Skip to content

Commit f492b94

Browse files
nilokGerrit Code Review
authored andcommitted
Merge "Neutron developer documentation"
2 parents 53d66bb + 01ed24f commit f492b94

File tree

1 file changed

+60
-1
lines changed
  • manuals/developer-guide/src/main/asciidoc/neutron

1 file changed

+60
-1
lines changed

manuals/developer-guide/src/main/asciidoc/neutron/neutron.adoc

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,63 @@ provider shows it is registering for *all* I*Aware interfaces:
120120

121121
=== How to use the Neutron YANG model
122122

123-
To be added
123+
For each neutron data object, there is an Neutron*Interface defined within
124+
the transcriber artifact that will write that object to the MD-SAL
125+
configurational datastore. +
126+
All Neutron*Interface extend AbstractNeutronInterface, in which two methods
127+
are defined: +
128+
129+
* one takes the neutron object as input, and will create a data object from it. +
130+
* one takes an uuid as input, and will create a data object containing the uuid.
131+
132+
----
133+
protected abstract T toMd(S neutronObject);
134+
protected abstract T toMd(String uuid);
135+
----
136+
137+
In addition the AbstractNeutronInterface class provides several other
138+
helper methods (addMd, updateMd, removeMd), which handle the actual
139+
writing to the configuration datastore.
140+
141+
==== The semantics of the toMD() methods
142+
Each of the Neutron YANG models defines structures containing data.
143+
Further each YANG-modeled structures has it own builder.
144+
A particular toMD() method instantiates an instance of the correct
145+
builder, fills in the properties of the builder from the corresponding
146+
values of the Neutron object and then creates the YANG-modeled structures
147+
via the build() method.
148+
149+
As an example, one of the toMD code for Neutron Networks is
150+
presented below:
151+
152+
----
153+
protected Network toMd(NeutronNetwork network) {
154+
NetworkBuilder networkBuilder = new NetworkBuilder();
155+
networkBuilder.setAdminStateUp(network.getAdminStateUp());
156+
if (network.getNetworkName() != null) {
157+
networkBuilder.setName(network.getNetworkName());
158+
}
159+
if (network.getShared() != null) {
160+
networkBuilder.setShared(network.getShared());
161+
}
162+
if (network.getStatus() != null) {
163+
networkBuilder.setStatus(network.getStatus());
164+
}
165+
if (network.getSubnets() != null) {
166+
List<Uuid> subnets = new ArrayList<Uuid>();
167+
for( String subnet : network.getSubnets()) {
168+
subnets.add(toUuid(subnet));
169+
}
170+
networkBuilder.setSubnets(subnets);
171+
}
172+
if (network.getTenantID() != null) {
173+
networkBuilder.setTenantId(toUuid(network.getTenantID()));
174+
}
175+
if (network.getNetworkUUID() != null) {
176+
networkBuilder.setUuid(toUuid(network.getNetworkUUID()));
177+
} else {
178+
logger.warn("Attempting to write neutron network without UUID");
179+
}
180+
return networkBuilder.build();
181+
}
182+
----

0 commit comments

Comments
 (0)