api-ref: Fix examples for add/removeFixedIp action
The nova-network has been deprecated since Newton. In neutron case, a network ID is a UUID. So replace an integer network ID with a UUID in the addFixedIp action example. The format of removeFixedIp action example is fixed. Change-Id: Icaaf25e7648a75b66f6fcaddd759fdf243810db4 Implements: blueprint api-ref-in-rst-pike
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"addFixedIp": {
|
"addFixedIp": {
|
||||||
"networkId": 1
|
"networkId": "e1882e38-38c2-4239-ade7-35d644cb963a"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"removeFixedIp":{
|
"removeFixedIp": {
|
||||||
"address": "10.0.0.4"
|
"address": "10.0.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,6 +37,7 @@ from nova import context
|
|||||||
from nova.db import migration
|
from nova.db import migration
|
||||||
from nova.db.sqlalchemy import api as session
|
from nova.db.sqlalchemy import api as session
|
||||||
from nova import exception
|
from nova import exception
|
||||||
|
from nova.network import model as network_model
|
||||||
from nova import objects
|
from nova import objects
|
||||||
from nova.objects import base as obj_base
|
from nova.objects import base as obj_base
|
||||||
from nova.objects import service as service_obj
|
from nova.objects import service as service_obj
|
||||||
@@ -1046,6 +1047,55 @@ class NeutronFixture(fixtures.Fixture):
|
|||||||
'tenant_id': tenant_id
|
'tenant_id': tenant_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nw_info = [{
|
||||||
|
"profile": {},
|
||||||
|
"ovs_interfaceid": "b71f1699-42be-4515-930a-f3ef01f94aa7",
|
||||||
|
"preserve_on_delete": False,
|
||||||
|
"network": {
|
||||||
|
"bridge": "br-int",
|
||||||
|
"subnets": [{
|
||||||
|
"ips": [{
|
||||||
|
"meta": {},
|
||||||
|
"version": 4,
|
||||||
|
"type": "fixed",
|
||||||
|
"floating_ips": [],
|
||||||
|
"address": "10.0.0.4"
|
||||||
|
}],
|
||||||
|
"version": 4,
|
||||||
|
"meta": {},
|
||||||
|
"dns": [],
|
||||||
|
"routes": [],
|
||||||
|
"cidr": "10.0.0.0/26",
|
||||||
|
"gateway": {
|
||||||
|
"meta": {},
|
||||||
|
"version": 4,
|
||||||
|
"type": "gateway",
|
||||||
|
"address": "10.0.0.1"
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
"meta": {
|
||||||
|
"injected": False,
|
||||||
|
"tenant_id": tenant_id,
|
||||||
|
"mtu": 1500
|
||||||
|
},
|
||||||
|
"id": "e1882e38-38c2-4239-ade7-35d644cb963a",
|
||||||
|
"label": "public"
|
||||||
|
},
|
||||||
|
"devname": "tapb71f1699-42",
|
||||||
|
"vnic_type": "normal",
|
||||||
|
"qbh_params": None,
|
||||||
|
"meta": {},
|
||||||
|
"details": {
|
||||||
|
"port_filter": True,
|
||||||
|
"ovs_hybrid_plug": True
|
||||||
|
},
|
||||||
|
"address": "fa:16:3e:47:94:4a",
|
||||||
|
"active": True,
|
||||||
|
"type": "ovs",
|
||||||
|
"id": "b71f1699-42be-4515-930a-f3ef01f94aa7",
|
||||||
|
"qbg_params": None
|
||||||
|
}]
|
||||||
|
|
||||||
def __init__(self, test, multiple_ports=False):
|
def __init__(self, test, multiple_ports=False):
|
||||||
super(NeutronFixture, self).__init__()
|
super(NeutronFixture, self).__init__()
|
||||||
self.test = test
|
self.test = test
|
||||||
@@ -1068,6 +1118,14 @@ class NeutronFixture(fixtures.Fixture):
|
|||||||
self.test.stub_out(
|
self.test.stub_out(
|
||||||
'nova.network.neutronv2.api.API.migrate_instance_start',
|
'nova.network.neutronv2.api.API.migrate_instance_start',
|
||||||
lambda *args, **kwargs: None)
|
lambda *args, **kwargs: None)
|
||||||
|
self.test.stub_out(
|
||||||
|
'nova.network.neutronv2.api.API.add_fixed_ip_to_instance',
|
||||||
|
lambda *args, **kwargs: network_model.NetworkInfo.hydrate(
|
||||||
|
NeutronFixture.nw_info))
|
||||||
|
self.test.stub_out(
|
||||||
|
'nova.network.neutronv2.api.API.remove_fixed_ip_from_instance',
|
||||||
|
lambda *args, **kwargs: network_model.NetworkInfo.hydrate(
|
||||||
|
NeutronFixture.nw_info))
|
||||||
self.test.stub_out(
|
self.test.stub_out(
|
||||||
'nova.network.neutronv2.api.API.migrate_instance_finish',
|
'nova.network.neutronv2.api.API.migrate_instance_finish',
|
||||||
lambda *args, **kwargs: None)
|
lambda *args, **kwargs: None)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"addFixedIp": {
|
"addFixedIp": {
|
||||||
"networkId": %(networkId)s
|
"networkId": "%(networkId)s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"removeFixedIp":{
|
"removeFixedIp": {
|
||||||
"address": "%(ip)s"
|
"address": "%(ip)s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,27 +13,40 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from nova.tests.functional.api_sample_tests import test_servers
|
from nova.tests import fixtures
|
||||||
|
from nova.tests.functional.api_sample_tests import api_sample_base
|
||||||
|
from nova.tests.functional import integrated_helpers
|
||||||
|
|
||||||
|
|
||||||
class MultinicSampleJsonTest(test_servers.ServersSampleBase):
|
class MultinicSampleJsonTest(integrated_helpers.InstanceHelperMixin,
|
||||||
|
api_sample_base.ApiSampleTestBaseV21):
|
||||||
ADMIN_API = True
|
ADMIN_API = True
|
||||||
|
USE_NEUTRON = True
|
||||||
sample_dir = "os-multinic"
|
sample_dir = "os-multinic"
|
||||||
|
|
||||||
def _disable_instance_dns_manager(self):
|
|
||||||
# NOTE(markmc): it looks like multinic and instance_dns_manager are
|
|
||||||
# incompatible. See:
|
|
||||||
# https://bugs.launchpad.net/nova/+bug/1213251
|
|
||||||
self.flags(
|
|
||||||
instance_dns_manager='nova.network.noop_dns_driver.NoopDNSDriver')
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self._disable_instance_dns_manager()
|
|
||||||
super(MultinicSampleJsonTest, self).setUp()
|
super(MultinicSampleJsonTest, self).setUp()
|
||||||
self.uuid = self._post_server()
|
self.neutron = fixtures.NeutronFixture(self)
|
||||||
|
self.useFixture(self.neutron)
|
||||||
|
server = self._boot_a_server(
|
||||||
|
extra_params={'networks': [{'port': self.neutron.port_1['id']}]})
|
||||||
|
self.uuid = server['id']
|
||||||
|
|
||||||
|
def _boot_a_server(self, expected_status='ACTIVE', extra_params=None):
|
||||||
|
server = self._build_minimal_create_server_request(
|
||||||
|
self.api, 'MultinicSampleJsonTestServer')
|
||||||
|
if extra_params:
|
||||||
|
server.update(extra_params)
|
||||||
|
|
||||||
|
created_server = self.api.post_server({'server': server})
|
||||||
|
|
||||||
|
# Wait for it to finish being created
|
||||||
|
found_server = self._wait_for_state_change(self.api, created_server,
|
||||||
|
expected_status)
|
||||||
|
return found_server
|
||||||
|
|
||||||
def _add_fixed_ip(self):
|
def _add_fixed_ip(self):
|
||||||
subs = {"networkId": '1'}
|
subs = {"networkId": 'e1882e38-38c2-4239-ade7-35d644cb963a'}
|
||||||
response = self._do_post('servers/%s/action' % (self.uuid),
|
response = self._do_post('servers/%s/action' % (self.uuid),
|
||||||
'multinic-add-fixed-ip-req', subs)
|
'multinic-add-fixed-ip-req', subs)
|
||||||
self.assertEqual(202, response.status_code)
|
self.assertEqual(202, response.status_code)
|
||||||
|
Reference in New Issue
Block a user