Merge "ADD UT for ns_vnfs Issue-ID: VFC-1429 Signed-off-by: zhuerlei <zhu.erlei@zte...
[vfc/nfvo/lcm.git] / docs / platform / ns-instantiate-guide.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3
4 NS LCM Guide Using VF-C
5 -----------------------
6
7 VF-C supports vCPE use case in R3, all VNFs are deployed through VF-C GVNFM .
8 This page describe how to use VF-C to instantiate NS
9
10 Before you try, please prepare two csar file: 
11 * VNF csar
12 * NS csar
13
14 If you don't have any csar, you can download the simple csar from https://wiki.onap.org/display/DW/VF-C+User+Guide 
15
16
17 Environment
18 +++++++++++
19 VF-C components can run as docker, docker service should be installed before installing VF-C components.
20
21 The following scripts show the docker service install commands in centos 7.
22
23 ::
24
25   yum install docker
26   systemctl enable docker.service
27   systemctl start docker.service
28
29 Steps
30 +++++
31
32
33
34 If you want to  try VF-C, the small project set should include: VF-C , Multicloud, MSB and A&AI.
35
36 VF-C components need to register to MSB when starting, so MSB components should be installed first,you can refer the following link to install MSB.
37
38 http://onap.readthedocs.io/en/latest/submodules/msb/apigateway.git/docs/platform/installation.html
39
40 Note: In the following steps, we use ${MSB_IP} as the IP of msb_apigateway component.
41
42 1. Install vfc-nfvo-db component
43
44 ::
45
46   docker run -d -p 3306:3306 -p 6379:6379 --name vfc-db -v /var/lib/mysql nexus3.onap.org:10001/onap/vfc/db
47   we use  ${VFC_DB_IP} as the IP of vfc-db component.
48
49 2. Install vfc-nfvo-lcm component.
50
51 ::
52
53   docker run -d -p 8403:8403 --name vfc-nslcm -e MSB_ADDR=${MSB_IP}:80 -e MYSQL_ADDR=${VFC_DB_IP}:3306
54   nexus3.onap.org:10001/onap/vfc/nslcm
55
56 3. Install vfc-nfvo-catalog component.
57
58 ::
59
60   docker run -d -p 8806:8806 --name vfc-catalog -e MSB_ADDR=${MSB_IP}:80 -e MYSQL_ADDR=${VFC_DB_IP}:3306 nexus3.onap.org:10001/onap/vfc/catalog
61
62 4. Install vfc-nfvo-gvnfmdriver component.
63
64 ::
65
66   docker run -d -p 8484:8484 --name vfc-gvnfmdriver -e MSB_ADDR=${MSB_IP}:80 nexus3.onap.org:10001/onap/vfc/gvnfmdriver
67
68 5. Install vfc-gvnfm-vnflcm component.
69
70 ::
71
72   docker run -d -p 8801:8801 --name vfc-vnflcm -e MSB_ADDR=${MSB_IP}:80 -e MYSQL_ADDR=${VFC_DB_IP}:3306 nexus3.onap.org:10001/onap/vfc/vnflcm
73
74
75 ESR Registration
76 ++++++++++++++++
77
78
79 Before we instantiate a service, we need to register vim and vnfm which is used to deploy vnfs.
80   1.VIM Registration
81
82   |image1|
83
84   .. |image1| image:: vim.png
85    :width: 1000px
86    :height: 600px
87
88
89   2. GVNFM Registration
90
91   For VF-C, because we use GVNFM to deploy vnfs , so you can register GVNFM in esr gui as follows:
92
93   |image2|
94
95   .. |image2| image:: gvnfm.png
96    :width: 1000px
97    :height: 600px
98
99
100 Note: type should be gvnfmdriver which is the same with gvnfmdriver microservice
101 url is the msb-iag NodeIp:port 
102 vim corresponds to cloudowner_cloudregionid which registered in step1
103
104 Package Onboarding
105 ++++++++++++++++++
106
107
108 VF-C R3 support VNF/PNF/NS csar package upload from local csar file. VNF/PNF csar package should be uploaded first, then NS csar package can be uploaded.
109 Before onboarding a package,  should create one record first. 
110
111
112 1. Create VNF package record in catalog DB
113
114 ::
115
116   curl -X POST \
117
118   http://172.30.3.104:30280/api/vnfpkgm/v1/vnf_packages \
119
120   -H 'Postman-Token: f9c45dea-b7bb-4acd-89e1-b9b1c3d70d8a' \
121   -H 'accept: application/json' \
122   -H 'cache-control: no-cache' \
123   -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
124   -F 'userDefinedData= "key2": "value2"'
125
126 Note:  
127   a. 172.30.3.104:30280 is the node IP and exposed port where the msb-iag pod is located. 
128   b. userDefinedData is the key value pair which defined for the vnf package we created
129
130 2. Upload VNF package to VF-C catalog
131
132 ::
133
134   curl -X PUT \
135   http://172.30.3.104:30280/api/vnfpkgm/v1/vnf_packages/38037a12-a0d4-4aa4-ac50-cd6b05ce0b24/package_content \
136   -H 'Postman-Token: 88ada218-86fd-4cd7-a06e-cc462f5df651' \
137   -H 'cache-control: no-cache'
138   -H 'accept: application/json' \
139   -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
140   -F 'file=@C:\ONAP\Integration\R3\vCPE\vnf-vsn.csar'
141
142 Note:
143   a.  38037a12-a0d4-4aa4-ac50-cd6b05ce0b24  is the vnf_pkg_id which we get from the first step.
144   b.  -F is used to specify the local vnf package file
145
146 3. Create NS package record in catalog DB
147
148 ::
149
150   curl -X POST \
151
152   http://172.30.3.104:30280/api/nsd/v1/ns_descriptors \
153   -H 'Postman-Token: 71b11910-1708-471c-84bb-5b0dd8d214a2' \
154   -H 'accept: application/json' \
155   -H 'cache-control: no-cache' \
156   -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
157   -F 'userDefinedData= "key1": "value1"'
158
159 Note:
160   a. userDefinedData is the key value pair which defined for the ns package we created
161
162 4. Upload NS package to VF-C catalog
163
164 ::
165
166   curl -X PUT \
167   http://172.30.3.104:30280/api/nsd/v1/ns_descriptors/79ca81ec-10e0-44e4-bc85-ba968f345711/nsd_content \
168   -H 'Postman-Token: f16e4a54-a514-4878-b307-9b80c630166e' \
169   -H 'cache-control: no-cache'
170   -H 'accept: application/json' \
171   -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
172   -F 'file=@C:\ONAP\Integration\R3\vCPE\ns.csar'
173
174 Note:
175   a.  -F is used to specify the local ns package file
176
177
178 NS Life Cycle Management
179 ++++++++++++++++++++++++
180
181
182 Currently VF-C GVNFM support NS create/Instantiate/terminate/delete/heal.
183
184 VF-C R3 healing only suport restart a vm of an VNF. 
185
186 1. NS Create 
187
188 ::
189
190   curl -X POST \
191   http://172.30.3.104:30280/api/nslcm/v1/ns \
192   -H 'Postman-Token: 27e2c576-2d9b-4753-a6b0-6262a4a7ec86' \
193   -H 'accept: application/json' \
194   -H 'cache-control: no-cache' \
195   -H 'content-type: application/json' \
196   -d '{
197        "context": {
198                 "globalCustomerId": "global-customer-id-test1",
199                 "serviceType": "service-type-test1"
200         },
201         "csarId": "79ca81ec-10e0-44e4-bc85-ba968f345711",
202         "nsName": "ns_vsn",
203         "description": "description"
204         }'
205
206 Note:
207   a.  globalCustomerId  and serviceType is defined in A&AI.
208   b. csar Id is the NS package id  which is consistent with the catalog ns package id.
209   c. nsName is the NS name 
210
211 2. NS Instantiate
212
213 ::
214
215    curl -X POST \
216   http://172.30.3.104:30280/api/nslcm/v1/ns/f0b4c09f-c653-438a-b091-5218b0f806ec/instantiate \
217   -H 'Postman-Token: 2a9542b2-3364-4a40-8513-45e10b8ca2ce' \
218   -H 'accept: application/json' \
219   -H 'cache-control: no-cache' \
220   -H 'content-type: application/json' \
221     -d '{
222          "additionalParamForNs": {
223                 "sdnControllerId": "2"
224          },
225          "locationConstraints": [{
226                 "vnfProfileId": "45711f40-3f43-415b-bb45-46e5c6940735",
227                 "locationConstraints": {
228                       "vimId": "CPE-DC_RegionOne"
229                 }
230                 }]
231          }'
232
233 Note:
234   a.  f0b4c09f-c653-438a-b091-5218b0f806ec is the ns instance id which create in step 1 : NS create.
235   b.  locationConstraints  is an array which contains all the vnfs included under NS locationConstraints is used to define the VIM( cloudOwner_cloudRegionId)  that the VNF will be deployed vnfProfileId is the vnf descriptor id which defined in NS template  under  node_templates . 
236
237
238  |image3|
239
240   .. |image3| image:: image2018-12-10_12-1-36.png
241    :width: 5.97047in
242    :height: 2.63208in
243
244   c.   before instantiate, you should create one volumntype which is called root.
245
246 3. NS Heal
247
248 ::
249
250   curl -X PUT \
251    http://172.30.3.104:30280/api/nslcm/v1/ns/f0b4c09f-c653-438a-b091-5218b0f806ec/heal \
252   -H 'Content-Type: application/json' \
253   -H 'Postman-Token: f18754b8-ed68-43b0-ae55-b8b8780e5c6a' \
254   -H 'accept: application/json' \
255   -H 'cache-control: no-cache' \
256   -d '{   "vnfInstanceId": "044b705c-e44d-4733-ab64-987f46d9b567", 
257                     "cause": "restartvm",  
258                     "additionalParams": {    
259                                                         "action": "restartvm",  
260                                                          "actionvminfo": {   
261                                                          "vmid": "1623cd25-ae6f-4880-8132-15914367e47b",
262                                                          "vduid": "",    
263                                                           "vmname": "1623cd25-ae6f-4880-8132-15914367e47b"  
264         }}  
265         }'
266
267 Note:
268   a.  f0b4c09f-c653-438a-b091-5218b0f806ec  is the ns instance id which create in step 1 : NS create.
269   b.   "vnfInstanceId": "044b705c-e44d-4733-ab64-987f46d9b567" is the VNF instanceId, we can get this from A&AI or VF-C DB.
270   c.  action only support restartvm  in Casablanca release.
271   d.  actionvminfo only supports to include one vm , vmid is the vmid which is the same with the vmid in cloud. 
272
273 4. NS Terminate
274
275 ::
276
277   curl -X POST \
278   http://172.30.3.104:30280/api/nslcm/v1/ns/f0b4c09f-c653-438a-b091-5218b0f806ec/terminate \
279   -H 'Postman-Token: 5190e46f-f612-432a-90d8-161ea67778b2' \
280   -H 'accept: application/json' \
281   -H 'cache-control: no-cache' \
282   -H 'content-type: application/json' \
283   -d 'gracefulTerminationTimeout: 600,
284   \terminationType: FORCEFUL'
285
286 Note:
287   a.  f0b4c09f-c653-438a-b091-5218b0f806ec  is the ns instance id which create in step 1 : NS create.
288   b.  terminateType supports FORCEFUL and GRACEFULLc.  gracefulTerminationTimeout is the wait time before execute terminate.
289
290 5. NS delete
291
292 ::
293
294   curl -X DELETE \
295   http://172.30.3.104:30280/api/nslcm/v1/ns/f0b4c09f-c653-438a-b091-5218b0f806ec \
296   -H 'Postman-Token: 62b35de6-1785-40ed-8026-06d73f9770d8' \
297   -H 'cache-control: no-cache'
298
299 Note:
300   a.  f0b4c09f-c653-438a-b091-5218b0f806ec is the ns instance id which create in step 1 : NS create