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 | |
Ethan Lynn | 66b38de | 2018-11-07 11:31:10 +0800 | [diff] [blame] | 5 | |
Ethan Lynn | c918a20 | 2018-11-05 14:41:16 +0800 | [diff] [blame] | 6 | MultiCloud VMware OpenStack Simulated API User Case |
Ethan Lynn | 66b38de | 2018-11-07 11:31:10 +0800 | [diff] [blame] | 7 | --------------------------------------------------- |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 8 | |
Ethan Lynn | c918a20 | 2018-11-05 14:41:16 +0800 | [diff] [blame] | 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. |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 12 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 13 | Make sure you environment have msb,aai service and multicloud-vmware config |
| 14 | file has the right msb_ip and |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 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 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 22 | Register vio information into AAI service with region name "vmware" and region |
| 23 | id "fake" |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 24 | |
| 25 | .. code-block:: console |
| 26 | |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 27 | $ 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] | 28 | -H "Content-Type:"application/json" -H "Authorization:Basic QUFJOkFBSQ==" \ |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 29 | https://aai_ip:aai_port/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/vmware/fake \ |
| 30 | -d "{ |
| 31 | "cloud-owner": "vmware", |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 32 | "cloud-region-id": "fake", |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 33 | "cloud-type": "vmware", |
| 34 | "cloud-region-version": "4.0", |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 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", |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 38 | "esr-system-info-list": { |
| 39 | "esr-system-info": [ |
| 40 | { |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 41 | "system-name": "vmware-fake-cloud", |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 42 | "type": "vim", |
| 43 | "service-url": "http://127.0.0.1:5000/v3", |
| 44 | "user-name": "admin", |
| 45 | "password": "vmware", |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 46 | "system-type": "VIM", |
| 47 | "ssl-insecure": true, |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 48 | "cloud-domain": "default", |
| 49 | "default-tenant": "admin", |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 50 | } |
| 51 | ] |
| 52 | } |
| 53 | }" |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 54 | |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 55 | the identity url reprent the fake cloud identity url. |
| 56 | |
| 57 | |
| 58 | |
| 59 | Test Examples |
Ethan Lynn | 42fbfdc | 2017-10-20 13:52:45 +0800 | [diff] [blame] | 60 | ~~~~~~~~~~~~~ |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 61 | |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 62 | 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] | 63 | the ${msb_address} = "MSB_IP:MSB_PORT" |
| 64 | |
| 65 | Get auth token |
| 66 | -------------- |
| 67 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 68 | # send request to multicloud-framework(broker) service to get token of keystone |
| 69 | 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 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 79 | { |
liangke | abfed00 | 2017-10-23 16:24:37 +0800 | [diff] [blame] | 80 | "auth": { |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +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 | } |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 86 | } |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 87 | } |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 88 | |
| 89 | |
| 90 | Response: |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 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”. |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 95 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 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} |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 100 | |
| 101 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 102 | Identity endpoint:: |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 103 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 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> |
liangke | 01ef914 | 2017-10-12 18:09:15 +0800 | [diff] [blame] | 109 | |
| 110 | |
| 111 | List projects |
| 112 | ------------- |
| 113 | |
Ethan Lynn | b3e79cc | 2018-06-05 17:26:55 +0800 | [diff] [blame] | 114 | 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] | 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 | |
liangke | 147839b | 2017-10-23 15:07:39 +0800 | [diff] [blame] | 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\" > /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\" > /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 | |