[SO-BPMN-INFRA] Remove trailing slash from SDNC calls
[so.git] / docs / developer_info / mso_adapter_restinterface.rst
1 Mso-adapters-rest-interface
2 ---------------------------
3 .. image:: ../images/module_structure.png
4
5 It mainly contains the payload that is provided to different rest calls in SO
6
7 Network
8 --------
9 # 1. Network contain beans( classes with multiple attributes and thier setters and getters) and their corresponding mappers which will be used by the network adapter of  SO. Contrail networking is used for cloud network automation
10
11 Beans
12 -----
13  # a. ContrailPolicyRef : this class has following attribute    
14        private ContrailPolicyRefSeq seq;
15
16        Usage: adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java- while creating network in openstack,  network stack is created depending on stackParams. So if pFqdns(FQDN address object is used in order to use DNS names in firewall policies) are there in the inputrequest to createNetwork, then mergePolicyRefs method is called, where for each input pFqdns, a new ContrailPolicyRef is created and appended to a list. Then this is added as value to stackParams with policy_refsdata as key.
17
18  # b. ContrailPolicyRefSeq : Attributes are
19    private String major;
20
21    private String minor ;
22
23    Usage: adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java- As this is an attribute to the ContrailPolicyRef explained above. So when a new ContrailPolicyRef() is created in mergePolicyRefs method, correspondingly a new ContrailPolicyRefSeq should be created.
24
25  # c. ContrailSubnet – Its a subnetwork having attributes 
26     private ContrailSubnetIp subnet = new ContrailSubnetIp();
27
28     private String defaultGateway;
29
30     private String subnetName;
31
32     private Boolean enableDhcp(dynamic host config);
33
34     private Boolean addrFromStart = true;
35
36     private List<ContrailSubnetPool> allocationPools = new ArrayList<>();
37
38     private ContrailSubnetHostRoutes hostRoutes = new ContrailSubnetHostRoutes();
39
40     Usage : adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java- While creating network mergeSubnetsAIC3 is called if a list of subnets are present. The subnets are mapped to ContrailSubnet using ContrailSubnetMapper, and then are added to the heat template and stackparams which are used for network creation in openstack.
41
42  # d. ContrailSubnetHostRoute : This is an attribute defined in contrailsubnet and has following attributes
43     private String prefix;
44
45     private String nextHop; 
46
47     Usage : This is an attribute of ContrailSubnetHostRoutes , which is used within the contrailSubnet and thus is used in network creation and updation.
48
49  # e. ContrailSubnetHostRoutes : This class is used to store an list of ContrailSubnetHostRoute 
50
51     private List<ContrailSubnetHostRoute> hostRoutes = new ArrayList<>();
52
53     Usage : attribute of contrailSubnet
54
55  # f. ContrailSubnetIp : attributes are
56      private String ipPrefix;
57
58      private String ipPrefixLen; 
59  
60      This class is used to store the cidr value , which is used as a interrouting table, taking as ipaddress/total no . Eg : 10.0.0.0/24 means starting ip is 10.0.0.0, and total no of ip address possible here is 256 (2^(32-24)), the last address being 10.0.0.255.
61
62      Usage : important attribute of contrailSubnet
63
64  # g. ContrailSubnetPool : attributes are starting and ending ip address of the subnet
65     private String start;
66
67     private String end;
68
69     Usage: a list of ContrailSubnetPool forms an important attribute of contrailSubnet
70
71 Mappers
72 -------
73
74  # a. ContrailSubnetMapper : It is used to map the inputsubnet to a contrailSubnet
75    public ContrailSubnetMapper(Subnet inputSubnet) {
76         this.inputSubnet = inputSubnet;
77
78     }
79
80    The map method within is used for the mapping. Here first a contrailSubnet is created, and depending on whether the subnet has name or id, the contrailSubnet’s name is initialized, then if it has cidr , then a contrailSubnetIp is created, and is added into it, which is then added to contrailSubnet created before. Depending on whether input has allocationpool or hostroutes, these are casted into ContrailSubnetPool and ContrailSubnetHostRoute using ContrailSubnetPoolMapper and ContrailSubnetPoolMapper respectively.
81
82    Usage: adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java :The subnets are mapped to ContrailSubnet using ContrailSubnetMapper, and then are added to the heat template and stackparams which are used for network creation
83
84  # b. ContrailSubnetPoolMapper : It is used to map the pool within the subnets to contrailSubnetPool. Used within contrailSubnetMapper. Here, the particular pool is added only if it has both the start and end ip address. 
85
86  # c. ContrailSubnetHostRoute : It is used to map the host routes within the subnets to contrailSubnetHostRoute. Used within contrailSubnetMapper. Here, the particular host route is added if either of the next hop or ip prefix is defined.
87
88 Network request
89 ---------------
90
91 #2. Network request : It contains the payloads for different types of network requests
92
93  # a. ContrailNetwork :
94     private String shared = "false";
95
96     private String external = "false";
97
98     private List<RouteTarget> routeTargets;
99
100     private List<String> policyFqdns;
101
102     private List<String> routeTableFqdns;
103
104     Usage: contrailNetwork is an important attribute of CreateNetworkRequest, So is to be used where all the request to createNetwork is required.
105
106   # 1. adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java : Here the input to createNetwork requires contrailNetwork parameter, so here it checks whether  contrailNetwork is already present, if not a new is created.
107
108   # 2.bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java : Here in createNetworkRequestMapper, createNetworkRequest is formed where in buildContrailNetwork, a new contrailNetwork is created and initialized. This request is used to create a network and set the corresponding execution variable   
109
110  # b. CreateNetworkError: It extends NetworkExceptionResponse. And is used when an error occurs during network creation
111
112  # c. NetworkExceptionResponse : it extends NetworkResponseCommon. Attributes are 
113     private String message;
114
115     private MsoExceptionCategory category;
116
117     private Boolean rolledBack; 
118
119  # d. NetworkResponseCommon: Attribute is 
120     private String messageId; 
121
122  # e. CreateNetworkRequest: extends NetworkRequestCommon
123     private String cloudSiteId;
124
125     private String tenantId;
126
127     private String networkId;
128
129     private String networkName;
130
131     private String networkType;
132
133     private String networkTypeVersion;
134
135     private String modelCustomizationUuid;
136
137     private String networkTechnology = "NEUTRON";
138
139     private List<Subnet> subnets;
140
141     private ProviderVlanNetwork providerVlanNetwork;
142
143     private ContrailNetwork contrailNetwork;
144
145     private Boolean failIfExists = false;
146
147     private Boolean backout = true;
148
149     private Map<String, String> networkParams = new HashMap<>();
150
151     private MsoRequest msoRequest = new MsoRequest();
152
153     private boolean contrailRequest;
154
155     Usage :
156     #1) bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java:  Here in getNetworkVpnBinding, where VPN Binding data from AAI result is extracted. There in routeTargets is got, and is updated in the execution variable(“createNetworkRequest”).
157
158     #2)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java – Here in createnetwork returns a CreateNetworkRequest which is updated in execution variable(“networkAdapterRequest”)
159
160     #3)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java - 
161     Here in createnetwork returns a CreateNetworkRequest which is updated in execution variable(“createNetworkRequest”)
162
163     #4) bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java -Here createNetwork request is processed as a restclient post process with CreateNetworkRequest as input.
164
165  # f. CreateNetworkResponse : extends NetworkResponseCommon
166     private String networkId;
167
168     private String neutronNetworkId;
169
170     private String networkStackId;
171
172     private String networkFqdn;
173
174     private Boolean networkCreated;
175
176     private Map<String, String> subnetMap;
177
178     private NetworkRollback rollback = new NetworkRollback();
179
180     Usage:
181     #1)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java :here after the network is created, the l3 network is updated with those parameters which come from execution variable("createNetworkResponse")
182
183     #2)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java – depending on variable networkCreated of response, networkAdapterCreateRollback is set to true. 
184
185     #3)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java -Here createNetwork request is processed as a restclient post process with CreateNetworkRequest as input and CreateNetworkResponse as output 
186
187  # g.DeleteNetworkError : extends NetworkExceptionResponse
188
189  # h. DeleteNetworkRequest:extends NetworkRequestCommon
190     private String cloudSiteId;
191
192     private String tenantId;
193
194     private String networkId;
195
196     private String networkStackId;
197
198     private String networkType;
199
200     private String modelCustomizationUuid;
201
202     private MsoRequest msoRequest = new MsoRequest();
203
204     Usage: 
205     #1)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java – deleteNetworkRequestMapper returns a DeleteNetworkRequest, which is set to the execution variable(“networkAdapterRequest”)
206
207     #2)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java - Here deleteNetwork request is processed as a restclient delete process with DeleteNetworkRequest as input.
208
209     #3)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java – Here the deleteNetworkRequestMapper forms DeleteNetworkRequest object 
210
211   Similarly others are also implemented and used
212  
213 .. image:: ../images/nwrest.png
214
215 Sdnc request
216 ------------
217
218 #3. Sdnc request -These are required by the mso-sdnc-adapter
219
220  # a. RequestInformation – This is an important parameter of SDNCServiceRequest. Thud is used during the conversion of SDNCServiceRequest to XMLstring.
221
222  # b. ServiceInformation – This stores the important information like serviceId, servicetype and SubscriberName. Its parameter of SDNCServiceRequest.
223
224  # c. SDNCErrorCommon – it extends SDNCResponseCommon . 
225  
226   Usage : adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java – catching exception if any happens during request creation and a new SDNCErrorCommon is created.
227
228  # d. SDNCRequestCommon – SDNCServiceRequest extends SDNCRequestCommon. It has some attributes like bpNotificationUrl(Endpoint on which BPMN can receive notifications from the SDNC adapter), bpTimeout ans sdncrequestId.
229
230  # e. SDNCServiceRequest
231   Usage: adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java – Here the runRequest is happening, where we are posting this request using a restclient call with SDNCServiceRequest as input.
232
233  # f. SDNCServiceResponse and SDNCServiceError 
234   Usage:adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java – Here if the above runRequest returns a 2xx response code then a corresponding SDNCServiceResponse is created and returned or else SDNCServiceError is created and returned
235
236 Tenant request
237 ---------------
238
239 #4. These provide classes to be used by the so-adapters.tenant.
240
241 The operator of a cloud can present unchangeable networks to the users, or give users the option to create, delete, connect and generally manipulate networks. The latter type of networks is called “tenant networks”.
242
243 Used in adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/TenantAdapterRest.java
244
245 The implementation and usage is similiar to the above classes
246
247 .. image:: ../images/tenantrest.png
248
249 VDU
250 ---
251
252 #5. Vdu – these are used for the deployment and management of (cloud-agnostic) VDU . The abstract classes for instantiation of vdu, query vdu, delete vdu, update vdu are defined in here.
253
254 These are implemented in adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java and adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
255
256 Vnfrest
257 -------
258
259 #6. Vnfrest – These are used to manage vnfs and vgs.
260 These are used in the project similiar to networkrest
261 Foreg : Usage of DeleteVfModuleRequest: 
262
263 1)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasks.java – Here in deleteVfModuleRequestMapper creates a new DeleteVfModuleRequest, and is set to the execution variable(“VNFREST_REQUEST” ) and “deleteVfModuleRequest” execution variable is set true
264
265 2)bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java -  Here a delete rest request is send
266
267 .. image:: ../images/vnfrest.png
268
269
270 OPENSTACK
271 ---------
272 Openstack is classified into beans, exceptions, and mappers
273
274 MAPPERS
275 -------
276  # 1) JAXBContext: It is used to convert a object to xml(marshalling) and to convert xml to object (unmarshalling) . These marshalling and unmarshalling are overriden in the map adapters in mappers.
277
278  # 2)NetworkInfoMapper – used to Capture the data from a Neutron Network object and cast it into a networkInfo( present in beans of openstack). Here in vlan information is located depending on network.getProviderNetworkType() , and if not then the segments within the network is iterated and is checked for the same.
279   Usage: It is used in adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java , where on createNetwork, queryNetwork and updateNetwork , the network is mapped by  NetworkInfoMapper into networkInfo and returned.
280
281  # 3) StackInfoMapper – used to Capture the data from a Stack object and cast it into a stackInfo( present in beans of openstack). 
282   Usage: It is used in adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils , where all createStack, queryStack, updateStack, deleteStack is done, a new instance of stackInfo is returned
283
284 Exceptions
285 ----------
286 These are set of msoexceptions provided, and would be used depending on what exception needs to be handled
287
288 .. image:: ../images/msoexception.png