zoukankan      html  css  js  c++  java
  • Restful创建虚拟机

    1.获取镜像列表
    GET:http://172.16.4.31:9292/v2/images
    或者http://172.16.4.31:8774/v2/57c0e01005c04f02a1b30253760cd323/images
    x-auth-token: a2424bc948814415b0bd0ecf9a64bce2
    response:
    {
    "images":  
    [
    4]
    0:  
    {
    "id": "a4dc3d76-219c-4396-829c-62ae265b7ceb"
    "links":  
    [
    3]
    2:  
    {
    "type": "application/vnd.openstack.image"
    "rel": "alternate"
    }
    -
    -
    "name": "Win2003"
    }
    -
    1:  
    {
    "id": "347ba80d-b9c4-46a8-8f59-c9f9de5f8c9b"
    "links":  
    [
    3]
    2:  
    {
    "type": "application/vnd.openstack.image"
    "rel": "alternate"
    }
    -
    -
    "name": "Centos6-hava-again"
    }
    -
    2:  
    {
    "id": "56a6597b-365b-42b3-8e5c-072aab0fe35a"
    "links":  
    [
    3]
    2:  
    {
    "type": "application/vnd.openstack.image"
    "rel": "alternate"
    }
    -
    -
    "name": "Centos6.2"
    }
    -
    3:  
    {
    "id": "329f4408-d760-4b21-86b6-86d3874106f9"
    "links":  
    [
    3]
    2:  
    {
    "type": "application/vnd.openstack.image"
    "rel": "alternate"
    }
    -
    -
    "name": "cirros-0.3.4-x86_64"
    }
    -
    -
    }
    这里我们选择一个cirros-0.3.4-x86_64  id:"329f4408-d760-4b21-86b6-86d3874106f9"
     
    2.需要获取flavors列表
     
    /v2/{tenant_id}/flavors
    GET:http://172.16.4.31:8774/v2/57c0e01005c04f02a1b30253760cd323/flavors
        HEADers: X-Auth-Token:bdb5c733eb1949f7ad0b3318428575e2
    Response:
    {
    "flavors":  
    [
    5]
    0:  
    {
    "id": "1"
    "links":  
    [
    2]
    -
    "name": "m1.tiny"
    }
    -
    1:  
    {
    "id": "3"
    "links":  
    [
    2]
    -
    "name": "m1.medium"
    }
    -
    2:  
    {
    "id": "3961a399-a02d-4c43-879d-d3367675c5f2"
    "name": "m1.small"
    }
    -
    3:  
    {
    "id": "4"
    "links":  
    [
    2]
    -
    "name": "m1.large"
    }
    -
    4:  
    {
    "id": "5"
    "links":  
    [
    2]
    -
    "name": "m1.xlarge"
    }
    -
    -
    }
     
    3.获取network list:
    GET:http://172.16.4.31:9696/v2.0/networks
    HEADers: X-Auth-Token: bdb5c733eb1949f7ad0b3318428575e2
    Response:
    {
    "networks":  
    [
    2]
    0:  
    {
    "status": "ACTIVE"
    "subnets":  
    [
    1]
    0:  "e8ae01dd-2ef4-4e69-b7ca-1556b1948b4c"
    -
    "name": "ext-net"
    "provider:physical_network": "external"
    "router:external": true
    "tenant_id": "57c0e01005c04f02a1b30253760cd323"
    "admin_state_up": true
    "mtu": 0
    "shared": false
    "provider:network_type": "flat"
    "id": "5e580216-9d86-495d-b092-77efe0e5de1b"
    "provider:segmentation_id": null
    }
    -
    1:  
    {
    "status": "ACTIVE"
    "subnets":  
    [
    1]
    0:  "80e8cd51-a45d-4748-bb8f-27bd8c71ac46"
    -
    "name": "admin-net"
    "provider:physical_network": null
    "router:external": false
    "tenant_id": "57c0e01005c04f02a1b30253760cd323"
    "admin_state_up": true
    "mtu": 0
    "shared": false
    "provider:network_type": "gre"
    "id": "9883a145-6a94-4ac7-9dff-1398fdefde73"
    "provider:segmentation_id": 76
    }
    -
    -
    }
    获取subnet
    GET: http://172.16.4.31:9696/v2.0/subnets
    HEADers:X-Auth-Token: e3f57e21576a40389eec9d0e74bcdea7
    Response:
    {
    "subnets":  
    [
    2]
    0:  
    {
    "name": "ext-subnet"
    "enable_dhcp": false
    "network_id": "5e580216-9d86-495d-b092-77efe0e5de1b"
    "tenant_id": "57c0e01005c04f02a1b30253760cd323"
    "dns_nameservers":  
    [
    0]
    "gateway_ip": "172.16.4.1"
    "ipv6_ra_mode": null
    "allocation_pools":  
    [
    1]
    0:  
    {
    "start": "172.16.4.150"
    "end": "172.16.4.200"
    }
    -
    -
    "host_routes":  
    [
    0]
    "ip_version": 4
    "ipv6_address_mode": null
    "cidr": "172.16.4.0/24"
    "id": "e8ae01dd-2ef4-4e69-b7ca-1556b1948b4c"
    "subnetpool_id": null
    }
    -
    1:  
    {
    "name": "admin-subnet"
    "enable_dhcp": true
    "network_id": "9883a145-6a94-4ac7-9dff-1398fdefde73"
    "tenant_id": "57c0e01005c04f02a1b30253760cd323"
    "dns_nameservers":  
    [
    0]
    "gateway_ip": "192.168.11.1"
    "ipv6_ra_mode": null
    "allocation_pools":  
    [
    1]
    0:  
    {
    "start": "192.168.11.2"
    "end": "192.168.11.254"
    }
    -
    -
    "host_routes":  
    [
    0]
    "ip_version": 4
    "ipv6_address_mode": null
    "cidr": "192.168.11.0/24"
    "id": "80e8cd51-a45d-4748-bb8f-27bd8c71ac46"
    "subnetpool_id": null
    }
    -
    -
    }
     
    4.创建虚拟机:
    nova boot --flavor m1.tiny --image XXXX --nic net-id=***** --security-group default --key-name admin-key zq_test_server
     
    curl -g -i -X POST http://controller5:8774/v2/57c0e01005c04f02a1b30253760cd323/servers -H "User-Agent: python-novaclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}13a022adc95c14756b67459b3a6b503a0152a81d" -d '{"server": {"name": "demo-instance1", "imageRef": "56a6597b-365b-42b3-8e5c-072aab0fe35a", "key_name": "admin-key", "flavorRef": "3", "max_count": 1, "min_count": 1, "networks": [{"uuid": "5e580216-9d86-495d-b092-77efe0e5de1b"}], "security_groups": [{"name": "default"}]}}'
     
    POST:http://172.16.4.31:8774/v2/57c0e01005c04f02a1b30253760cd323/servers
    HEADers:X-Auth-token: a2424bc948814415b0bd0ecf9a64bce2
     
    BODY:
    {
         "server" : {
              "name" : "zq-test-server",
              "imageRef" : "329f4408-d760-4b21-86b6-86d3874106f9",
              "flavorRef" : "3",
              "key_name" : "admin-key",
              "networks" :  [{"uuid": "9883a145-6a94-4ac7-9dff-1398fdefde73"}],
              "security_groups" : [{"name" : "default"}]
         }
    }
     
    Reponse:
    {
    "server": 
    {
    "security_groups": 
    [
    1]
    0:  
    {
    "name": "default"
    }
    -
    -
    "OS-DCF:diskConfig": "MANUAL"
    "id": "a8a255ae-5067-41df-a4ab-310431263695"
    "adminPass": "RvScjQFQ5qH6"
    }
    -
    }
    5.删除虚拟机
    DELETE:http://172.16.4.31:8774/v2/57c0e01005c04f02a1b30253760cd323/servers/2d6d8312-e4d1-48fa-ad81-580d83858e3b
    HEADers:X-Auth-Token:bdb5c733eb1949f7ad0b3318428575e2
    其中DELETE中最后的字段为server_id,需要GEThttp://172.16.4.31:8774/v2/57c0e01005c04f02a1b30253760cd323/servers + HEADers获得server_id"3bd14814-bf87-4e11-ae32-7b71a2ad3b6f"
    Response: no data.
     
    6.获取云硬盘参数列表
    //当然也可以使用http://172.16.4.31:8776/v2/tenant-id/volumes 可是只有id&name
    HEADers:  X-Auth-Token: c303c543ab9647e68478149633b38683
    Response:
    {
    "volumes":  
    [
    6]
    0:  
    {
    "attachments":  
    [
    0]
    "availability_zone": "nova"
    "os-vol-host-attr:host": "block-storage@lvm#LVM"
    "encrypted": false
    "os-volume-replication:extended_status": null
    "replication_status": "disabled"
    "snapshot_id": null
    "id": "94a89b53-703f-4ea5-b2e3-0219bc7878bd"
    "size": 1
    "user_id": "e4ca38ebf28c4cf6a0f6f8ae32233726"
    "os-vol-tenant-attr:tenant_id": "57c0e01005c04f02a1b30253760cd323"
    "os-vol-mig-status-attr:migstat": null
    "metadata":  
    {
    "readonly": "False"
    }
    -
    "status": "available"
    "description": null
    "multiattach": false
    "os-volume-replication:driver_data": null
    "source_volid": null
    "consistencygroup_id": null
    "os-vol-mig-status-attr:name_id": null
    "name": "zq-test-vol"
    "bootable": "false"
    "created_at": "2015-12-09T09:42:40.000000"
    "volume_type": null
    }
    -
    1:  
    {
    "attachments":  
    [
    1]
    0:  
    {
    "server_id": "abe90207-04b4-47e3-bb8e-504e01ae5790"
    "attachment_id": "2ae9bd53-9e0f-4a72-9bb1-6ee2b8a93988"
    "host_name": null
    "volume_id": "b5a2053d-77b2-4c91-ba50-3ca331551c1b"
    "device": "/dev/vda"
    "id": "b5a2053d-77b2-4c91-ba50-3ca331551c1b"
    }
    -
    -
    "availability_zone": "nova"
    "os-vol-host-attr:host": "block-storage@lvm#LVM"
    "encrypted": false
    "os-volume-replication:extended_status": null
    "replication_status": "disabled"
    "snapshot_id": null
    "id": "b5a2053d-77b2-4c91-ba50-3ca331551c1b"
    "size": 1
    "user_id": "e4ca38ebf28c4cf6a0f6f8ae32233726"
    "os-vol-tenant-attr:tenant_id": "57c0e01005c04f02a1b30253760cd323"
    "os-vol-mig-status-attr:migstat": null
    "metadata":  
    {
    "readonly": "False"
    "attached_mode": "rw"
    }
    -
    "status": "in-use"
    "volume_image_metadata":  
    {
    "container_format": "bare"
    "min_ram": "0"
    "disk_format": "qcow2"
    "image_name": "cirros-0.3.4-x86_64"
    "image_id": "329f4408-d760-4b21-86b6-86d3874106f9"
    "checksum": "ee1eca47dc88f4879d8a229cc70a07c6"
    "min_disk": "0"
    "watchdog": "reset"
    "size": "13287936"
    }
    -
    "description": null
    "multiattach": false
    "os-volume-replication:driver_data": null
    "source_volid": null
    "consistencygroup_id": null
    "os-vol-mig-status-attr:name_id": null
    "name": "boot-volume-vda"
    "bootable": "true"
    "created_at": "2015-12-05T07:45:14.000000"
    "volume_type": null
    }
    -
    2:  
    {
    "attachments":  
    [
    1]
    0:  
    {
    "server_id": "54b7feef-57f6-4cab-9a4f-57c7c3efbc05"
    "attachment_id": "cd5dea74-1cd8-49e4-bcc1-15fec4096a97"
    "host_name": null
    "volume_id": "2a6e58fc-33a6-4ac2-909a-397b2ec76dd0"
    "device": "/dev/vda"
    "id": "2a6e58fc-33a6-4ac2-909a-397b2ec76dd0"
    }
    -
    -
    "availability_zone": "nova"
    "os-vol-host-attr:host": "block-storage@lvm#LVM"
    "encrypted": false
    "os-volume-replication:extended_status": null
    "replication_status": "disabled"
    "snapshot_id": null
    "id": "2a6e58fc-33a6-4ac2-909a-397b2ec76dd0"
    "size": 1
    "user_id": "e4ca38ebf28c4cf6a0f6f8ae32233726"
    "os-vol-tenant-attr:tenant_id": "57c0e01005c04f02a1b30253760cd323"
    "os-vol-mig-status-attr:migstat": null
    "metadata":  
    {
    "readonly": "False"
    "attached_mode": "rw"
    }
    -
    "status": "in-use"
    "volume_image_metadata":  
    {
    "container_format": "bare"
    "min_ram": "0"
    "disk_format": "qcow2"
    "image_name": "cirros-0.3.4-x86_64"
    "image_id": "329f4408-d760-4b21-86b6-86d3874106f9"
    "checksum": "ee1eca47dc88f4879d8a229cc70a07c6"
    "min_disk": "0"
    "watchdog": "reset"
    "size": "13287936"
    }
    -
    "description": "volume for VM"
    "multiattach": false
    "os-volume-replication:driver_data": null
    "source_volid": null
    "consistencygroup_id": null
    "os-vol-mig-status-attr:name_id": null
    "name": "cirros-0.3.4-x86_64"
    "bootable": "true"
    "created_at": "2015-11-26T09:11:41.000000"
    "volume_type": "Tutorial"
    }
    -
    3:  
    {
    "attachments":  
    [
    0]
    "availability_zone": "nova"
    "os-vol-host-attr:host": "block-storage@lvm#LVM"
    "encrypted": false
    "os-volume-replication:extended_status": null
    "replication_status": "disabled"
    "snapshot_id": null
    "id": "2a7a10ee-1fa1-4f6b-8d8c-dc1ca11a753a"
    "size": 20
    "user_id": "e4ca38ebf28c4cf6a0f6f8ae32233726"
    "os-vol-tenant-attr:tenant_id": "57c0e01005c04f02a1b30253760cd323"
    "os-vol-mig-status-attr:migstat": null
    "metadata":  
    {
    }
    "status": "available"
    "volume_image_metadata":  
    {
    "instance_uuid": "39afa59b-21a1-4232-8faf-5a28962cd211"
    "image_location": "snapshot"
    "image_state": "available"
    "user_id": "e4ca38ebf28c4cf6a0f6f8ae32233726"
    "image_type": "snapshot"
    "container_format": "bare"
    "min_ram": "0"
    "disk_format": "qcow2"
    "image_name": "Centos6-hava-again"
    "image_id": "347ba80d-b9c4-46a8-8f59-c9f9de5f8c9b"
    "checksum": "8c52d62bdab222924185884caf9ca7eb"
    "min_disk": "20"
    "size": "2931490816"
    "base_image_ref": "56a6597b-365b-42b3-8e5c-072aab0fe35a"
    "owner_id": "57c0e01005c04f02a1b30253760cd323"
    }
    -
    "description": null
    "multiattach": false
    "os-volume-replication:driver_data": null
    "source_volid": null
    "consistencygroup_id": null
    "os-vol-mig-status-attr:name_id": null
    "name": "Centos6-hava-again"
    "bootable": "true"
    "created_at": "2015-11-25T08:27:16.000000"
    "volume_type": null
    }
    -
    4:  
    {
    "attachments":  
    [
    1]
    0:  
    {
    "server_id": "78acff86-a9b0-4c10-b34b-dbec59676e28"
    "attachment_id": "733efa3f-9e51-4080-ae73-ba858a72994e"
    "host_name": null
    "volume_id": "067414fd-6b86-498a-a4df-970a68900dbf"
    "device": "/dev/vdb"
    "id": "067414fd-6b86-498a-a4df-970a68900dbf"
    }
    -
    -
    "availability_zone": "nova"
    "os-vol-host-attr:host": "block-storage@lvm#LVM"
    "encrypted": false
    "os-volume-replication:extended_status": null
    "replication_status": "disabled"
    "snapshot_id": null
    "id": "067414fd-6b86-498a-a4df-970a68900dbf"
    "size": 100
    "user_id": "e4ca38ebf28c4cf6a0f6f8ae32233726"
    "os-vol-tenant-attr:tenant_id": "57c0e01005c04f02a1b30253760cd323"
    "os-vol-mig-status-attr:migstat": null
    "metadata":  
    {
    "readonly": "False"
    "attached_mode": "rw"
    }
    -
    "status": "in-use"
    "description": null
    "multiattach": false
    "os-volume-replication:driver_data": null
    "source_volid": null
    "consistencygroup_id": null
    "os-vol-mig-status-attr:name_id": null
    "name": "CDP_Volume"
    "bootable": "false"
    "created_at": "2015-11-24T05:03:48.000000"
    "volume_type": null
    }
    -
    5:  
    {
    "attachments":  
    [
    0]
    "availability_zone": "nova"
    "os-vol-host-attr:host": "block-storage@lvm#LVM"
    "encrypted": false
    "os-volume-replication:extended_status": null
    "replication_status": "disabled"
    "snapshot_id": null
    "id": "2e7c512c-3f43-435b-aaf0-c420ba9802fc"
    "size": 1
    "user_id": "e4ca38ebf28c4cf6a0f6f8ae32233726"
    "os-vol-tenant-attr:tenant_id": "57c0e01005c04f02a1b30253760cd323"
    "os-vol-mig-status-attr:migstat": null
    "metadata":  
    {
    "readonly": "False"
    }
    -
    "status": "available"
    "description": null
    "multiattach": false
    "os-volume-replication:driver_data": null
    "source_volid": null
    "consistencygroup_id": null
    "os-vol-mig-status-attr:name_id": null
    "name": "t5"
    "bootable": "false"
    "created_at": "2015-11-24T05:03:08.000000"
    "volume_type": null
    }
    -
    -
    }
     
    7.创建云硬盘
    POST: http://172.16.4.31:8776/v2/57c0e01005c04f02a1b30253760cd323/volumes
    HEADers: X-Auth-Token:213459408f2e444fb5802a45d79c229d
    BODY:
    {
         "volume": {
              "status": "creating",
              "description": null,
              "availability_zone": null,
              "source_volid": null,
              "consistencygroup_id": null,
              "snapshot_id": null,
              "source_replica": null,
              "size": 1,
              "user_id": null,
              "name": "zq-test-vol",
              "imageRef": null,
              "attach_status": "detached",
              "volume_type": null,
              "project_id": null,
              "metadata": {}
         }
    }
    Response:
    {
    "volume":  
    {
    "status": "creating"
    "user_id": "e4ca38ebf28c4cf6a0f6f8ae32233726"
    "attachments":  
    [
    0]
    "availability_zone": "nova"
    "bootable": "false"
    "encrypted": false
    "created_at": "2015-12-10T02:08:04.443738"
    "description": null
    "volume_type": null
    "name": "zq-test-vol"
    "replication_status": "disabled"
    "consistencygroup_id": null
    "source_volid": null
    "snapshot_id": null
    "multiattach": false
    "metadata":  
    {
    }
    "id": "7738f6a9-c2cb-4e02-90ab-5bd02376d02a"
    "size": 1
    }
    -
    }
     
    8.将新建的云硬盘attach 到虚拟机上
    nova volume-attach zq_test_server ***********(volume-id) 
     
    curl -g -i -X POST http://controller5:8774/v2/57c0e01005c04f02a1b30253760cd323/servers/3bd14814-bf87-4e11-ae32-7b71a2ad3b6f(server-id)/os-volume_attachments -H "User-Agent: python-novaclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}8117d5f290eeaab753c05c467e810f56dd54ce12" -d '{"volumeAttachment": {"device": null, "volumeId": "94a89b53-703f-4ea5-b2e3-0219bc7878bd"}}'
    DEBUG (connectionpool:383) "POST /v2/57c0e01005c04f02a1b30253760cd323/servers/3bd14814-bf87-4e11-ae32-7b71a2ad3b6f/os-volume_attachments HTTP/1.1" 200 194
    DEBUG (session:224) RESP: [200] date: Wed, 09 Dec 2015 09:49:39 GMT connection: keep-alive content-type: application/json content-length: 194 x-compute-request-id: req-893e3d07-d0ce-4dbd-a784-61a7d941879a
    RESP BODY:
    {"volumeAttachment": {"device": "/dev/vdb", "serverId": "3bd14814-bf87-4e11-ae32-7b71a2ad3b6f", "id": "94a89b53-703f-4ea5-b2e3-0219bc7878bd", "volumeId": "94a89b53-703f-4ea5-b2e3-0219bc7878bd"}}
     
    POST: http://172.16.4.31:8774/v2/57c0e01005c04f02a1b30253760cd323/servers/3bd14814-bf87-4e11-ae32-7b71a2ad3b6f(server-id)/os-volume_attachments
    BODY:
    {
         "volumeAttachment":
               {
                   "device": null,
                   "volumeId": "7738f6a9-c2cb-4e02-90ab-5bd02376d02a"
                }
    }
    Response:
    {
    "volumeAttachment": 
    {
    "device": "/dev/vdb"
    "serverId": "a8a255ae-5067-41df-a4ab-310431263695"
    "id": "7738f6a9-c2cb-4e02-90ab-5bd02376d02a"
    "volumeId": "7738f6a9-c2cb-4e02-90ab-5bd02376d02a"
    }
    -
    }
     
    9.detach volume
    curl -g -i -X DELETE http://controller5:8774/v2/57c0e01005c04f02a1b30253760cd323/servers/3bd14814-bf87-4e11-ae32-7b71a2ad3b6f/os-volume_attachments/94a89b53-703f-4ea5-b2e3-0219bc7878bd(volume-id) -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}3fc6e7762ee1c0c457fa694a7c430498edeb376e"
     
    1.http://172.16.4.31:8774/v2/57c0e01005c04f02a1b30253760cd323/servers?name=zq_test_server
    查询 server-id
     
    2.http://172.16.4.31:8774/v2/57c0e01005c04f02a1b30253760cd323/servers/3bd14814-bf87-4e11-ae32-7b71a2ad3b6f(server-id)
    查询 attachment_id
     
    3.DELETE:  http://controller5:8774/v2/57c0e01005c04f02a1b30253760cd323/servers/3bd14814-bf87-4e11-ae32-7b71a2ad3b6f/os-volume_attachments/94a89b53-703f-4ea5-b2e3-0219bc7878bd
    HEADer:X-Auth-Token: c303c543ab9647e68478149633b38683
    BODY:
    {
         "os-force_detach": {
              "attachment_id": "94a89b53-703f-4ea5-b2e3-0219bc7878bd"
         }
    }
    Response:  not contain any data.
     
    10.delete volume
    DELETE: http://172.16.4.31:8776/v2/57c0e01005c04f02a1b30253760cd323/volumes/{volume-id}
    HEADers:  X-Auth-Token: a2424bc948814415b0bd0ecf9a64bce2
    Reponse: no data.
     
     
     
     
    *********************** v2.0<ok> **************************
    下面使用v2.0好像可以获取token:
    1.
    POST  http://192.168.4.31:5000/v2.0/tokens
    {
          "auth": {
            "passwordCredentials": {
                "username": "admin",
                "password": "jcb410"
            }
        }
    }
    response:
    {
    "access":  
    {
    "token":  
    {
    "issued_at": "2015-12-08T01:17:51.749244"
    "expires": "2015-12-08T02:17:51Z"
    "id": "c28b38cce3b3492aa807b698cd3e9103"
    "audit_ids":  
    [
    1]
    0:  "7SZeb1BYT1W1gdt5_1lYJA"
    -
    }
    -
    "serviceCatalog":  
    [
    0]
    "user":  
    {
    "username": "admin"
    "roles_links":  
    [
    0]
    "id": "e4ca38ebf28c4cf6a0f6f8ae32233726"
    "roles":  
    [
    0]
    "name": "admin"
    }
    -
    "metadata":  
    {
    "is_admin": 0
    "roles":  
    [
    0]
    }
    -
    }
    -
    }
    2.
    这样得到了临时的 no-socped token, 接着访问租户,将临时token 作为X-Auth-Token的值:
    GET:
    http://172.16.4.31:5000/v2.0/tenants HEADERS["X-Auth-Token":"e4ca38ebf28c4cf6a0f6f8ae32233726"]
    response:
    {
    "tenants_links":  
    [
    0]
    "tenants":  
    [
    1]
    0:  
    {
    "description": "Admin Project"
    "enabled": true
    "id": "57c0e01005c04f02a1b30253760cd323"
    "name": "admin"
    }
    -
    -
    }
    3.上一步中我们获取的用户所能访问到租户,接着用户需要从中选择一个租户,作为自己的工作空间, 用户在某一租户中才能访问其他非keystone服务,也只能使用指定租户的Token才能访问其他非keystone服务。 获取指定租户的Token,所使用的REST API与步骤1相同,仅有的区别:在body体中要指定租户。
    POST:http://172.16.4.31:5000/v2.0/tokens
     
    {
       "auth":{
          "tenantName":"admin",
          "passwordCredentials":{
             "username":"admin",
             "password":"jcb410"
          }
       }
    }
    response:
    {
    "access":  
    {
    "token":  
    {
    "issued_at": "2015-12-08T03:26:12.327560"
    "expires": "2015-12-08T04:26:12Z9292"
    "id": "a2424bc948814415b0bd0ecf9a64bce2"
    "tenant":  
    {
    "description": "Admin Project"
    "enabled": true
    "id": "57c0e01005c04f02a1b30253760cd323"
    "name": "admin"
    }
    -
    "audit_ids":  
    [
    1]
    0:  "D0ghgHPqT7625UvcAwbpbw"
    -
    }
    -
    "serviceCatalog":  
    [
    9]
    0:  
    {
    "endpoints":  
    [
    1]
    0:  
    {
    "region": "RegionOne"
    "id": "7673b95f4b9f4bd9a8ea91e50b5db75b"
    }
    -
    -
    "endpoints_links":  
    [
    0]
    "type": "compute"
    "name": "nova"
    }
    -
    1:  
    {
    "endpoints":  
    [
    1]
    0:  
    {
    "region": "RegionOne"
    "internalURL": "http://controller5:9696"
    "id": "4f15ed275d98474197c97febcaf83c0d"
    "publicURL": "http://controller5:9696"
    }
    -
    -
    "endpoints_links":  
    [
    0]
    "type": "network"
    "name": "neutron"
    }
    -
    2:  
    {
    "endpoints":  
    [
    1]
    0:  
    {
    "region": "RegionOne"
    "id": "09b0ddfdce8642c6a7c6d763bd0830d6"
    }
    -
    -
    "endpoints_links":  
    [
    0]
    "type": "volumev2"
    "name": "cinderv2"
    }
    -
    3:  
    {
    "endpoints":  
    [
    1]
    0:  
    {
    "region": "RegionOne"
    "internalURL": "http://controller5:9292"
    "id": "0c3e0c8054d949609fe6a7db0f1f7498"
    "publicURL": "http://controller5:9292"
    }
    -
    -
    "endpoints_links":  
    [
    0]
    "type": "image"
    "name": "glance"
    }
    -
    4:  
    {
    "endpoints":  
    [
    1]
    0:  
    {
    "region": "RegionOne"
    "internalURL": "http://controller5:8777"
    "id": "059bd89aa25741e78e6d609816995bbd"
    "publicURL": "http://controller5:8777"
    }
    -
    -
    "endpoints_links":  
    [
    0]
    "type": "metering"
    "name": "ceilometer"
    }
    -
    5:  
    {
    "endpoints":  
    [
    1]
    0:  
    {
    "region": "RegionOne"
    "internalURL": "http://controller5:8000/v1"
    "id": "86aa3c6be86c4e14beb6c110ff97e204"
    }
    -
    -
    "endpoints_links":  
    [
    0]
    "type": "cloudformation"
    "name": "heat-cfn"
    }
    -
    6:  
    {
    "endpoints":  
    [
    1]
    0:  
    {
    "region": "RegionOne"
    "id": "32f9a6185aa44b22ab6e8dd514acf9d4"
    }
    -
    -
    "endpoints_links":  
    [
    0]
    "type": "volume"
    "name": "cinder"
    }
    -
    7:  
    {
    "endpoints":  
    [
    1]
    0:  
    {
    "region": "RegionOne"
    "id": "2a2362ee45ba403b9423e2df65e16d7f"
    }
    -
    -
    "endpoints_links":  
    [
    0]
    "type": "orchestration"
    "name": "heat"
    }
    -
    8:  
    {
    "endpoints":  
    [
    1]
    0:  
    {
    "region": "RegionOne"
    "id": "4e94151beecd4d5793496774a3ec3f70"
    }
    -
    -
    "endpoints_links":  
    [
    0]
    "type": "identity"
    "name": "keystone"
    }
    -
    -
    "user":  
    {
    "username": "admin"
    "roles_links":  
    [
    0]
    "id": "e4ca38ebf28c4cf6a0f6f8ae32233726"
    "roles":  
    [
    2]
    0:  
    {
    "name": "heat_stack_owner"
    }
    -
    1:  
    {
    "name": "admin"
    }
    -
    -
    "name": "admin"
    }
    -
    "metadata":  
    {
    "is_admin": 0
    "roles":  
    [
    2]
    0:  "2e11f3e0aef14156939cece1c9e33e2c"
    1:  "2870cfab9f65494e963f768f147bb39a"
    -
    }
    -
    }
    -
    }
     
  • 相关阅读:
    jQuery.getJSON的缓存问题的解决办法
    MFC Tab Control控件的详细使用
    JavaScript 闭包深入理解(closure)
    STL中sort函数用法简介
    STL中qsort的七种用法
    学习Javascript闭包(Closure)
    使用 Visual Studio 分析器找出应用程序瓶颈
    各种语言性能测试工具一览表
    Javascript 链式作用域
    MessageBox、::MessageBox 、AfxMessageBox三者的区别 .
  • 原文地址:https://www.cnblogs.com/wizzhangquan/p/5037080.html
Copyright © 2011-2022 走看看