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