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