Add support for network adapter hotplug.

This patch makes it possible to add/del instance
    interface other than booting time.
    Implement bp:network-adapter-hotplug

Originally from change Ibee003a9ec6cc9b3fd275417caccd0c67f6c871f

Co-authored-by: Yaguang Tang <heut2008@gmail.com>
Co-authored-by: Édouard Thuleau <edouard.thuleau@orange.com>

Change-Id: I4f8f677af58afcb928379e5cf859388d1da45d51
This commit is contained in:
Dan Smith
2013-02-12 15:45:24 -05:00
parent c7f8b93c9d
commit 231a8ce08b
16 changed files with 193 additions and 8 deletions

View File

@@ -96,6 +96,14 @@
"namespace": "http://docs.openstack.org/compute/ext/aggregates/api/v1.1", "namespace": "http://docs.openstack.org/compute/ext/aggregates/api/v1.1",
"updated": "2012-01-12T00:00:00+00:00" "updated": "2012-01-12T00:00:00+00:00"
}, },
{
"alias": "os-attach-interfaces",
"description": "Attach interface support.",
"links": [],
"name": "AttachInterfaces",
"namespace": "http://docs.openstack.org/compute/ext/interfaces/api/v1.1",
"updated": "2012-07-22T00:00:00+00:00"
},
{ {
"alias": "os-availability-zone", "alias": "os-availability-zone",
"description": "1. Add availability_zone to the Create Server v1.1 API.\n 2. Add availability zones describing.\n ", "description": "1. Add availability_zone to the Create Server v1.1 API.\n 2. Add availability zones describing.\n ",
@@ -194,11 +202,11 @@
}, },
{ {
"alias": "os-evacuate", "alias": "os-evacuate",
"description": "Enables server evacuation", "description": "Enables server evacuation.",
"links": [], "links": [],
"name": "Evacuate", "name": "Evacuate",
"namespace": "http://docs.openstack.org/compute/ext/evacuate/api/v2", "namespace": "http://docs.openstack.org/compute/ext/evacuate/api/v2",
"updated": "2012-12-05T00:00:00+00:00" "updated": "2013-01-06T00:00:00+00:00"
}, },
{ {
"alias": "os-fixed-ips", "alias": "os-fixed-ips",

View File

@@ -40,6 +40,9 @@
<extension alias="os-aggregates" updated="2012-01-12T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/aggregates/api/v1.1" name="Aggregates"> <extension alias="os-aggregates" updated="2012-01-12T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/aggregates/api/v1.1" name="Aggregates">
<description>Admin-only aggregate administration.</description> <description>Admin-only aggregate administration.</description>
</extension> </extension>
<extension alias="os-attach-interfaces" updated="2012-07-22T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/interfaces/api/v1.1" name="AttachInterfaces">
<description>Attach interface support.</description>
</extension>
<extension alias="os-availability-zone" updated="2012-12-21T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/availabilityzone/api/v1.1" name="AvailabilityZone"> <extension alias="os-availability-zone" updated="2012-12-21T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/availabilityzone/api/v1.1" name="AvailabilityZone">
<description>1. Add availability_zone to the Create Server v1.1 API. <description>1. Add availability_zone to the Create Server v1.1 API.
2. Add availability zones describing. 2. Add availability zones describing.
@@ -88,8 +91,8 @@
<extension alias="os-deferred-delete" updated="2011-09-01T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/deferred-delete/api/v1.1" name="DeferredDelete"> <extension alias="os-deferred-delete" updated="2011-09-01T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/deferred-delete/api/v1.1" name="DeferredDelete">
<description>Instance deferred delete.</description> <description>Instance deferred delete.</description>
</extension> </extension>
<extension alias="os-evacuate" updated="2012-12-05T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/evacuate/api/v2" name="Evacuate"> <extension alias="os-evacuate" updated="2013-01-06T00:00:00+00:00" namespace="http://docs.openstack.org/compute/ext/evacuate/api/v2" name="Evacuate">
<description>Enables server evacuation</description> <description>Enables server evacuation.</description>
</extension> </extension>
<extension alias="os-fixed-ips" updated="2012-10-18T13:25:27-06:00" namespace="http://docs.openstack.org/compute/ext/fixed_ips/api/v2" name="FixedIPs"> <extension alias="os-fixed-ips" updated="2012-10-18T13:25:27-06:00" namespace="http://docs.openstack.org/compute/ext/fixed_ips/api/v2" name="FixedIPs">
<description>Fixed IPs support.</description> <description>Fixed IPs support.</description>

View File

@@ -0,0 +1,5 @@
{
"interfaceAttachment": {
"port_id": "ce531f90-199f-48c0-816c-13e38010b442"
}
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<interfaceAttachment>
<port_id>ce531f90-199f-48c0-816c-13e38010b442</port_id>
</interfaceAttachment>

View File

@@ -0,0 +1,12 @@
{
"interfaceAttachment": {
"fixed_ips": [{
"ip_address": "192.168.1.1",
"subnet_id": "f8a6e8f8-c2ec-497c-9f23-da9616de54ef"
}],
"mac_addr": "fa:16:3e:4c:2c:30",
"net_id": "3cb9bc59-5699-4588-a4b1-b87f96708bc6",
"port_id": "ce531f90-199f-48c0-816c-13e38010b442",
"port_state": "ACTIVE"
}
}

View File

@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<interfaceAttachment>
<net_id>3cb9bc59-5699-4588-a4b1-b87f96708bc6</net_id>
<port_id>ce531f90-199f-48c0-816c-13e38010b442</port_id>
<fixed_ips>
<fixed_ip>
<subnet_id>f8a6e8f8-c2ec-497c-9f23-da9616de54ef</subnet_id>
<ip_address>192.168.1.3</ip_address>
</fixed_ip>
</fixed_ips>
<port_state>ACTIVE</port_state>
<mac_addr>fa:16:3e:4c:2c:30</mac_addr>
</interfaceAttachment>

View File

@@ -0,0 +1,16 @@
{
"interfaceAttachments": [
{
"port_state": "ACTIVE",
"fixed_ips": [
{
"subnet_id": "f8a6e8f8-c2ec-497c-9f23-da9616de54ef",
"ip_address": "192.168.1.3"
}
],
"net_id": "3cb9bc59-5699-4588-a4b1-b87f96708bc6",
"port_id": "ce531f90-199f-48c0-816c-13e38010b442",
"mac_addr": "fa:16:3e:4c:2c:30"
}
]
}

View File

@@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<interfaceAttachments>
<interfaceAttachment>
<port_state>ACTIVE</port_state>
<fixed_ips>
<fixed_ip>
<subnet_id>f8a6e8f8-c2ec-497c-9f23-da9616de54ef</subnet_id>
<ip_address>192.168.1.3</ip_address>
</fixed_ip>
</fixed_ips>
<port_id>ce531f90-199f-48c0-816c-13e38010b442</port_id>
<net_id>3cb9bc59-5699-4588-a4b1-b87f96708bc6</net_id>
<mac_addr>fa:16:3e:4c:2c:30</mac_addr>
</interfaceAttachment>
</interfaceAttachments>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<interfaceAttachments>
<interfaceAttachment>
<item>
<port_state>ACTIVE</port_state>
<fixed_ips>
<fixed_ip>
<subnet_id>f8a6e8f8-c2ec-497c-9f23-da9616de54ef</subnet_id>
<ip_address>192.168.1.3</ip_address>
</fixed_ip>
</fixed_ips>
<port_id>ce531f90-199f-48c0-816c-13e38010b442</port_id>
<net_id>3cb9bc59-5699-4588-a4b1-b87f96708bc6</net_id>
<mac_addr>fa:16:3e:4c:2c:30</mac_addr>
</item>
</interfaceAttachment>
</interfaceAttachments>

View File

@@ -0,0 +1,14 @@
{
"interfaceAttachment": {
"port_state": "ACTIVE",
"fixed_ips": [
{
"subnet_id": "f8a6e8f8-c2ec-497c-9f23-da9616de54ef",
"ip_address": "192.168.1.3"
}
],
"net_id": "3cb9bc59-5699-4588-a4b1-b87f96708bc6",
"port_id": "ce531f90-199f-48c0-816c-13e38010b442",
"mac_addr": "fa:16:3e:4c:2c:30"
}
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<interfaceAttachment>
<port_state>ACTIVE</port_state>
<fixed_ips>
<fixed_ip>
<subnet_id>b6e47749-6bf0-4d6e-ae4b-ba6b5e238510</subnet_id>
<ip_address>192.168.123.131</ip_address>
</fixed_ip>
</fixed_ips>
<port_id>89e64f2e-86bd-4c19-9155-4548b36fdcb2</port_id>
<net_id>a9efd207-2c1a-4cdd-a296-d3c7c3211302</net_id>
<mac_addr>fa:16:3e:a4:1c:12</mac_addr>
</interfaceAttachment>

View File

@@ -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=="
}
]
}
}

View File

@@ -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>

View File

@@ -0,0 +1,16 @@
{
"server": {
"adminPass": "N4Lxd6cMUXmE",
"id": "4e44ac84-f3ed-4219-aa2e-b3d1477f0ac3",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/4e44ac84-f3ed-4219-aa2e-b3d1477f0ac3",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/4e44ac84-f3ed-4219-aa2e-b3d1477f0ac3",
"rel": "bookmark"
}
]
}
}

View File

@@ -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="71f1047f-f5db-42f9-b43f-85767bcafda6" adminPass="XVCtnj5P2MnJ">
<metadata/>
<atom:link href="http://openstack.example.com/v2/openstack/servers/71f1047f-f5db-42f9-b43f-85767bcafda6" rel="self"/>
<atom:link href="http://openstack.example.com/openstack/servers/71f1047f-f5db-42f9-b43f-85767bcafda6" rel="bookmark"/>
</server>

View File

@@ -496,6 +496,10 @@ class NetworkNotFound(NotFound):
message = _("Network %(network_id)s could not be found.") message = _("Network %(network_id)s could not be found.")
class PortNotFound(NotFound):
message = _("Port id %(port_id)s could not be found.")
class NetworkNotFoundForBridge(NetworkNotFound): class NetworkNotFoundForBridge(NetworkNotFound):
message = _("Network could not be found for bridge %(bridge)s") message = _("Network could not be found for bridge %(bridge)s")
@@ -529,10 +533,6 @@ class PortInUse(NovaException):
message = _("Port %(port_id)s is still in use.") message = _("Port %(port_id)s is still in use.")
class PortNotFound(NotFound):
message = _("Port %(port_id)s could not be found.")
class PortNotUsable(NovaException): class PortNotUsable(NovaException):
message = _("Port %(port_id)s not usable for instance %(instance)s.") message = _("Port %(port_id)s not usable for instance %(instance)s.")
@@ -1076,6 +1076,14 @@ class ConfigDriveUnknownFormat(NovaException):
"iso9660 or vfat.") "iso9660 or vfat.")
class InterfaceAttachFailed(Invalid):
message = _("Failed to attach network adapter device to %(instance)s")
class InterfaceDetachFailed(Invalid):
message = _("Failed to detach network adapter device from %(instance)s")
class InstanceUserDataTooLarge(NovaException): class InstanceUserDataTooLarge(NovaException):
message = _("User data too large. User data must be no larger than " message = _("User data too large. User data must be no larger than "
"%(maxsize)s bytes once base64 encoded. Your data is " "%(maxsize)s bytes once base64 encoded. Your data is "