update link to upper-constraints.txt
[multicloud/framework.git] / docs / multicloud-plugin-vio / Multicloud-Fake_Cloud-Guide.rst
1 ..
2  This work is licensed under a Creative Commons Attribution 4.0
3  International License.
4
5
6 MultiCloud VMware OpenStack Simulated API User Case
7 ---------------------------------------------------
8
9 When there's no real VIO environment at hands, we could still use fake_cloud APIs
10 in VIO plugin to test ONAP functions. These set of APIs simulate the real VIO functions
11 to interact with ONAP components.
12
13 Make sure you environment have msb,aai service and multicloud-vmware config
14 file has the right msb_ip and
15 msb_port value,The config file path is vio/vio/pub/config/congfig.py
16
17
18
19 Register Fake Cloud to AAI
20 ~~~~~~~~~~~~~~~~~~~~~~~~~~
21
22 Register vio information into AAI service with region name "vmware" and region
23 id "fake"
24
25 .. code-block:: console
26
27   $ curl -X PUT  -H "X-TransactionId":"get_aai_subr" -H "X-FromAppId":"AAI" -H "Accept":"application/json" \
28     -H "Content-Type:"application/json"  -H "Authorization:Basic QUFJOkFBSQ==" \
29     https://aai_ip:aai_port/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/vmware/fake \
30       -d "{
31             "cloud-owner": "vmware",
32             "cloud-region-id": "fake",
33             "cloud-type": "vmware",
34             "cloud-region-version": "4.0",
35             "identity-url": "http://MSB_IP:MSB_PORT/api/multicloud/v0/vmware_fake/identity/v3",
36             "cloud-zone": "cloud zone",
37             "complex-name": "complex name",
38             "esr-system-info-list": {
39                 "esr-system-info": [
40                     {
41                         "system-name": "vmware-fake-cloud",
42                         "type": "vim",
43                         "service-url": "http://127.0.0.1:5000/v3",
44                         "user-name": "admin",
45                         "password": "vmware",
46                         "system-type": "VIM",
47                         "ssl-insecure": true,
48                         "cloud-domain": "default",
49                         "default-tenant": "admin",
50                     }
51                 ]
52             }
53       }"
54
55 the identity url reprent the fake cloud identity url.
56
57
58
59 Test Examples
60 ~~~~~~~~~~~~~
61
62 the ${fake_identiy_url}= "http://MSB_IP:MSB_PORT/api/multicloud/v0/vmware_fake/identity/v3"
63 the ${msb_address} =  "MSB_IP:MSB_PORT"
64
65 Get auth token
66 --------------
67
68 # send request to multicloud-framework(broker) service to get token of keystone
69 V3
70
71 .. code-block:: console
72
73   $ 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
74
75 test.json content example:
76
77 ::
78
79     {
80     "auth": {
81         "scope": {"project": {"id": “<project-id>”}},
82         "identity":
83         {
84         "password": {"user": {"domain": {"name": “<doman-name>”}, "password": “<user-password>”, "name": “<user-name>”}}, "methods": ["password"]
85         }
86     }
87     }
88
89
90 Response:
91 There are a large amounts of data including service endpoint, user information,
92 etc.
93 For our testing  We  take nova and identity service endpoint address and auth
94 token which is in response header named “X-Subject-Token”.
95
96 # you can find the endpoint url namespace is
97 "api/multicloiud-vio/v0/vmware_fake", it represent the multicloud-vio service,
98 So requests sending to mulitcloud-vio will be forwarded to fake cloud.the ip
99 and port reprenst ${msb_address}
100
101
102 Identity endpoint::
103
104     http://$msb_address/api/multicloud-vio/v0/vmware_fake/identity
105
106 Nova endpoint::
107
108     http://$msb_address/api/multicloud-vio/v0/vmware_fake/compute/<user-tenantid>
109
110
111 List projects
112 -------------
113
114 Use identity’s endpoint: http://$msb_address/api/multicloud-vio/v0/vmware_fake/identity/
115
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
121 Get os Hypervisor
122 -----------------
123
124 Use 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
132 List 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
140 Show instance detail
141 --------------------
142
143 you 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
150 Shutdown instance
151 -----------------
152
153 you 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
160 Start instance
161 --------------
162
163 you 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
170 Suspend instance
171 ----------------
172
173 you 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
180 Resume  instance
181 ----------------
182
183 you 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
190 Pause instance
191 --------------
192
193 you 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
200 Unpasue instance
201 ----------------
202
203 you 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
210 Reboot instance
211 ---------------
212
213 you 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
219
220 list 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
228 create 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
268 create  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
308 delete 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