diff --git a/api-ref/source/v1/parameters.yaml b/api-ref/source/v1/parameters.yaml index 0d1ec9b6..8fa7dc49 100644 --- a/api-ref/source/v1/parameters.yaml +++ b/api-ref/source/v1/parameters.yaml @@ -337,13 +337,6 @@ multi_server_name_body: in: body required: true type: string -network_port_type: - description: | - To provision the server with a specified type of NIC(like 1GE or 10 GE) for a - network, specify the type of the NIC in the ``port_type`` key in a dict in ``networks`` list. - in: body - required: false - type: string network_uuid: description: | To provision the server with a NIC for a network, specify the UUID of diff --git a/api-ref/source/v1/samples/server_networks/server-get-network-response.json b/api-ref/source/v1/samples/server_networks/server-get-network-response.json index de724590..fc643f7b 100644 --- a/api-ref/source/v1/samples/server_networks/server-get-network-response.json +++ b/api-ref/source/v1/samples/server_networks/server-get-network-response.json @@ -4,7 +4,6 @@ "network_id": "f31af5a2-f14d-4007-b2e5-abeb82429b87", "port_id": "99845c22-6268-46c1-b068-1dbcb8adaf68", "floating_ip": null, - "port_type": null, "mac_address": "52:54:00:cc:ed:87", "fixed_ips": [ { diff --git a/api-ref/source/v1/samples/servers/multi-server-create-req.json b/api-ref/source/v1/samples/servers/multi-server-create-req.json index cc1a9b87..2f7e4c2f 100644 --- a/api-ref/source/v1/samples/servers/multi-server-create-req.json +++ b/api-ref/source/v1/samples/servers/multi-server-create-req.json @@ -8,8 +8,7 @@ "net_id": "c1940655-8b8e-4370-b8f9-03ba1daeca31" }, { - "net_id": "8e8ceb07-4641-4188-9b22-840755e92ee2", - "port_type": "10GE" + "net_id": "8e8ceb07-4641-4188-9b22-840755e92ee2" } ], "min_count": 2, diff --git a/api-ref/source/v1/samples/servers/server-create-req.json b/api-ref/source/v1/samples/servers/server-create-req.json index facabdfb..0844a2fe 100644 --- a/api-ref/source/v1/samples/servers/server-create-req.json +++ b/api-ref/source/v1/samples/servers/server-create-req.json @@ -9,8 +9,7 @@ "net_id": "c1940655-8b8e-4370-b8f9-03ba1daeca31" }, { - "net_id": "8e8ceb07-4641-4188-9b22-840755e92ee2", - "port_type": "10GE" + "net_id": "8e8ceb07-4641-4188-9b22-840755e92ee2" } ], "metadata" : { diff --git a/api-ref/source/v1/samples/servers/server-detail-resp.json b/api-ref/source/v1/samples/servers/server-detail-resp.json index fec103d8..1e414728 100644 --- a/api-ref/source/v1/samples/servers/server-detail-resp.json +++ b/api-ref/source/v1/samples/servers/server-detail-resp.json @@ -20,7 +20,6 @@ "network_id": "f31af5a2-f14d-4007-b2e5-abeb82429b87", "port_id": "43cb1111-63c5-45d2-8bcf-3443d94b34f3", "floating_ip": null, - "port_type": null, "mac_address": "52:54:00:d0:f9:2c", "fixed_ips": [ { diff --git a/api-ref/source/v1/samples/servers/server-list-detail-resp.json b/api-ref/source/v1/samples/servers/server-list-detail-resp.json index 8fc6e6d0..2b8d0cbe 100644 --- a/api-ref/source/v1/samples/servers/server-list-detail-resp.json +++ b/api-ref/source/v1/samples/servers/server-list-detail-resp.json @@ -22,7 +22,6 @@ "network_id": "f31af5a2-f14d-4007-b2e5-abeb82429b87", "port_id": "43cb1111-63c5-45d2-8bcf-3443d94b34f3", "floating_ip": null, - "port_type": null, "mac_address": "52:54:00:d0:f9:2c", "fixed_ips": [ { diff --git a/api-ref/source/v1/samples/servers/server-update-resp.json b/api-ref/source/v1/samples/servers/server-update-resp.json index 32b5c01c..e09320fd 100644 --- a/api-ref/source/v1/samples/servers/server-update-resp.json +++ b/api-ref/source/v1/samples/servers/server-update-resp.json @@ -27,7 +27,6 @@ "network_id": "f31af5a2-f14d-4007-b2e5-abeb82429b87", "port_id": "99845c22-6268-46c1-b068-1dbcb8adaf68", "floating_ip": null, - "port_type": null, "mac_address": "52:54:00:cc:ed:87", "fixed_ips": [ { diff --git a/api-ref/source/v1/servers.inc b/api-ref/source/v1/servers.inc index bbf779cc..b1efa14a 100644 --- a/api-ref/source/v1/servers.inc +++ b/api-ref/source/v1/servers.inc @@ -37,7 +37,6 @@ Request - availability_zone: availability_zone - networks: networks - networks.net_id: network_uuid - - networks.port_type: network_port_type - networks.port_id: port_uuid - metadata: metadata - user_data: user_data diff --git a/mogan/api/controllers/v1/schemas/servers.py b/mogan/api/controllers/v1/schemas/servers.py index dc9ee678..37602018 100644 --- a/mogan/api/controllers/v1/schemas/servers.py +++ b/mogan/api/controllers/v1/schemas/servers.py @@ -31,7 +31,6 @@ create_server = { 'type': 'object', 'properties': { 'net_id': parameter_types.network_id, - 'port_type': parameter_types.port_type, 'port_id': parameter_types.network_port_id, }, 'oneOf': [ diff --git a/mogan/api/controllers/v1/utils.py b/mogan/api/controllers/v1/utils.py index cd815e27..eed8fc30 100644 --- a/mogan/api/controllers/v1/utils.py +++ b/mogan/api/controllers/v1/utils.py @@ -57,7 +57,7 @@ def apply_jsonpatch(doc, patch): def show_nics(nics): - show_keys = ['port_id', 'port_type', 'network_id', 'mac_address', + show_keys = ['port_id', 'network_id', 'mac_address', 'fixed_ips', 'floating_ip', 'extra'] ret_nics = [] for nic in nics: diff --git a/mogan/api/validation/parameter_types.py b/mogan/api/validation/parameter_types.py index a9a70760..70746f8c 100644 --- a/mogan/api/validation/parameter_types.py +++ b/mogan/api/validation/parameter_types.py @@ -54,11 +54,6 @@ network_port_id = { } -port_type = { - 'type': 'string', 'minLength': 1, 'maxLength': 255, -} - - flavor_id = { 'type': 'string', 'format': 'uuid' } diff --git a/mogan/db/sqlalchemy/alembic/versions/91941bf1ebc9_initial_migration.py b/mogan/db/sqlalchemy/alembic/versions/91941bf1ebc9_initial_migration.py index dd5e671b..2513703a 100644 --- a/mogan/db/sqlalchemy/alembic/versions/91941bf1ebc9_initial_migration.py +++ b/mogan/db/sqlalchemy/alembic/versions/91941bf1ebc9_initial_migration.py @@ -105,7 +105,6 @@ def upgrade(): sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('address', sa.String(length=18), nullable=False), - sa.Column('port_type', sa.String(length=255), nullable=False), sa.Column('port_uuid', sa.String(length=36), nullable=False), sa.Column('node_uuid', sa.String(length=36), nullable=False), sa.Column('extra_specs', sa.Text(), nullable=True), @@ -123,7 +122,6 @@ def upgrade(): sa.Column('port_id', sa.String(length=36), nullable=False), sa.Column('mac_address', sa.String(length=36), nullable=True), sa.Column('network_id', sa.String(length=36), nullable=True), - sa.Column('port_type', sa.String(length=64), nullable=True), sa.Column('floating_ip', sa.String(length=64), nullable=True), sa.Column('fixed_ips', sa.Text(), nullable=True), sa.ForeignKeyConstraint(['server_uuid'], ['servers.uuid'], ), diff --git a/mogan/db/sqlalchemy/models.py b/mogan/db/sqlalchemy/models.py index 60f1c67a..2c95a42a 100644 --- a/mogan/db/sqlalchemy/models.py +++ b/mogan/db/sqlalchemy/models.py @@ -120,7 +120,6 @@ class ComputePort(Base): ) id = Column(Integer, primary_key=True) address = Column(String(18), nullable=False) - port_type = Column(String(255), nullable=False) port_uuid = Column(String(36), nullable=False) node_uuid = Column(String(36), nullable=False) extra_specs = Column(db_types.JsonEncodedDict) @@ -140,7 +139,6 @@ class ServerNic(Base): mac_address = Column(String(32), nullable=False) network_id = Column(String(36), nullable=True) fixed_ips = Column(db_types.JsonEncodedList) - port_type = Column(String(64), nullable=True) floating_ip = Column(String(64), nullable=True) _server = orm.relationship( Server, diff --git a/mogan/engine/baremetal/ironic/driver.py b/mogan/engine/baremetal/ironic/driver.py index 84987734..f99860ff 100644 --- a/mogan/engine/baremetal/ironic/driver.py +++ b/mogan/engine/baremetal/ironic/driver.py @@ -159,11 +159,8 @@ class IronicDriver(base_driver.BaseEngineDriver): def _port_resource(self, port): """Helper method to create resource dict from port stats.""" - port_type = port.extra.get('port_type') - dic = { 'address': str(port.address), - 'port_type': str(port_type), 'node_uuid': str(port.node_uuid), 'port_uuid': str(port.uuid), } @@ -261,11 +258,8 @@ class IronicDriver(base_driver.BaseEngineDriver): detail=detail) return ports + portgroups - def plug_vif(self, ironic_port_id, port_id): - patch = [{'op': 'add', - 'path': '/extra/vif_port_id', - 'value': port_id}] - self.ironicclient.call("port.update", ironic_port_id, patch) + def plug_vif(self, node_uuid, port_id): + self.ironicclient.call("node.vif_attach", node_uuid, port_id) def unplug_vifs(self, context, server): LOG.debug("unplug: server_uuid=%(uuid)s vif=%(server_nics)s", diff --git a/mogan/engine/flows/create_server.py b/mogan/engine/flows/create_server.py index 0c5841fe..47892340 100644 --- a/mogan/engine/flows/create_server.py +++ b/mogan/engine/flows/create_server.py @@ -156,38 +156,38 @@ class BuildNetworkTask(flow_utils.MoganTask): 'pif_count': len(ports)}) nics_obj = objects.ServerNics(context) - for vif, pif in zip(requested_networks, ports): - # Match the specified port type with physical interface type - if vif.get('port_type', 'None') == pif.port_type: - try: - if vif.get('net_id'): - port = self.manager.network_api.create_port( - context, vif['net_id'], pif.address, server.uuid) - port_dict = port['port'] - elif vif.get('port_id'): - port_dict = self.manager.network_api.show_port( - context, vif.get('port_id')) + for vif in requested_networks: + try: + if vif.get('net_id'): + port = self.manager.network_api.create_port( + context, vif['net_id'], server.uuid) + port_dict = port['port'] + elif vif.get('port_id'): + port_dict = self.manager.network_api.show_port( + context, vif.get('port_id')) - self.manager.driver.plug_vif(pif.port_uuid, - port_dict['id']) - nic_dict = {'port_id': port_dict['id'], - 'network_id': port_dict['network_id'], - 'mac_address': port_dict['mac_address'], - 'fixed_ips': port_dict['fixed_ips'], - 'port_type': vif.get('port_type'), - 'server_uuid': server.uuid} - nics_obj.objects.append(objects.ServerNic( - context, **nic_dict)) + self.manager.driver.plug_vif(server.node_uuid, + port_dict['id']) + # Get updated VIF info + port_dict = self.manager.network_api.show_port( + context, port_dict.get('id')) - except Exception as e: - # Set nics here, so we can clean up the - # created networks during reverting. - server.nics = nics_obj - LOG.error("Server %(server)s: create or get network " - "failed. The reason is %(reason)s", - {"server": server.uuid, "reason": e}) - raise exception.NetworkError(_( - "Build network for server failed.")) + nic_dict = {'port_id': port_dict['id'], + 'network_id': port_dict['network_id'], + 'mac_address': port_dict['mac_address'], + 'fixed_ips': port_dict['fixed_ips'], + 'server_uuid': server.uuid} + nics_obj.objects.append(objects.ServerNic(context, **nic_dict)) + + except Exception as e: + # Set nics here, so we can clean up the + # created networks during reverting. + server.nics = nics_obj + LOG.error("Server %(server)s: create or get network " + "failed. The reason is %(reason)s", + {"server": server.uuid, "reason": e}) + raise exception.NetworkError(_( + "Build network for server failed.")) return nics_obj def execute(self, context, server, requested_networks, ports): diff --git a/mogan/engine/manager.py b/mogan/engine/manager.py index b135db58..1e012787 100644 --- a/mogan/engine/manager.py +++ b/mogan/engine/manager.py @@ -599,19 +599,15 @@ class EngineManager(base_manager.BaseEngineManager): raise exception.ComputePortNotAvailable(message=message) def attach_interface(self, context, server, net_id=None): - pif = self._choose_pif_from_node(context, server.node_uuid) - vif = self.network_api.create_port( - context, net_id, pif.address, server.uuid) + vif = self.network_api.create_port(context, net_id, server.uuid) vif_port = vif['port'] try: - self.driver.plug_vif(pif.uuid, vif_port['id']) - + self.driver.plug_vif(server.node_uuid, vif_port['id']) nics_obj = objects.ServerNics(context) nic_dict = {'port_id': vif_port['id'], 'network_id': vif_port['network_id'], 'mac_address': vif_port['mac_address'], 'fixed_ips': vif_port['fixed_ips'], - 'port_type': vif_port.get('port_type'), 'server_uuid': server.uuid} nics_obj.objects.append(objects.ServerNic( context, **nic_dict)) diff --git a/mogan/network/api.py b/mogan/network/api.py index 5ddfe58d..042ba16c 100644 --- a/mogan/network/api.py +++ b/mogan/network/api.py @@ -62,14 +62,13 @@ def get_client(token=None): class API(object): """API for interacting with the neutron 2.x API.""" - def create_port(self, context, network_uuid, mac, server_uuid): + def create_port(self, context, network_uuid, server_uuid): """Create neutron port.""" client = get_client(context.auth_token) body = { 'port': { 'network_id': network_uuid, - 'mac_address': mac, 'device_id': server_uuid, } } diff --git a/mogan/objects/compute_port.py b/mogan/objects/compute_port.py index 0d9ab03f..a5fd4258 100644 --- a/mogan/objects/compute_port.py +++ b/mogan/objects/compute_port.py @@ -31,7 +31,6 @@ class ComputePort(base.MoganObject, object_base.VersionedObjectDictCompat): fields = { 'id': object_fields.IntegerField(read_only=True), 'address': object_fields.MACAddressField(nullable=False), - 'port_type': object_fields.StringField(), 'port_uuid': object_fields.UUIDField(read_only=True), 'node_uuid': object_fields.UUIDField(read_only=True), 'extra_specs': object_fields.FlexibleDictField(nullable=True), @@ -74,7 +73,7 @@ class ComputePort(base.MoganObject, object_base.VersionedObjectDictCompat): self.obj_refresh(current) def update_from_driver(self, port): - keys = ["address", "port_type", "port_uuid", "node_uuid", + keys = ["address", "port_uuid", "node_uuid", "extra_specs"] for key in keys: if key in port: diff --git a/mogan/objects/server_nics.py b/mogan/objects/server_nics.py index 89767595..f6c1b6c0 100644 --- a/mogan/objects/server_nics.py +++ b/mogan/objects/server_nics.py @@ -36,7 +36,6 @@ class ServerNic(base.MoganObject, object_base.VersionedObjectDictCompat): 'network_id': object_fields.UUIDField(nullable=True), 'fixed_ips': object_fields.ListOfDictOfNullableStringsField( nullable=True), - 'port_type': object_fields.StringField(nullable=True), 'floating_ip': object_fields.StringField(nullable=True), } diff --git a/mogan/scheduler/filters/ports_filter.py b/mogan/scheduler/filters/ports_filter.py index 6ecd6b9e..416212d0 100644 --- a/mogan/scheduler/filters/ports_filter.py +++ b/mogan/scheduler/filters/ports_filter.py @@ -23,15 +23,6 @@ LOG = logging.getLogger(__name__) class PortsFilter(filters.BaseNodeFilter): """NodeFilter to work with resource server type records.""" - def _find_port_type(self, ports, port_type): - """Check if ports has the specified port type.""" - - for port in ports: - if port_type == port.port_type: - return True - - return False - def _satisfies_networks(self, ports, networks): """Check if ports satisfy networks requirements. @@ -45,11 +36,6 @@ class PortsFilter(filters.BaseNodeFilter): if len(ports) < len(networks): return False - for net in networks: - if 'port_type' in net: - if not self._find_port_type(ports, net.get('port_type')): - return False - return True def node_passes(self, node_state, filter_properties): diff --git a/mogan/tests/functional/api/v1/test_servers.py b/mogan/tests/functional/api/v1/test_servers.py index c3915a59..17d642f1 100644 --- a/mogan/tests/functional/api/v1/test_servers.py +++ b/mogan/tests/functional/api/v1/test_servers.py @@ -134,8 +134,8 @@ class TestServers(v1_test.APITestV1): 'flavor_uuid': 'ff28b5a2-73e5-431c-b4b7-1b96b74bca7b', 'image_uuid': 'b8f82429-3a13-4ffe-9398-4d1abdc256a8', 'networks': [ - {'net_id': 'c1940655-8b8e-4370-b8f9-03ba1daeca31', - 'port_type': 'Ethernet'}], + {'net_id': 'c1940655-8b8e-4370-b8f9-03ba1daeca31'} + ], 'metadata': {'fake_key': 'fake_value'} } responses.append( diff --git a/mogan/tests/tempest/api/test_servers.py b/mogan/tests/tempest/api/test_servers.py index bc36fc15..020b47aa 100644 --- a/mogan/tests/tempest/api/test_servers.py +++ b/mogan/tests/tempest/api/test_servers.py @@ -161,7 +161,6 @@ class BaremetalComputeAPIServersTest(base.BaseBaremetalComputeTest): self.assertIn('network_id', nic) self.assertIn('port_id', nic) self.assertIn('floating_ip', nic) - self.assertIn('port_type', nic) self.assertIn('mac_address', nic) self.assertIsInstance(nic['fixed_ips'], list) fixed_ip = nic['fixed_ips'][0] @@ -181,7 +180,6 @@ class BaremetalComputeAPIServersTest(base.BaseBaremetalComputeTest): self.assertIn('network_id', nic) self.assertIn('port_id', nic) self.assertIn('floating_ip', nic) - self.assertIn('port_type', nic) self.assertIn('mac_address', nic) self.assertIsInstance(nic['fixed_ips'], list) fixed_ip = nic['fixed_ips'][0] diff --git a/mogan/tests/unit/api/v1/test_server.py b/mogan/tests/unit/api/v1/test_server.py index f5194c6b..52735e0b 100644 --- a/mogan/tests/unit/api/v1/test_server.py +++ b/mogan/tests/unit/api/v1/test_server.py @@ -29,8 +29,7 @@ def gen_post_body(**kw): "net_id": "c1940655-8b8e-4370-b8f9-03ba1daeca31" }, { - "net_id": "8e8ceb07-4641-4188-9b22-840755e92ee2", - "port_type": "10GE" + "net_id": "8e8ceb07-4641-4188-9b22-840755e92ee2" } ] return { @@ -81,12 +80,10 @@ class TestServerAuthorization(v1_test.APITestV1): mock_engine_create.return_value = [self.server1] fake_networks = [ { - "port_id": "c1940655-8b8e-4370-b8f9-03ba1daeca31", - "port_type": "Ethernet" + "port_id": "c1940655-8b8e-4370-b8f9-03ba1daeca31" }, { - "port_id": "8e8ceb07-4641-4188-9b22-840755e92ee2", - "port_type": "Ethernet" + "port_id": "8e8ceb07-4641-4188-9b22-840755e92ee2" } ] body = gen_post_body(**{'networks': fake_networks}) @@ -110,13 +107,11 @@ class TestServerAuthorization(v1_test.APITestV1): fake_networks = [ { "port_id": "c1940655-8b8e-4370-b8f9-03ba1daeca31", - "net_id": "c1940655-8b8e-4370-b8f9-03ba1daeca32", - "port_type": "Ethernet" + "net_id": "c1940655-8b8e-4370-b8f9-03ba1daeca32" }, { "port_id": "8e8ceb07-4641-4188-9b22-840755e92ee2", - "net_id": "8e8ceb07-4641-4188-9b22-840755e92ee3", - "port_type": "Ethernet" + "net_id": "8e8ceb07-4641-4188-9b22-840755e92ee3" } ] body = gen_post_body(**{'networks': fake_networks}) diff --git a/mogan/tests/unit/db/test_compute_ports.py b/mogan/tests/unit/db/test_compute_ports.py index 74097f29..399a7b50 100644 --- a/mogan/tests/unit/db/test_compute_ports.py +++ b/mogan/tests/unit/db/test_compute_ports.py @@ -74,5 +74,5 @@ class DbComputePortTestCase(base.DbTestCase): port = utils.create_test_compute_port() res = self.dbapi.compute_port_update(self.context, port.port_uuid, - {'port_type': 'foo'}) - self.assertEqual('foo', res.port_type) + {'address': 'aa:bb:cc:dd:ee:ff'}) + self.assertEqual('aa:bb:cc:dd:ee:ff', res.address) diff --git a/mogan/tests/unit/db/utils.py b/mogan/tests/unit/db/utils.py index cc244821..bc107271 100644 --- a/mogan/tests/unit/db/utils.py +++ b/mogan/tests/unit/db/utils.py @@ -35,7 +35,6 @@ def get_test_server(**kw): "ip_address": "2001:db8:8000:0:5054:ff:fe6a:b7cc" } ], - 'port_type': 'test_type', 'floating_ip': '', }, ] @@ -130,7 +129,6 @@ def get_test_compute_port(**kw): return { 'id': kw.get('id', 123), 'address': kw.get('address', '52:54:00:cf:2d:31'), - 'port_type': kw.get('port_type', '1GE'), 'port_uuid': kw.get('port_uuid', 'f978ef48-d4af-4dad-beec-e6174309bc72'), 'node_uuid': kw.get('node_uuid', diff --git a/mogan/tests/unit/objects/test_compute_port.py b/mogan/tests/unit/objects/test_compute_port.py index fc6d2803..3af558a5 100644 --- a/mogan/tests/unit/objects/test_compute_port.py +++ b/mogan/tests/unit/objects/test_compute_port.py @@ -90,5 +90,4 @@ class TestComputePortObject(base.DbTestCase): db_port = utils.create_test_compute_port(context=self.ctxt) port = objects.ComputePort.get(self.context, db_port.port_uuid) port.refresh(self.context) - port.port_type = 'refresh' port.save(self.context) diff --git a/mogan/tests/unit/objects/test_objects.py b/mogan/tests/unit/objects/test_objects.py index a2425668..0d03376c 100644 --- a/mogan/tests/unit/objects/test_objects.py +++ b/mogan/tests/unit/objects/test_objects.py @@ -385,13 +385,13 @@ expected_object_fingerprints = { 'Server': '1.0-dc54162c0cc91fac43fed5304cd2c968', 'ComputeNode': '1.0-586e7eaadd4ec88a0506c4238ebdd7a5', 'ComputeNodeList': '1.0-33a2e1bb91ad4082f9f63429b77c1244', - 'ComputePort': '1.0-ca4c1817ad7324286813f2cfcdcf802e', + 'ComputePort': '1.0-996a1dc296ac109730e7976735488eb2', 'ComputePortList': '1.0-33a2e1bb91ad4082f9f63429b77c1244', 'ServerFault': '1.0-74349ff701259e4834b4e9dc2dac1b12', 'ServerFaultList': '1.0-43e8aad0258652921f929934e9e048fd', 'Flavor': '1.0-f53b71bd4aaaadea0d9284b811a82bb5', 'MyObj': '1.1-aad62eedc5a5cc8bcaf2982c285e753f', - 'ServerNic': '1.0-ebbd767c2f6a7f14bd524c6067f2b382', + 'ServerNic': '1.0-0494306157ef437802260ff8b51cf5cf', 'ServerNics': '1.0-33a2e1bb91ad4082f9f63429b77c1244', 'Quota': '1.0-c8caa082f4d726cb63fdc5943f7cd186', 'KeyPair': '1.0-c6820166e307676c5900f7801831b84c',