Li Xinhui | 3457d6e | 2018-04-16 16:51:15 +0800 | [diff] [blame] | 1 | .. |
| 2 | This work is licensed under a Creative Commons Attribution 4.0 |
| 3 | International License. |
Ethan Lynn | 2906f88 | 2018-01-15 10:32:43 +0800 | [diff] [blame] | 4 | |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 5 | ================================ |
| 6 | MultiCloud Fake_Cloud User Case |
| 7 | ================================ |
| 8 | |
| 9 | |
| 10 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 11 | multilcoud-vmware server not only provide vio plugin to access real openstack |
| 12 | platform,but |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 13 | also provide fake_cloud plugin which simulate thereal VIO function.The fake |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 14 | cloud is suitable for testing openstack function if there is not real VIO |
| 15 | platform. |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 16 | |
| 17 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 18 | Make sure you environment have msb,aai service and multicloud-vmware config |
| 19 | file has the right msb_ip and |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 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 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 27 | Register vio information into AAI service with region name "vmware" and region |
| 28 | id "fake" |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 29 | |
| 30 | .. code-block:: console |
| 31 | |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 32 | $ curl -X PUT -H "X-TransactionId":"get_aai_subr" -H "X-FromAppId":"AAI" -H "Accept":"application/json" \ |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 33 | -H "Content-Type:"application/json" -H "Authorization:Basic QUFJOkFBSQ==" \ |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 34 | https://aai_ip:aai_port/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/vmware/fake \ |
| 35 | -d "{ |
| 36 | "cloud-owner": "vmware", |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 37 | "cloud-region-id": "fake", |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 38 | "cloud-type": "vmware", |
| 39 | "cloud-region-version": "4.0", |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 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", |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 43 | "esr-system-info-list": { |
| 44 | "esr-system-info": [ |
| 45 | { |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 46 | "system-name": "vmware-fake-cloud", |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 47 | "type": "vim", |
| 48 | "service-url": "http://127.0.0.1:5000/v3", |
| 49 | "user-name": "admin", |
| 50 | "password": "vmware", |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 51 | "system-type": "VIM", |
| 52 | "ssl-insecure": true, |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 53 | "cloud-domain": "default", |
| 54 | "default-tenant": "admin", |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 55 | } |
| 56 | ] |
| 57 | } |
| 58 | }" |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 59 | |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 60 | the identity url reprent the fake cloud identity url. |
| 61 | |
| 62 | |
| 63 | |
| 64 | Test Examples |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 65 | ~~~~~~~~~~~~~ |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 66 | |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 67 | the ${fake_identiy_url}= "http://MSB_IP:MSB_PORT/api/multicloud/v0/vmware_fake/identity/v3" |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 68 | the ${msb_address} = "MSB_IP:MSB_PORT" |
| 69 | |
| 70 | Get auth token |
| 71 | -------------- |
| 72 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 73 | # send request to multicloud-framework(broker) service to get token of keystone |
| 74 | V3 |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 75 | |
| 76 | .. code-block:: console |
| 77 | |
liangke | 147839b | 2017-10-23 15:07:39 +0800 | [diff] [blame] | 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 |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 79 | |
| 80 | test.json content example: |
| 81 | |
| 82 | :: |
| 83 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 84 | { |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 85 | "auth": { |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 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 | } |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 91 | } |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 92 | } |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 93 | |
| 94 | |
| 95 | Response: |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 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”. |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 100 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 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} |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 105 | |
| 106 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 107 | Identity endpoint:: |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 108 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 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> |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 114 | |
| 115 | |
| 116 | List projects |
| 117 | ------------- |
| 118 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 119 | Use identity’s endpoint: http://$msb_address/api/multicloud-vio/v0/vmware_fake/identity/ |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 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 | |
liangke | 147839b | 2017-10-23 15:07:39 +0800 | [diff] [blame] | 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\" > /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\" > /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 | |