Add an extension to show the mac address of a ip in server(s)
This extension adds the OS-EXT-IPS-MAC:mac_addr param so that users can associate the mac address to the ip of the server in one API call. Implement bp: os-ext-ips-mac-api-extension DocImpact Change-Id: I01d0b3aa804b5218853a4bb568c85e31b87d04e4 Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
This commit is contained in:
parent
4861a3b6a5
commit
262b285a04
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"server": {
|
||||
"accessIPv4": "",
|
||||
"accessIPv6": "",
|
||||
"addresses": {
|
||||
"private": [
|
||||
{
|
||||
"addr": "192.168.0.3",
|
||||
"version": 4,
|
||||
"OS-EXT-IPS-MAC:mac_addr": "00:0c:29:e1:42:90"
|
||||
}
|
||||
]
|
||||
},
|
||||
"created": "2013-02-07T18:46:28Z",
|
||||
"flavor": {
|
||||
"id": "1",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/openstack/flavors/1",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
]
|
||||
},
|
||||
"hostId": "4e2003eddbfdb1280c2618d04090bcdd6773203b8da8347af0b2723d",
|
||||
"id": "dc7281f9-ee47-40b9-9950-9f73e7961caa",
|
||||
"image": {
|
||||
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
]
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/v2/openstack/servers/dc7281f9-ee47-40b9-9950-9f73e7961caa",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "http://openstack.example.com/openstack/servers/dc7281f9-ee47-40b9-9950-9f73e7961caa",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"My Server Name": "Apache1"
|
||||
},
|
||||
"name": "new-server-test",
|
||||
"progress": 0,
|
||||
"status": "ACTIVE",
|
||||
"tenant_id": "openstack",
|
||||
"updated": "2013-02-07T18:46:29Z",
|
||||
"user_id": "fake"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<server xmlns:OS-EXT-IPS-MAC="http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="2013-02-07T18:46:29Z" hostId="068cc5e2de14b6e533a239c6eac0a0bdedcd57cab25450a6d3da43af" name="new-server-test" created="2013-02-07T18:46:28Z" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="22e7cf4d-ab7a-4a3d-9599-7d0dbaf9ed55">
|
||||
<image id="70a599e0-31e7-49b7-b260-868f441e862b">
|
||||
<atom:link href="http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b" rel="bookmark"/>
|
||||
</image>
|
||||
<flavor id="1">
|
||||
<atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/>
|
||||
</flavor>
|
||||
<metadata>
|
||||
<meta key="My Server Name">Apache1</meta>
|
||||
</metadata>
|
||||
<addresses>
|
||||
<network id="private">
|
||||
<ip version="4" addr="192.168.0.3" OS-EXT-IPS-MAC:mac_addr="00:0c:29:e1:42:90"/>
|
||||
</network>
|
||||
</addresses>
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/servers/22e7cf4d-ab7a-4a3d-9599-7d0dbaf9ed55" rel="self"/>
|
||||
<atom:link href="http://openstack.example.com/openstack/servers/22e7cf4d-ab7a-4a3d-9599-7d0dbaf9ed55" rel="bookmark"/>
|
||||
</server>
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"server" : {
|
||||
"name" : "new-server-test",
|
||||
"imageRef" : "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
|
||||
"flavorRef" : "http://openstack.example.com/openstack/flavors/1",
|
||||
"metadata" : {
|
||||
"My Server Name" : "Apache1"
|
||||
},
|
||||
"personality" : [
|
||||
{
|
||||
"path" : "/etc/banner.txt",
|
||||
"contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<server xmlns="http://docs.openstack.org/compute/api/v1.1" imageRef="http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b" flavorRef="http://openstack.example.com/openstack/flavors/1" name="new-server-test">
|
||||
<metadata>
|
||||
<meta key="My Server Name">Apache1</meta>
|
||||
</metadata>
|
||||
<personality>
|
||||
<file path="/etc/banner.txt">
|
||||
ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
|
||||
dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k
|
||||
IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs
|
||||
c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g
|
||||
QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo
|
||||
ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv
|
||||
dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy
|
||||
c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6
|
||||
b25zLiINCg0KLVJpY2hhcmQgQmFjaA==
|
||||
</file>
|
||||
</personality>
|
||||
</server>
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"server": {
|
||||
"adminPass": "zD7wDKTXiHsp",
|
||||
"id": "b44e5008-42f7-4048-b4c8-f40a29da88ba",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/v2/openstack/servers/b44e5008-42f7-4048-b4c8-f40a29da88ba",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "http://openstack.example.com/openstack/servers/b44e5008-42f7-4048-b4c8-f40a29da88ba",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" id="752dd57d-933b-4a57-a0ae-4c3431c5abc7" adminPass="B2gvFFjBQCVQ">
|
||||
<metadata/>
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/servers/752dd57d-933b-4a57-a0ae-4c3431c5abc7" rel="self"/>
|
||||
<atom:link href="http://openstack.example.com/openstack/servers/752dd57d-933b-4a57-a0ae-4c3431c5abc7" rel="bookmark"/>
|
||||
</server>
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"servers": [
|
||||
{
|
||||
"accessIPv4": "",
|
||||
"accessIPv6": "",
|
||||
"addresses": {
|
||||
"private": [
|
||||
{
|
||||
"addr": "192.168.0.3",
|
||||
"version": 4,
|
||||
"OS-EXT-IPS-MAC:mac_addr": "00:0c:29:e1:42:90"
|
||||
}
|
||||
]
|
||||
},
|
||||
"created": "2013-02-07T18:40:59Z",
|
||||
"flavor": {
|
||||
"id": "1",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/openstack/flavors/1",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
]
|
||||
},
|
||||
"hostId": "fe866a4962fe3bdb6c2db9c8f7dcdb9555aca73387e72b5cb9c45bd3",
|
||||
"id": "76908712-653a-4d16-807e-d89d41435d24",
|
||||
"image": {
|
||||
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
]
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/v2/openstack/servers/76908712-653a-4d16-807e-d89d41435d24",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "http://openstack.example.com/openstack/servers/76908712-653a-4d16-807e-d89d41435d24",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"My Server Name": "Apache1"
|
||||
},
|
||||
"name": "new-server-test",
|
||||
"progress": 0,
|
||||
"status": "ACTIVE",
|
||||
"tenant_id": "openstack",
|
||||
"updated": "2013-02-07T18:40:59Z",
|
||||
"user_id": "fake"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<servers xmlns:OS-EXT-IPS-MAC="http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||
<server status="ACTIVE" updated="2013-02-07T18:40:59Z" hostId="51a80e6ee89b638b2cb57eb4e39d89a725e07c8a698f4d8e256f8665" name="new-server-test" created="2013-02-07T18:40:59Z" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="0337de6b-1d43-46c8-8804-35669f1dea9a">
|
||||
<image id="70a599e0-31e7-49b7-b260-868f441e862b">
|
||||
<atom:link href="http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b" rel="bookmark"/>
|
||||
</image>
|
||||
<flavor id="1">
|
||||
<atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/>
|
||||
</flavor>
|
||||
<metadata>
|
||||
<meta key="My Server Name">Apache1</meta>
|
||||
</metadata>
|
||||
<addresses>
|
||||
<network id="private">
|
||||
<ip version="4" addr="192.168.0.3" OS-EXT-IPS-MAC:mac_addr="00:0c:29:e1:42:90"/>
|
||||
</network>
|
||||
</addresses>
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/servers/0337de6b-1d43-46c8-8804-35669f1dea9a" rel="self"/>
|
||||
<atom:link href="http://openstack.example.com/openstack/servers/0337de6b-1d43-46c8-8804-35669f1dea9a" rel="bookmark"/>
|
||||
</server>
|
||||
</servers>
|
|
@ -40,6 +40,14 @@
|
|||
"namespace": "http://docs.openstack.org/compute/ext/extended_ips/api/v1.1",
|
||||
"updated": "2013-01-06T00:00:00+00:00"
|
||||
},
|
||||
{
|
||||
"alias": "OS-EXT-IPS-MAC",
|
||||
"description": "Adds mac address parameter to the ip list.",
|
||||
"links": [],
|
||||
"name": "ExtendedIpsMac",
|
||||
"namespace": "http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1",
|
||||
"updated": "2013-03-07T00:00:00+00:00"
|
||||
},
|
||||
{
|
||||
"alias": "OS-EXT-SRV-ATTR",
|
||||
"description": "Extended Server Attributes support.",
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
<extension alias="OS-EXT-IPS" updated="2013-01-06T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/extended_ips/api/v1.1" name="ExtendedIps">
|
||||
<description>Adds type parameter to the ip list.</description>
|
||||
</extension>
|
||||
<extension alias="OS-EXT-IPS-MAC" updated="2013-03-07T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1" name="ExtendedIpsMac">
|
||||
<description>Adds mac address parameter to the ip list.</description>
|
||||
</extension>
|
||||
<extension alias="OS-EXT-SRV-ATTR" updated="2011-11-03T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" name="ExtendedServerAttributes">
|
||||
<description>Extended Server Attributes support.</description>
|
||||
</extension>
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
{
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"addr": "192.168.0.3",
|
||||
"version": 4
|
||||
"version": 4,
|
||||
"OS-EXT-IPS-MAC:mac_addr": "00:0c:29:e1:42:90"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<server xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-IPS="http://docs.openstack.org/compute/ext/extended_ips/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-AZ="http://docs.openstack.org/compute/ext/extended_availability_zone/api/v2" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="2013-02-07T19:01:59Z" hostId="06d1cfd52be5f5d197193db2842978235fd085bd2dfaea32e5068468" name="new-server-test" created="2013-02-07T19:01:58Z" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="6be39927-53b2-4aee-8593-1c72b3673168" key_name="None" config_drive="" OS-EXT-SRV-ATTR:vm_state="active" OS-EXT-SRV-ATTR:task_state="None" OS-EXT-SRV-ATTR:power_state="1" OS-EXT-SRV-ATTR:instance_name="instance-00000001" OS-EXT-SRV-ATTR:host="b98603db318e495e819601702d16c512" OS-EXT-SRV-ATTR:hypervisor_hostname="fake-mini" OS-EXT-AZ:availability_zone="nova" OS-DCF:diskConfig="AUTO">
|
||||
<server xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-IPS="http://docs.openstack.org/compute/ext/extended_ips/api/v1.1" xmlns:OS-EXT-IPS-MAC="http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-AZ="http://docs.openstack.org/compute/ext/extended_availability_zone/api/v2" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="2013-02-07T19:01:59Z" hostId="06d1cfd52be5f5d197193db2842978235fd085bd2dfaea32e5068468" name="new-server-test" created="2013-02-07T19:01:58Z" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="6be39927-53b2-4aee-8593-1c72b3673168" key_name="None" config_drive="" OS-EXT-SRV-ATTR:vm_state="active" OS-EXT-SRV-ATTR:task_state="None" OS-EXT-SRV-ATTR:power_state="1" OS-EXT-SRV-ATTR:instance_name="instance-00000001" OS-EXT-SRV-ATTR:host="b98603db318e495e819601702d16c512" OS-EXT-SRV-ATTR:hypervisor_hostname="fake-mini" OS-EXT-AZ:availability_zone="nova" OS-DCF:diskConfig="AUTO">
|
||||
<image id="70a599e0-31e7-49b7-b260-868f441e862b">
|
||||
<atom:link href="http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b" rel="bookmark"/>
|
||||
</image>
|
||||
|
@ -11,7 +11,8 @@
|
|||
</metadata>
|
||||
<addresses>
|
||||
<network id="private">
|
||||
<ip OS-EXT-IPS:type="fixed" version="4" addr="192.168.0.3"/>
|
||||
<ip OS-EXT-IPS:type="fixed" version="4" addr="192.168.0.3"
|
||||
OS-EXT-IPS-MAC:mac_addr="00:0c:29:e1:42:90"/>
|
||||
</network>
|
||||
</addresses>
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/servers/6be39927-53b2-4aee-8593-1c72b3673168" rel="self"/>
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
{
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"addr": "192.168.0.3",
|
||||
"version": 4
|
||||
"version": 4,
|
||||
"OS-EXT-IPS-MAC:mac_addr": "00:0c:29:e1:42:90"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<servers xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-IPS="http://docs.openstack.org/compute/ext/extended_ips/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-AZ="http://docs.openstack.org/compute/ext/extended_availability_zone/api/v2" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||
<servers xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-IPS="http://docs.openstack.org/compute/ext/extended_ips/api/v1.1" xmlns:OS-EXT-IPS-MAC="http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-AZ="http://docs.openstack.org/compute/ext/extended_availability_zone/api/v2" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||
<server status="ACTIVE" updated="2013-02-07T19:01:59Z" hostId="641edaad8dd6a670afec58a4ce7e908d50379a6060f845236cd063db" name="new-server-test" created="2013-02-07T19:01:58Z" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="b45edf9d-30f6-41e8-a00b-ef8962376586" key_name="None" config_drive="" OS-EXT-SRV-ATTR:vm_state="active" OS-EXT-SRV-ATTR:task_state="None" OS-EXT-SRV-ATTR:power_state="1" OS-EXT-SRV-ATTR:instance_name="instance-00000001" OS-EXT-SRV-ATTR:host="f7954cfa4a5544278876b1d9224efe48" OS-EXT-SRV-ATTR:hypervisor_hostname="fake-mini" OS-EXT-AZ:availability_zone="nova" OS-DCF:diskConfig="AUTO">
|
||||
<image id="70a599e0-31e7-49b7-b260-868f441e862b">
|
||||
<atom:link href="http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b" rel="bookmark"/>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</metadata>
|
||||
<addresses>
|
||||
<network id="private">
|
||||
<ip OS-EXT-IPS:type="fixed" version="4" addr="192.168.0.3"/>
|
||||
<ip OS-EXT-IPS:type="fixed" version="4" addr="192.168.0.3" OS-EXT-IPS-MAC:mac_addr="00:0c:29:e1:42:90"/>
|
||||
</network>
|
||||
</addresses>
|
||||
<atom:link href="http://openstack.example.com/v2/openstack/servers/b45edf9d-30f6-41e8-a00b-ef8962376586" rel="self"/>
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
"compute_extension:extended_status": "",
|
||||
"compute_extension:extended_availability_zone": "",
|
||||
"compute_extension:extended_ips": "",
|
||||
"compute_extension:extended_ips_mac": "",
|
||||
"compute_extension:extended_vif_net": "",
|
||||
"compute_extension:fixed_ips": "rule:admin_api",
|
||||
"compute_extension:flavor_access": "",
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# under the License.
|
||||
|
||||
import functools
|
||||
import itertools
|
||||
import os
|
||||
import re
|
||||
import urlparse
|
||||
|
@ -320,6 +321,9 @@ def get_networks_for_instance_from_nw_info(nw_info):
|
|||
|
||||
networks[label]['ips'].extend(ips)
|
||||
networks[label]['floating_ips'].extend(floaters)
|
||||
for ip in itertools.chain(networks[label]['ips'],
|
||||
networks[label]['floating_ips']):
|
||||
ip['mac_address'] = vif['address']
|
||||
return networks
|
||||
|
||||
|
||||
|
@ -328,10 +332,18 @@ def get_networks_for_instance(context, instance):
|
|||
|
||||
We end up with a data structure like::
|
||||
|
||||
{'public': {'ips': [{'addr': '10.0.0.1', 'version': 4},
|
||||
{'addr': '2001::1', 'version': 6}],
|
||||
'floating_ips': [{'addr': '172.16.0.1', 'version': 4},
|
||||
{'addr': '172.16.2.1', 'version': 4}]},
|
||||
{'public': {'ips': [{'address': '10.0.0.1',
|
||||
'version': 4,
|
||||
'mac_address': 'aa:aa:aa:aa:aa:aa'},
|
||||
{'address': '2001::1',
|
||||
'version': 6,
|
||||
'mac_address': 'aa:aa:aa:aa:aa:aa'}],
|
||||
'floating_ips': [{'address': '172.16.0.1',
|
||||
'version': 4,
|
||||
'mac_address': 'aa:aa:aa:aa:aa:aa'},
|
||||
{'address': '172.16.2.1',
|
||||
'version': 4,
|
||||
'mac_address': 'aa:aa:aa:aa:aa:aa'}]},
|
||||
...}
|
||||
"""
|
||||
nw_info = compute_utils.get_nw_info_for_instance(instance)
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2013 IBM Corp.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""The Extended Ips API extension."""
|
||||
|
||||
import itertools
|
||||
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute import ips
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api.openstack import xmlutil
|
||||
from nova.openstack.common import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
authorize = extensions.soft_extension_authorizer('compute', 'extended_ips_mac')
|
||||
|
||||
|
||||
class ExtendedIpsMacController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ExtendedIpsMacController, self).__init__(*args, **kwargs)
|
||||
|
||||
def _extend_server(self, context, server, instance):
|
||||
key = "%s:mac_addr" % Extended_ips_mac.alias
|
||||
networks = common.get_networks_for_instance(context, instance)
|
||||
for label, network in networks.items():
|
||||
# NOTE(vish): ips are hidden in some states via the
|
||||
# hide_server_addresses extension.
|
||||
if label in server['addresses']:
|
||||
all_ips = itertools.chain(network["ips"],
|
||||
network["floating_ips"])
|
||||
for i, ip in enumerate(all_ips):
|
||||
server['addresses'][label][i][key] = ip['mac_address']
|
||||
|
||||
@wsgi.extends
|
||||
def show(self, req, resp_obj, id):
|
||||
context = req.environ['nova.context']
|
||||
if authorize(context):
|
||||
# Attach our slave template to the response object
|
||||
resp_obj.attach(xml=ExtendedIpsMacServerTemplate())
|
||||
server = resp_obj.obj['server']
|
||||
db_instance = req.get_db_instance(server['id'])
|
||||
# server['id'] is guaranteed to be in the cache due to
|
||||
# the core API adding it in its 'show' method.
|
||||
self._extend_server(context, server, db_instance)
|
||||
|
||||
@wsgi.extends
|
||||
def detail(self, req, resp_obj):
|
||||
context = req.environ['nova.context']
|
||||
if authorize(context):
|
||||
# Attach our slave template to the response object
|
||||
resp_obj.attach(xml=ExtendedIpsMacServersTemplate())
|
||||
servers = list(resp_obj.obj['servers'])
|
||||
for server in servers:
|
||||
db_instance = req.get_db_instance(server['id'])
|
||||
# server['id'] is guaranteed to be in the cache due to
|
||||
# the core API adding it in its 'detail' method.
|
||||
self._extend_server(context, server, db_instance)
|
||||
|
||||
|
||||
class Extended_ips_mac(extensions.ExtensionDescriptor):
|
||||
"""Adds mac address parameter to the ip list."""
|
||||
|
||||
name = "ExtendedIpsMac"
|
||||
alias = "OS-EXT-IPS-MAC"
|
||||
namespace = ("http://docs.openstack.org/compute/ext/"
|
||||
"extended_ips_mac/api/v1.1")
|
||||
updated = "2013-03-07T00:00:00+00:00"
|
||||
|
||||
def get_controller_extensions(self):
|
||||
controller = ExtendedIpsMacController()
|
||||
extension = extensions.ControllerExtension(self, 'servers', controller)
|
||||
return [extension]
|
||||
|
||||
|
||||
def make_server(elem):
|
||||
elem.append(ips.AddressesTemplate())
|
||||
ip = elem['addresses']['network']['ip']
|
||||
ip.set('{%s}mac_addr' % Extended_ips_mac.namespace,
|
||||
'%s:mac_addr' % Extended_ips_mac.alias)
|
||||
|
||||
|
||||
class ExtendedIpsMacServerTemplate(xmlutil.TemplateBuilder):
|
||||
def construct(self):
|
||||
root = xmlutil.TemplateElement('server', selector='server')
|
||||
make_server(root)
|
||||
return xmlutil.SlaveTemplate(root, 1, nsmap={
|
||||
Extended_ips_mac.alias: Extended_ips_mac.namespace})
|
||||
|
||||
|
||||
class ExtendedIpsMacServersTemplate(xmlutil.TemplateBuilder):
|
||||
def construct(self):
|
||||
root = xmlutil.TemplateElement('servers')
|
||||
elem = xmlutil.SubTemplateElement(root, 'server', selector='servers')
|
||||
make_server(elem)
|
||||
return xmlutil.SlaveTemplate(root, 1, nsmap={
|
||||
Extended_ips_mac.alias: Extended_ips_mac.namespace})
|
|
@ -0,0 +1,175 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2013 IBM Corp.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from lxml import etree
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute.contrib import extended_ips_mac
|
||||
from nova.api.openstack import xmlutil
|
||||
from nova import compute
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova import test
|
||||
from nova.tests.api.openstack import fakes
|
||||
|
||||
UUID1 = '00000000-0000-0000-0000-000000000001'
|
||||
UUID2 = '00000000-0000-0000-0000-000000000002'
|
||||
UUID3 = '00000000-0000-0000-0000-000000000003'
|
||||
NW_CACHE = [
|
||||
{
|
||||
'address': 'aa:aa:aa:aa:aa:aa',
|
||||
'id': 1,
|
||||
'network': {
|
||||
'bridge': 'br0',
|
||||
'id': 1,
|
||||
'label': 'private',
|
||||
'subnets': [
|
||||
{
|
||||
'cidr': '192.168.1.0/24',
|
||||
'ips': [
|
||||
{
|
||||
'address': '192.168.1.100',
|
||||
'type': 'fixed',
|
||||
'floating_ips': [
|
||||
{'address': '5.0.0.1', 'type': 'floating'},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
'address': 'bb:bb:bb:bb:bb:bb',
|
||||
'id': 2,
|
||||
'network': {
|
||||
'bridge': 'br1',
|
||||
'id': 2,
|
||||
'label': 'public',
|
||||
'subnets': [
|
||||
{
|
||||
'cidr': '10.0.0.0/24',
|
||||
'ips': [
|
||||
{
|
||||
'address': '10.0.0.100',
|
||||
'type': 'fixed',
|
||||
'floating_ips': [
|
||||
{'address': '5.0.0.2', 'type': 'floating'},
|
||||
],
|
||||
}
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
ALL_IPS = []
|
||||
for cache in NW_CACHE:
|
||||
for subnet in cache['network']['subnets']:
|
||||
for fixed in subnet['ips']:
|
||||
sanitized = dict(fixed)
|
||||
sanitized['mac_address'] = cache['address']
|
||||
sanitized.pop('floating_ips')
|
||||
sanitized.pop('type')
|
||||
ALL_IPS.append(sanitized)
|
||||
for floating in fixed['floating_ips']:
|
||||
sanitized = dict(floating)
|
||||
sanitized['mac_address'] = cache['address']
|
||||
sanitized.pop('type')
|
||||
ALL_IPS.append(sanitized)
|
||||
ALL_IPS.sort()
|
||||
|
||||
|
||||
def fake_compute_get(*args, **kwargs):
|
||||
return fakes.stub_instance(1, uuid=UUID3, nw_cache=NW_CACHE)
|
||||
|
||||
|
||||
def fake_compute_get_all(*args, **kwargs):
|
||||
return [
|
||||
fakes.stub_instance(1, uuid=UUID1, nw_cache=NW_CACHE),
|
||||
fakes.stub_instance(2, uuid=UUID2, nw_cache=NW_CACHE),
|
||||
]
|
||||
|
||||
|
||||
class ExtendedIpsMacTest(test.TestCase):
|
||||
content_type = 'application/json'
|
||||
prefix = '%s:' % extended_ips_mac.Extended_ips_mac.alias
|
||||
|
||||
def setUp(self):
|
||||
super(ExtendedIpsMacTest, self).setUp()
|
||||
fakes.stub_out_nw_api(self.stubs)
|
||||
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
|
||||
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Extended_ips_mac'])
|
||||
|
||||
def _make_request(self, url):
|
||||
req = webob.Request.blank(url)
|
||||
req.headers['Accept'] = self.content_type
|
||||
res = req.get_response(fakes.wsgi_app(init_only=('servers',)))
|
||||
return res
|
||||
|
||||
def _get_server(self, body):
|
||||
return jsonutils.loads(body).get('server')
|
||||
|
||||
def _get_servers(self, body):
|
||||
return jsonutils.loads(body).get('servers')
|
||||
|
||||
def _get_ips(self, server):
|
||||
for network in server['addresses'].itervalues():
|
||||
for ip in network:
|
||||
yield ip
|
||||
|
||||
def assertServerStates(self, server):
|
||||
results = []
|
||||
for ip in self._get_ips(server):
|
||||
results.append({'address': ip.get('addr'),
|
||||
'mac_address': ip.get('%smac_addr' % self.prefix)})
|
||||
|
||||
self.assertEqual(ALL_IPS, sorted(results))
|
||||
|
||||
def test_show(self):
|
||||
url = '/v2/fake/servers/%s' % UUID3
|
||||
res = self._make_request(url)
|
||||
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertServerStates(self._get_server(res.body))
|
||||
|
||||
def test_detail(self):
|
||||
url = '/v2/fake/servers/detail'
|
||||
res = self._make_request(url)
|
||||
|
||||
self.assertEqual(res.status_int, 200)
|
||||
for _i, server in enumerate(self._get_servers(res.body)):
|
||||
self.assertServerStates(server)
|
||||
|
||||
|
||||
class ExtendedIpsMacXmlTest(ExtendedIpsMacTest):
|
||||
content_type = 'application/xml'
|
||||
prefix = '{%s}' % extended_ips_mac.Extended_ips_mac.namespace
|
||||
|
||||
def _get_server(self, body):
|
||||
return etree.XML(body)
|
||||
|
||||
def _get_servers(self, body):
|
||||
return etree.XML(body).getchildren()
|
||||
|
||||
def _get_ips(self, server):
|
||||
for network in server.find('{%s}addresses' % xmlutil.XMLNS_V11):
|
||||
for ip in network:
|
||||
yield ip
|
|
@ -168,6 +168,7 @@ class ExtensionControllerTest(ExtensionTestCase):
|
|||
"DiskConfig",
|
||||
"ExtendedAvailabilityZone",
|
||||
"ExtendedIps",
|
||||
"ExtendedIpsMac",
|
||||
"ExtendedVIFNet",
|
||||
"Evacuate",
|
||||
"ExtendedStatus",
|
||||
|
|
|
@ -124,6 +124,7 @@ policy_data = """
|
|||
"compute_extension:extended_status": "",
|
||||
"compute_extension:extended_availability_zone": "",
|
||||
"compute_extension:extended_ips": "",
|
||||
"compute_extension:extended_ips_mac": "",
|
||||
"compute_extension:extended_vif_net": "",
|
||||
"compute_extension:fixed_ips": "",
|
||||
"compute_extension:flavor_access": "",
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"server": {
|
||||
"accessIPv4": "",
|
||||
"accessIPv6": "",
|
||||
"addresses": {
|
||||
"private": [
|
||||
{
|
||||
"addr": "%(ip)s",
|
||||
"version": 4,
|
||||
"OS-EXT-IPS-MAC:mac_addr": "%(mac_addr)s"
|
||||
}
|
||||
]
|
||||
},
|
||||
"created": "%(timestamp)s",
|
||||
"flavor": {
|
||||
"id": "1",
|
||||
"links": [
|
||||
{
|
||||
"href": "%(host)s/openstack/flavors/1",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
]
|
||||
},
|
||||
"hostId": "%(hostid)s",
|
||||
"id": "%(id)s",
|
||||
"image": {
|
||||
"id": "%(uuid)s",
|
||||
"links": [
|
||||
{
|
||||
"href": "%(host)s/openstack/images/%(uuid)s",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
]
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"href": "%(host)s/v2/openstack/servers/%(id)s",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "%(host)s/openstack/servers/%(id)s",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"My Server Name": "Apache1"
|
||||
},
|
||||
"name": "new-server-test",
|
||||
"progress": 0,
|
||||
"status": "ACTIVE",
|
||||
"tenant_id": "openstack",
|
||||
"updated": "%(timestamp)s",
|
||||
"user_id": "fake"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<server xmlns:OS-EXT-IPS-MAC="http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="%(timestamp)s" hostId="%(hostid)s" name="new-server-test" created="%(timestamp)s" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="%(id)s">
|
||||
<image id="%(uuid)s">
|
||||
<atom:link href="%(host)s/openstack/images/%(uuid)s" rel="bookmark"/>
|
||||
</image>
|
||||
<flavor id="1">
|
||||
<atom:link href="%(host)s/openstack/flavors/1" rel="bookmark"/>
|
||||
</flavor>
|
||||
<metadata>
|
||||
<meta key="My Server Name">Apache1</meta>
|
||||
</metadata>
|
||||
<addresses>
|
||||
<network id="private">
|
||||
<ip version="4" addr="%(ip)s" OS-EXT-IPS-MAC:mac_addr="%(mac_addr)s"/>
|
||||
</network>
|
||||
</addresses>
|
||||
<atom:link href="%(host)s/v2/openstack/servers/%(id)s" rel="self"/>
|
||||
<atom:link href="%(host)s/openstack/servers/%(id)s" rel="bookmark"/>
|
||||
</server>
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"server" : {
|
||||
"name" : "new-server-test",
|
||||
"imageRef" : "%(host)s/openstack/images/%(image_id)s",
|
||||
"flavorRef" : "%(host)s/openstack/flavors/1",
|
||||
"metadata" : {
|
||||
"My Server Name" : "Apache1"
|
||||
},
|
||||
"personality" : [
|
||||
{
|
||||
"path" : "/etc/banner.txt",
|
||||
"contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<server xmlns="http://docs.openstack.org/compute/api/v1.1" imageRef="%(host)s/openstack/images/%(image_id)s" flavorRef="%(host)s/openstack/flavors/1" name="new-server-test">
|
||||
<metadata>
|
||||
<meta key="My Server Name">Apache1</meta>
|
||||
</metadata>
|
||||
<personality>
|
||||
<file path="/etc/banner.txt">
|
||||
ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
|
||||
dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k
|
||||
IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs
|
||||
c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g
|
||||
QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo
|
||||
ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv
|
||||
dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy
|
||||
c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6
|
||||
b25zLiINCg0KLVJpY2hhcmQgQmFjaA==
|
||||
</file>
|
||||
</personality>
|
||||
</server>
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"server": {
|
||||
"adminPass": "%(password)s",
|
||||
"id": "%(id)s",
|
||||
"links": [
|
||||
{
|
||||
"href": "%(host)s/v2/openstack/servers/%(uuid)s",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "%(host)s/openstack/servers/%(uuid)s",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" id="%(id)s" adminPass="%(password)s">
|
||||
<metadata/>
|
||||
<atom:link href="%(host)s/v2/openstack/servers/%(uuid)s" rel="self"/>
|
||||
<atom:link href="%(host)s/openstack/servers/%(uuid)s" rel="bookmark"/>
|
||||
</server>
|
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"servers": [
|
||||
{
|
||||
"status": "ACTIVE",
|
||||
"updated": "%(timestamp)s",
|
||||
"user_id": "fake",
|
||||
"addresses": {
|
||||
"private": [
|
||||
{
|
||||
"addr": "%(ip)s",
|
||||
"version": 4,
|
||||
"OS-EXT-IPS-MAC:mac_addr": "%(mac_addr)s"
|
||||
}
|
||||
]
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"href": "%(host)s/v2/openstack/servers/%(id)s",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "%(host)s/openstack/servers/%(id)s",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"created": "%(timestamp)s",
|
||||
"name": "new-server-test",
|
||||
"image": {
|
||||
"id": "%(uuid)s",
|
||||
"links": [
|
||||
{
|
||||
"href": "%(host)s/openstack/images/%(uuid)s",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": "%(uuid)s",
|
||||
"accessIPv4": "",
|
||||
"accessIPv6": "",
|
||||
"tenant_id": "openstack",
|
||||
"progress": 0,
|
||||
"flavor": {
|
||||
"id": "1",
|
||||
"links": [
|
||||
{
|
||||
"href": "%(host)s/openstack/flavors/1",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
]
|
||||
},
|
||||
"hostId": "%(hostid)s",
|
||||
"metadata": {
|
||||
"My Server Name": "Apache1"
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<servers xmlns:OS-EXT-IPS-MAC="http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||
<server xmlns:OS-EXT-IPS-MAC="http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="%(timestamp)s" hostId="%(hostid)s" name="new-server-test" created="%(timestamp)s" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="%(id)s">
|
||||
<image id="%(uuid)s">
|
||||
<atom:link href="%(host)s/openstack/images/%(uuid)s" rel="bookmark"/>
|
||||
</image>
|
||||
<flavor id="1">
|
||||
<atom:link href="%(host)s/openstack/flavors/1" rel="bookmark"/>
|
||||
</flavor>
|
||||
<metadata>
|
||||
<meta key="My Server Name">Apache1</meta>
|
||||
</metadata>
|
||||
<addresses>
|
||||
<network id="private">
|
||||
<ip version="4" addr="%(ip)s" OS-EXT-IPS-MAC:mac_addr="%(mac_addr)s"/>
|
||||
</network>
|
||||
</addresses>
|
||||
<atom:link href="%(host)s/v2/openstack/servers/%(id)s" rel="self"/>
|
||||
<atom:link href="%(host)s/openstack/servers/%(id)s" rel="bookmark"/>
|
||||
</server>
|
||||
</servers>
|
|
@ -32,6 +32,14 @@
|
|||
"namespace": "http://docs.openstack.org/compute/ext/extended_ips/api/v1.1",
|
||||
"updated": "%(timestamp)s"
|
||||
},
|
||||
{
|
||||
"alias": "OS-EXT-IPS-MAC",
|
||||
"description": "%(text)s",
|
||||
"links": [],
|
||||
"name": "ExtendedIpsMac",
|
||||
"namespace": "http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1",
|
||||
"updated": "%(timestamp)s"
|
||||
},
|
||||
{
|
||||
"alias": "OS-EXT-IMG-SIZE",
|
||||
"description": "%(text)s",
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
<extension alias="OS-EXT-IPS" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/extended_ips/api/v1.1" name="ExtendedIps">
|
||||
<description>%(text)s</description>
|
||||
</extension>
|
||||
<extension alias="OS-EXT-IPS-MAC" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1" name="ExtendedIpsMac">
|
||||
<description>%(text)s</description>
|
||||
</extension>
|
||||
<extension alias="OS-EXT-IMG-SIZE" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/image_size/api/v1.1" name="ImageSize">
|
||||
<description>%(text)s</description>
|
||||
</extension>
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
{
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"addr": "%(ip)s",
|
||||
"version": 4
|
||||
"version": 4,
|
||||
"OS-EXT-IPS-MAC:mac_addr": "%(mac_addr)s"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<server xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:OS-EXT-AZ="http://docs.openstack.org/compute/ext/extended_availability_zone/api/v2" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-IPS="http://docs.openstack.org/compute/ext/extended_ips/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="%(timestamp)s" hostId="%(hostid)s" name="new-server-test" created="%(timestamp)s" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="%(id)s" key_name="None" config_drive="" OS-EXT-SRV-ATTR:vm_state="active" OS-EXT-SRV-ATTR:task_state="None" OS-EXT-SRV-ATTR:power_state="1" OS-EXT-SRV-ATTR:instance_name="instance-00000001" OS-EXT-SRV-ATTR:host="%(compute_host)s" OS-EXT-SRV-ATTR:hypervisor_hostname="%(hypervisor_hostname)s" OS-EXT-AZ:availability_zone="nova" OS-DCF:diskConfig="AUTO">
|
||||
<server xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:OS-EXT-AZ="http://docs.openstack.org/compute/ext/extended_availability_zone/api/v2" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-IPS="http://docs.openstack.org/compute/ext/extended_ips/api/v1.1" xmlns:OS-EXT-IPS-MAC="http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="%(timestamp)s" hostId="%(hostid)s" name="new-server-test" created="%(timestamp)s" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="%(id)s" key_name="None" config_drive="" OS-EXT-SRV-ATTR:vm_state="active" OS-EXT-SRV-ATTR:task_state="None" OS-EXT-SRV-ATTR:power_state="1" OS-EXT-SRV-ATTR:instance_name="instance-00000001" OS-EXT-SRV-ATTR:host="%(compute_host)s" OS-EXT-SRV-ATTR:hypervisor_hostname="%(hypervisor_hostname)s" OS-EXT-AZ:availability_zone="nova" OS-DCF:diskConfig="AUTO">
|
||||
<image id="%(uuid)s">
|
||||
<atom:link href="%(host)s/openstack/images/%(uuid)s" rel="bookmark"/>
|
||||
</image>
|
||||
|
@ -11,7 +11,8 @@
|
|||
</metadata>
|
||||
<addresses>
|
||||
<network id="private">
|
||||
<ip OS-EXT-IPS:type="fixed" version="4" addr="%(ip)s"/>
|
||||
<ip OS-EXT-IPS:type="fixed" version="4" addr="%(ip)s"
|
||||
OS-EXT-IPS-MAC:mac_addr="%(mac_addr)s"/>
|
||||
</network>
|
||||
</addresses>
|
||||
<atom:link href="%(host)s/v2/openstack/servers/%(id)s" rel="self"/>
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
{
|
||||
"OS-EXT-IPS:type": "fixed",
|
||||
"addr": "%(ip)s",
|
||||
"version": 4
|
||||
"version": 4,
|
||||
"OS-EXT-IPS-MAC:mac_addr": "%(mac_addr)s"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<servers xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:OS-EXT-AZ="http://docs.openstack.org/compute/ext/extended_availability_zone/api/v2" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-IPS="http://docs.openstack.org/compute/ext/extended_ips/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||
<servers xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:OS-EXT-AZ="http://docs.openstack.org/compute/ext/extended_availability_zone/api/v2" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-IPS="http://docs.openstack.org/compute/ext/extended_ips/api/v1.1" xmlns:OS-EXT-IPS-MAC="http://docs.openstack.org/compute/ext/extended_ips_mac/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1">
|
||||
<server xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:OS-EXT-AZ="http://docs.openstack.org/compute/ext/extended_availability_zone/api/v2" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-IPS="http://docs.openstack.org/compute/ext/extended_ips/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="%(timestamp)s" hostId="%(hostid)s" name="new-server-test" created="%(timestamp)s" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="%(id)s" key_name="None" config_drive="" OS-EXT-SRV-ATTR:vm_state="active" OS-EXT-SRV-ATTR:task_state="None" OS-EXT-SRV-ATTR:power_state="1" OS-EXT-SRV-ATTR:instance_name="instance-00000001" OS-EXT-SRV-ATTR:host="%(compute_host)s" OS-EXT-SRV-ATTR:hypervisor_hostname="%(hypervisor_hostname)s" OS-EXT-AZ:availability_zone="nova" OS-DCF:diskConfig="AUTO">
|
||||
<image id="%(uuid)s">
|
||||
<atom:link href="%(host)s/openstack/images/%(uuid)s" rel="bookmark"/>
|
||||
|
@ -12,7 +12,8 @@
|
|||
</metadata>
|
||||
<addresses>
|
||||
<network id="private">
|
||||
<ip OS-EXT-IPS:type="fixed" version="4" addr="%(ip)s"/>
|
||||
<ip OS-EXT-IPS:type="fixed" version="4" addr="%(ip)s"
|
||||
OS-EXT-IPS-MAC:mac_addr="%(mac_addr)s"/>
|
||||
</network>
|
||||
</addresses>
|
||||
<atom:link href="%(host)s/v2/openstack/servers/%(id)s" rel="self"/>
|
||||
|
|
|
@ -461,6 +461,7 @@ class ServersSampleJsonTest(ServersSampleBase):
|
|||
subs['hostid'] = '[a-f0-9]+'
|
||||
subs['id'] = uuid
|
||||
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
||||
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
||||
return self._verify_response('server-get-resp', subs, response, 200)
|
||||
|
||||
def test_servers_list(self):
|
||||
|
@ -477,6 +478,7 @@ class ServersSampleJsonTest(ServersSampleBase):
|
|||
subs['hostid'] = '[a-f0-9]+'
|
||||
subs['id'] = uuid
|
||||
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
||||
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
||||
return self._verify_response('servers-details-resp', subs,
|
||||
response, 200)
|
||||
|
||||
|
@ -2331,6 +2333,38 @@ class ExtendedIpsSampleXmlTests(ExtendedIpsSampleJsonTests):
|
|||
ctype = 'xml'
|
||||
|
||||
|
||||
class ExtendedIpsMacSampleJsonTests(ServersSampleBase):
|
||||
extension_name = ("nova.api.openstack.compute.contrib"
|
||||
".extended_ips_mac.Extended_ips_mac")
|
||||
|
||||
def test_show(self):
|
||||
uuid = self._post_server()
|
||||
response = self._do_get('servers/%s' % uuid)
|
||||
self.assertEqual(response.status, 200)
|
||||
subs = self._get_regexes()
|
||||
subs['hostid'] = '[a-f0-9]+'
|
||||
subs['id'] = uuid
|
||||
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
||||
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
||||
return self._verify_response('server-get-resp', subs,
|
||||
response, 200)
|
||||
|
||||
def test_detail(self):
|
||||
uuid = self._post_server()
|
||||
response = self._do_get('servers/detail')
|
||||
self.assertEqual(response.status, 200)
|
||||
subs = self._get_regexes()
|
||||
subs['id'] = uuid
|
||||
subs['hostid'] = '[a-f0-9]+'
|
||||
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
||||
return self._verify_response('servers-detail-resp', subs,
|
||||
response, 200)
|
||||
|
||||
|
||||
class ExtendedIpsMacSampleXmlTests(ExtendedIpsMacSampleJsonTests):
|
||||
ctype = 'xml'
|
||||
|
||||
|
||||
class ExtendedStatusSampleJsonTests(ServersSampleBase):
|
||||
extension_name = ("nova.api.openstack.compute.contrib"
|
||||
".extended_status.Extended_status")
|
||||
|
|
Loading…
Reference in New Issue