Clean up some unused codes
Change-Id: I5552795255b5bfcaf125f3441d6ee7ea7359ec5d
This commit is contained in:
parent
9c76ae4467
commit
d830dc7256
|
@ -174,26 +174,6 @@ class FlavorAccessNotFound(NotFound):
|
|||
"%(project_id)s combination.")
|
||||
|
||||
|
||||
class ComputeNodeAlreadyExists(Conflict):
|
||||
_msg_fmt = _("ComputeNode with node_uuid %(node)s already exists.")
|
||||
|
||||
|
||||
class ComputeNodeNotFound(NotFound):
|
||||
_msg_fmt = _("ComputeNode %(node)s could not be found.")
|
||||
|
||||
|
||||
class ComputePortAlreadyExists(Conflict):
|
||||
_msg_fmt = _("ComputePort with port_uuid %(port)s already exists.")
|
||||
|
||||
|
||||
class ComputePortNotFound(NotFound):
|
||||
_msg_fmt = _("ComputePort %(port)s could not be found.")
|
||||
|
||||
|
||||
class ComputePortNotAvailable(NotFound):
|
||||
_msg_fmt = _("No available compute ports.")
|
||||
|
||||
|
||||
class AggregateNameExists(Conflict):
|
||||
_msg_fmt = _("Aggregate %(name)s already exists.")
|
||||
|
||||
|
|
|
@ -91,47 +91,6 @@ class Server(Base):
|
|||
locked_by = Column(Enum('owner', 'admin'))
|
||||
|
||||
|
||||
class ComputeNode(Base):
|
||||
"""Represents the compute nodes."""
|
||||
|
||||
__tablename__ = 'compute_nodes'
|
||||
__table_args__ = (
|
||||
schema.UniqueConstraint('node_uuid',
|
||||
name='uniq_compute_nodes0node_uuid'),
|
||||
table_args()
|
||||
)
|
||||
id = Column(Integer, primary_key=True)
|
||||
cpus = Column(Integer, nullable=False)
|
||||
memory_mb = Column(Integer, nullable=False)
|
||||
hypervisor_type = Column(String(255), nullable=False)
|
||||
resource_class = Column(String(80), nullable=False)
|
||||
availability_zone = Column(String(255), nullable=True)
|
||||
node_uuid = Column(String(36), nullable=False)
|
||||
extra_specs = Column(db_types.JsonEncodedDict)
|
||||
used = Column(Boolean, default=False)
|
||||
|
||||
|
||||
class ComputePort(Base):
|
||||
"""Represents the compute ports."""
|
||||
|
||||
__tablename__ = 'compute_ports'
|
||||
__table_args__ = (
|
||||
schema.UniqueConstraint('port_uuid',
|
||||
name='uniq_compute_ports0port_uuid'),
|
||||
table_args()
|
||||
)
|
||||
id = Column(Integer, primary_key=True)
|
||||
address = Column(String(18), nullable=False)
|
||||
port_uuid = Column(String(36), nullable=False)
|
||||
node_uuid = Column(String(36), nullable=False)
|
||||
extra_specs = Column(db_types.JsonEncodedDict)
|
||||
_node = orm.relationship(
|
||||
"ComputeNode",
|
||||
backref='ports',
|
||||
foreign_keys=node_uuid,
|
||||
primaryjoin='ComputeNode.node_uuid == ComputePort.node_uuid')
|
||||
|
||||
|
||||
class ServerNic(Base):
|
||||
"""Represents the NIC info for servers."""
|
||||
|
||||
|
|
|
@ -530,18 +530,6 @@ class EngineManager(base_manager.BaseEngineManager):
|
|||
'port': parsed_url.port,
|
||||
'internal_access_path': None}
|
||||
|
||||
def _choose_pif_from_node(self, context, node):
|
||||
pifs = self.driver.get_ports_from_node(node, detail=True)
|
||||
for pif in pifs:
|
||||
vif = pif.extra.get('vif_port_id', None)
|
||||
if not vif:
|
||||
return pif
|
||||
|
||||
# if no available compute ports, raise exception
|
||||
message = "Node %s has no available physical ports." % node
|
||||
LOG.error(message)
|
||||
raise exception.ComputePortNotAvailable(message=message)
|
||||
|
||||
def attach_interface(self, context, server, net_id=None):
|
||||
try:
|
||||
vif = self.network_api.create_port(context, net_id, server.uuid)
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
# Copyright 2017 Huawei Technologies Co.,LTD.
|
||||
# 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 oslo_versionedobjects import base as object_base
|
||||
|
||||
from mogan.db import api as dbapi
|
||||
from mogan.objects import base
|
||||
from mogan.objects import fields as object_fields
|
||||
|
||||
|
||||
@base.MoganObjectRegistry.register
|
||||
class ComputePort(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
|
||||
dbapi = dbapi.get_instance()
|
||||
|
||||
fields = {
|
||||
'id': object_fields.IntegerField(read_only=True),
|
||||
'address': object_fields.MACAddressField(nullable=False),
|
||||
'port_uuid': object_fields.UUIDField(read_only=True),
|
||||
'node_uuid': object_fields.UUIDField(read_only=True),
|
||||
'extra_specs': object_fields.FlexibleDictField(nullable=True),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def list(cls, context):
|
||||
"""Return a list of ComputePort objects."""
|
||||
db_compute_ports = cls.dbapi.compute_port_get_all(context)
|
||||
return cls._from_db_object_list(context, db_compute_ports)
|
||||
|
||||
@classmethod
|
||||
def get(cls, context, port_uuid):
|
||||
"""Find a compute port and return a ComputePort object."""
|
||||
db_compute_port = cls.dbapi.compute_port_get(context, port_uuid)
|
||||
compute_port = cls._from_db_object(context, cls(context),
|
||||
db_compute_port)
|
||||
return compute_port
|
||||
|
||||
def create(self, context=None):
|
||||
"""Create a ComputePort record in the DB."""
|
||||
values = self.obj_get_changes()
|
||||
db_compute_port = self.dbapi.compute_port_create(context, values)
|
||||
self._from_db_object(context, self, db_compute_port)
|
||||
|
||||
def destroy(self, context=None):
|
||||
"""Delete the ComputePort from the DB."""
|
||||
self.dbapi.compute_port_destroy(context, self.port_uuid)
|
||||
self.obj_reset_changes()
|
||||
|
||||
def save(self, context=None):
|
||||
"""Save updates to this ComputePort."""
|
||||
updates = self.obj_get_changes()
|
||||
self.dbapi.compute_port_update(context, self.port_uuid, updates)
|
||||
self.obj_reset_changes()
|
||||
|
||||
def refresh(self, context=None):
|
||||
"""Refresh the object by re-fetching from the DB."""
|
||||
current = self.__class__.get(context, self.port_uuid)
|
||||
self.obj_refresh(current)
|
||||
|
||||
def update_from_driver(self, port):
|
||||
keys = ["address", "port_uuid", "node_uuid",
|
||||
"extra_specs"]
|
||||
for key in keys:
|
||||
if key in port:
|
||||
setattr(self, key, port[key])
|
||||
|
||||
|
||||
@base.MoganObjectRegistry.register
|
||||
class ComputePortList(object_base.ObjectListBase, base.MoganObject,
|
||||
object_base.VersionedObjectDictCompat):
|
||||
# Version 1.0: Initial version
|
||||
|
||||
VERSION = '1.0'
|
||||
|
||||
dbapi = dbapi.get_instance()
|
||||
|
||||
fields = {
|
||||
'objects': object_fields.ListOfObjectsField('ComputePort')
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def get_by_node_uuid(cls, context, node_uuid):
|
||||
db_ports = cls.dbapi.compute_port_get_by_node_uuid(
|
||||
context, node_uuid)
|
||||
return object_base.obj_make_list(context, cls(context),
|
||||
ComputePort, db_ports)
|
Loading…
Reference in New Issue