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