blob: 0b78a3d00586af63bef98cdac7e8a0f6ff34e019 [file] [log] [blame]
Li Xinhui3457d6e2018-04-16 16:51:15 +08001..
2 This work is licensed under a Creative Commons Attribution 4.0
3 International License.
Ethan Lynn2906f882018-01-15 10:32:43 +08004
Ethan Lynn66b38de2018-11-07 11:31:10 +08005
Ethan Lynnc918a202018-11-05 14:41:16 +08006MultiCloud VMware OpenStack Simulated API User Case
Ethan Lynn66b38de2018-11-07 11:31:10 +08007---------------------------------------------------
liangke01ef9142017-10-12 18:09:15 +08008
Ethan Lynnc918a202018-11-05 14:41:16 +08009When there's no real VIO environment at hands, we could still use fake_cloud APIs
10in VIO plugin to test ONAP functions. These set of APIs simulate the real VIO functions
11to interact with ONAP components.
liangke01ef9142017-10-12 18:09:15 +080012
Ethan Lynnb3e79cc2018-06-05 17:26:55 +080013Make sure you environment have msb,aai service and multicloud-vmware config
14file has the right msb_ip and
liangke01ef9142017-10-12 18:09:15 +080015msb_port value,The config file path is vio/vio/pub/config/congfig.py
16
17
18
19Register Fake Cloud to AAI
20~~~~~~~~~~~~~~~~~~~~~~~~~~
21
Ethan Lynnb3e79cc2018-06-05 17:26:55 +080022Register vio information into AAI service with region name "vmware" and region
23id "fake"
liangke01ef9142017-10-12 18:09:15 +080024
25.. code-block:: console
26
Ethan Lynn42fbfdc2017-10-20 13:52:45 +080027 $ curl -X PUT -H "X-TransactionId":"get_aai_subr" -H "X-FromAppId":"AAI" -H "Accept":"application/json" \
liangkeabfed002017-10-23 16:24:37 +080028 -H "Content-Type:"application/json" -H "Authorization:Basic QUFJOkFBSQ==" \
Ethan Lynn42fbfdc2017-10-20 13:52:45 +080029 https://aai_ip:aai_port/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/vmware/fake \
30 -d "{
31 "cloud-owner": "vmware",
liangkeabfed002017-10-23 16:24:37 +080032 "cloud-region-id": "fake",
Ethan Lynn42fbfdc2017-10-20 13:52:45 +080033 "cloud-type": "vmware",
34 "cloud-region-version": "4.0",
liangkeabfed002017-10-23 16:24:37 +080035 "identity-url": "http://MSB_IP:MSB_PORT/api/multicloud/v0/vmware_fake/identity/v3",
36 "cloud-zone": "cloud zone",
37 "complex-name": "complex name",
Ethan Lynn42fbfdc2017-10-20 13:52:45 +080038 "esr-system-info-list": {
39 "esr-system-info": [
40 {
liangkeabfed002017-10-23 16:24:37 +080041 "system-name": "vmware-fake-cloud",
Ethan Lynn42fbfdc2017-10-20 13:52:45 +080042 "type": "vim",
43 "service-url": "http://127.0.0.1:5000/v3",
44 "user-name": "admin",
45 "password": "vmware",
liangkeabfed002017-10-23 16:24:37 +080046 "system-type": "VIM",
47 "ssl-insecure": true,
Ethan Lynn42fbfdc2017-10-20 13:52:45 +080048 "cloud-domain": "default",
49 "default-tenant": "admin",
Ethan Lynn42fbfdc2017-10-20 13:52:45 +080050 }
51 ]
52 }
53 }"
liangke01ef9142017-10-12 18:09:15 +080054
liangke01ef9142017-10-12 18:09:15 +080055the identity url reprent the fake cloud identity url.
56
57
58
59Test Examples
Ethan Lynn42fbfdc2017-10-20 13:52:45 +080060~~~~~~~~~~~~~
liangke01ef9142017-10-12 18:09:15 +080061
liangkeabfed002017-10-23 16:24:37 +080062the ${fake_identiy_url}= "http://MSB_IP:MSB_PORT/api/multicloud/v0/vmware_fake/identity/v3"
liangke01ef9142017-10-12 18:09:15 +080063the ${msb_address} = "MSB_IP:MSB_PORT"
64
65Get auth token
66--------------
67
Ethan Lynnb3e79cc2018-06-05 17:26:55 +080068# send request to multicloud-framework(broker) service to get token of keystone
69V3
liangke01ef9142017-10-12 18:09:15 +080070
71.. code-block:: console
72
liangke147839b2017-10-23 15:07:39 +080073 $ curl -X POST -d @test.json -H 'Content-Type:application/json' http://MSB_IP:MSB_PORT/api/multicloud/v0/vmware_fake/identity/v3/auth/tokens
liangke01ef9142017-10-12 18:09:15 +080074
75test.json content example:
76
77::
78
Ethan Lynnb3e79cc2018-06-05 17:26:55 +080079 {
liangkeabfed002017-10-23 16:24:37 +080080 "auth": {
Ethan Lynnb3e79cc2018-06-05 17:26:55 +080081 "scope": {"project": {"id": “<project-id>”}},
82 "identity":
83 {
84 "password": {"user": {"domain": {"name": “<doman-name>”}, "password": “<user-password>”, "name": “<user-name>”}}, "methods": ["password"]
85 }
liangke01ef9142017-10-12 18:09:15 +080086 }
Ethan Lynnb3e79cc2018-06-05 17:26:55 +080087 }
liangke01ef9142017-10-12 18:09:15 +080088
89
90Response:
Ethan Lynnb3e79cc2018-06-05 17:26:55 +080091There are a large amounts of data including service endpoint, user information,
92etc.
93For our testing We take nova and identity service endpoint address and auth
94token which is in response header named “X-Subject-Token”.
liangke01ef9142017-10-12 18:09:15 +080095
Ethan Lynnb3e79cc2018-06-05 17:26:55 +080096# you can find the endpoint url namespace is
97"api/multicloiud-vio/v0/vmware_fake", it represent the multicloud-vio service,
98So requests sending to mulitcloud-vio will be forwarded to fake cloud.the ip
99and port reprenst ${msb_address}
liangke01ef9142017-10-12 18:09:15 +0800100
101
Ethan Lynnb3e79cc2018-06-05 17:26:55 +0800102Identity endpoint::
liangke01ef9142017-10-12 18:09:15 +0800103
Ethan Lynnb3e79cc2018-06-05 17:26:55 +0800104 http://$msb_address/api/multicloud-vio/v0/vmware_fake/identity
105
106Nova endpoint::
107
108 http://$msb_address/api/multicloud-vio/v0/vmware_fake/compute/<user-tenantid>
liangke01ef9142017-10-12 18:09:15 +0800109
110
111List projects
112-------------
113
Ethan Lynnb3e79cc2018-06-05 17:26:55 +0800114Use identity’s endpoint: http://$msb_address/api/multicloud-vio/v0/vmware_fake/identity/
liangke01ef9142017-10-12 18:09:15 +0800115
116.. code-block:: console
117
118 $ curl -X GET -H 'X-Auth-Token:<token>' http://$msb_address/api/multicloud-vio/v0/vmware_fake/identity/projects
119
120
121Get os Hypervisor
122-----------------
123
124Use nova’s endpoint: http://$msb_address/api/multicloud-vio/v0/vmware_fake/nova/<user-tenantid>
125
126
127.. code-block:: console
128
129 $ curl -X GET -H 'X-Auth-Token:<token>' http://$msb_address/api/multicloud-vio/v0/vmware_fake/nova/<tenantid>/os-hypervisors/detail
130
131
132List instance of user’s project
133--------------------------------
134
135.. code-block:: console
136
137 $ curl -X GET -H 'X-Auth-Token:<token>' http://$msb_address/api/multicloud-vio/v0/vmware_fake/nova/<tenantid>/servers
138
139
140Show instance detail
141--------------------
142
143you need to input <server-id> in url path.
144
145.. code-block:: console
146
147 $ curl -X GET -H 'X-Auth-Token:<token>' http://$msb_address/api/multicloud-vio/v0/vimid/nova/tenantid/servers/<server-id>
148
149
150Shutdown instance
151-----------------
152
153you need to input <server-id> in url path
154
155.. code-block:: console
156
157 $ curl -X POST -d '{"os-stop":null}' -H 'X-Auth-Token:<token>' -H 'Content-Type:application/json' http://$msb_address/api/multicloud-vio/v0/vmware_fake/nova/<tenantid>/servers/<server-id>/action
158
159
160Start instance
161--------------
162
163you need to input <server-id> in url path
164
165.. code-block:: console
166
167 $ curl -X POST -d '{"os-start":null}' -H 'X-Auth-Token:<token>' -H 'Content-Type:application/json' http://$msb_address/api/multicloud-vio/v0/vmware_fake/nova/<tenantid>/servers/<server-id>/action
168
169
170Suspend instance
171----------------
172
173you need to input <server-id> in url path
174
175.. code-block:: console
176
177 $ curl -X POST -d '{"suspend":null}' -H 'X-Auth-Token:<token>' -H 'Content-Type:application/json' http://$msb_address/api/multicloud-vio/v0/vmware_fake/nova/<tenantid>/servers/<server-id>/action
178
179
180Resume instance
181----------------
182
183you need to input <server-id> in url path
184
185.. code-block:: console
186
187 $ curl -X POST -d '{"resume":null}' -H 'X-Auth-Token:<token>' -H 'Content-Type:application/json' http://$msb_address/api/multicloud-vio/v0/vmware_fake/nova/<tenantid>/servers/<server-id>/action
188
189
190Pause instance
191--------------
192
193you need to input <server-id> in url path
194
195.. code-block:: console
196
197 $ curl -X POST -d '{"pause":null}' -H 'X-Auth-Token:<token>' -H 'Content-Type:application/json' http://$msb_address/api/multicloud-vio/v0/vmware_fake/nova/<tenantid>/servers/<server-id>/action
198
199
200Unpasue instance
201----------------
202
203you need to input <server-id> in url path
204
205.. code-block:: console
206
207 $ curl -X POST -d '{"unpause":null}' -H 'X-Auth-Token:<token> -H 'Content-Type:application/json' http://$msb_address/api/multicloud-vio/v0/vmware_fake/nova/<tenantid>/servers/<server-id>/action
208
209
210Reboot instance
211---------------
212
213you need to input <server-id> in url path
214
215.. code-block:: console
216
217 $ curl -X POST -d '{"reboot":{"type":"HARD"}}' -H 'X-Auth-Token:<token> -H 'Content-Type:application/json' http://$msb_address/api/multicloud-vio/v0/vmware_fake/nova/<tenantid>/servers/<server-id>/action
218
liangke147839b2017-10-23 15:07:39 +0800219
220list heat stacks
221----------------
222
223.. code-block:: console
224
225 $ curl -X GET -H 'X-Auth-Token:<token>' http://$msb_address/api/multicloud-vio/v0/vmware_fake/heat/<tenantid>/stacks
226
227
228create preview stack
229--------------------
230
231.. code-block:: console
232
233 $ curl -X POST -H 'X-Auth-Token:<token>' http://$msb_address/api/multicloud-vio/v0/vmware_fake/heat/<tenantid>/stacks/preview \
234 -d "{
235 "files": {},
236 "disable_rollback": true,
237 "parameters": {
238 "flavor": "m1.heat"
239 },
240 "stack_name": "teststack",
241 "template": {
242 "heat_template_version": "2013-05-23",
243 "description": "Simple template to test heat commands",
244 "parameters": {
245 "flavor": {
246 "default": "m1.tiny",
247 "type": "string"
248 }
249 },
250 "resources": {
251 "hello_world": {
252 "type": "OS::Nova::Server",
253 "properties": {
254 "key_name": "heat_key",
255 "flavor": {
256 "get_param": "flavor"
257 },
258 "image": "40be8d1a-3eb9-40de-8abd-43237517384f",
259 "user_data": "#!/bin/bash -xv\necho \"hello world\" &gt; /root/hello-world.txt\n"
260 }
261 }
262 }
263 },
264 "timeout_mins": 60
265 }"
266
267
268create stack
269-------------
270
271.. code-block:: console
272
273 $ curl -X POST -H 'X-Auth-Token:<token>' http://$msb_address/api/multicloud-vio/v0/vmware_fake/heat/<tenantid>/stacks \
274 -d "{
275 "files": {},
276 "disable_rollback": true,
277 "parameters": {
278 "flavor": "m1.heat"
279 },
280 "stack_name": "teststack",
281 "template": {
282 "heat_template_version": "2013-05-23",
283 "description": "Simple template to test heat commands",
284 "parameters": {
285 "flavor": {
286 "default": "m1.tiny",
287 "type": "string"
288 }
289 },
290 "resources": {
291 "hello_world": {
292 "type": "OS::Nova::Server",
293 "properties": {
294 "key_name": "heat_key",
295 "flavor": {
296 "get_param": "flavor"
297 },
298 "image": "40be8d1a-3eb9-40de-8abd-43237517384f",
299 "user_data": "#!/bin/bash -xv\necho \"hello world\" &gt; /root/hello-world.txt\n"
300 }
301 }
302 }
303 },
304 "timeout_mins": 60
305 }"
306
307
308delete stack
309------------
310
311.. code-block:: console
312
313 $ curl -X DELETE -H 'X-Auth-Token:<token>' http://$msb_address/api/multicloud-vio/v0/vmware_fake/heat/<tenantid>/stacks/<stack_name>/<stack_id>
314