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