From 2c16344cfea8461e96425a2c375b4dabd21f03c5 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 31 Aug 2010 16:48:41 -0700 Subject: [PATCH] rename node_name to host --- nova/compute/manager.py | 2 +- nova/db/__init__.py | 20 ++++++++ nova/db/api.py | 15 ++++-- nova/db/sqlalchemy/__init__.py | 25 ++++++++- nova/db/sqlalchemy/api.py | 28 +++++------ nova/db/sqlalchemy/models.py | 92 ++++++++++++++++++++++------------ nova/endpoint/cloud.py | 6 +-- nova/flags.py | 2 +- nova/network/manager.py | 4 +- nova/service.py | 10 ++-- nova/tests/model_unittest.py | 6 +-- nova/tests/network_unittest.py | 2 +- nova/tests/service_unittest.py | 36 ++++++------- nova/volume/manager.py | 4 +- 14 files changed, 163 insertions(+), 89 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 7723edd53871..c15c9e1f5c12 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -74,7 +74,7 @@ class ComputeManager(manager.Manager): self.network_manager.setup_compute_network(context, project_id) db.instance_update(context, instance_id, - {'node_name': FLAGS.node_name}) + {'host': FLAGS.host}) # TODO(vish) check to make sure the availability zone matches db.instance_state(context, diff --git a/nova/db/__init__.py b/nova/db/__init__.py index 2d893cb36154..054b7ac945a2 100644 --- a/nova/db/__init__.py +++ b/nova/db/__init__.py @@ -1,3 +1,23 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# 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. +""" +DB abstraction for Nova +""" from nova.db.api import * diff --git a/nova/db/api.py b/nova/db/api.py index d95d1ce6ead7..8c0649df25c2 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -15,11 +15,13 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +""" +Defines interface for DB access +""" from nova import exception from nova import flags from nova import utils -from nova import validate FLAGS = flags.FLAGS @@ -33,14 +35,17 @@ _impl = utils.LazyPluggable(FLAGS['db_backend'], # TODO(vish): where should these exceptions go? class NoMoreAddresses(exception.Error): + """No more available addresses""" pass class NoMoreBlades(exception.Error): + """No more available blades""" pass class NoMoreNetworks(exception.Error): + """No more available networks""" pass @@ -52,9 +57,9 @@ def daemon_get(context, daemon_id): return _impl.daemon_get(context, daemon_id) -def daemon_get_by_args(context, node_name, binary): +def daemon_get_by_args(context, host, binary): """Get the state of an daemon by node name and binary.""" - return _impl.daemon_get_by_args(context, node_name, binary) + return _impl.daemon_get_by_args(context, host, binary) def daemon_create(context, values): @@ -74,12 +79,12 @@ def daemon_update(context, daemon_id, values): ################### -def floating_ip_allocate_address(context, node_name, project_id): +def floating_ip_allocate_address(context, host, project_id): """Allocate free floating ip and return the address. Raises if one is not available. """ - return _impl.floating_ip_allocate_address(context, node_name, project_id) + return _impl.floating_ip_allocate_address(context, host, project_id) def floating_ip_create(context, address, host): diff --git a/nova/db/sqlalchemy/__init__.py b/nova/db/sqlalchemy/__init__.py index 444f50a9b9f4..3288ebd20f5e 100644 --- a/nova/db/sqlalchemy/__init__.py +++ b/nova/db/sqlalchemy/__init__.py @@ -1,3 +1,24 @@ -from models import register_models +# vim: tabstop=4 shiftwidth=4 softtabstop=4 -register_models() +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# 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. + +""" +SQLAlchemy database backend +""" +from nova.db.sqlalchemy import models + +models.register_models() diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index b00ad19fff36..f6be037b3d91 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -33,8 +33,8 @@ def daemon_get(context, daemon_id): return models.Daemon.find(daemon_id) -def daemon_get_by_args(context, node_name, binary): - return models.Daemon.find_by_args(node_name, binary) +def daemon_get_by_args(context, host, binary): + return models.Daemon.find_by_args(host, binary) def daemon_create(context, values): @@ -55,10 +55,10 @@ def daemon_update(context, daemon_id, values): ################### -def floating_ip_allocate_address(context, node_name, project_id): +def floating_ip_allocate_address(context, host, project_id): with managed_session(autocommit=False) as session: floating_ip_ref = session.query(models.FloatingIp) \ - .filter_by(node_name=node_name) \ + .filter_by(host=host) \ .filter_by(fixed_ip_id=None) \ .filter_by(deleted=False) \ .with_lockmode('update') \ @@ -76,7 +76,7 @@ def floating_ip_allocate_address(context, node_name, project_id): def floating_ip_create(context, address, host): floating_ip_ref = models.FloatingIp() floating_ip_ref['address'] = address - floating_ip_ref['node_name'] = host + floating_ip_ref['host'] = host floating_ip_ref.save() return floating_ip_ref @@ -131,8 +131,8 @@ def floating_ip_get_instance(context, address): def fixed_ip_allocate(context, network_id): with managed_session(autocommit=False) as session: - network_or_none = or_(models.FixedIp.network_id==network_id, - models.FixedIp.network_id==None) + network_or_none = or_(models.FixedIp.network_id == network_id, + models.FixedIp.network_id == None) fixed_ip_ref = session.query(models.FixedIp) \ .filter(network_or_none) \ .filter_by(reserved=False) \ @@ -270,7 +270,7 @@ def instance_get_floating_address(context, instance_id): def instance_get_host(context, instance_id): instance_ref = instance_get(context, instance_id) - return instance_ref['node_name'] + return instance_ref['host'] def instance_is_vpn(context, instance_id): @@ -376,7 +376,7 @@ def network_get_by_bridge(context, bridge): def network_get_host(context, network_id): network_ref = network_get(context, network_id) - return network_ref['node_name'] + return network_ref['host'] def network_get_index(context, network_id): @@ -418,13 +418,13 @@ def network_set_host(context, network_id, host_id): network_id) # NOTE(vish): if with_lockmode isn't supported, as in sqlite, # then this has concurrency issues - if network.node_name: + if network.host: session.commit() - return network['node_name'] - network['node_name'] = host_id + return network['host'] + network['host'] = host_id session.add(network) session.commit() - return network['node_name'] + return network['host'] def network_update(context, network_id, values): @@ -549,7 +549,7 @@ def volume_get_by_str(context, str_id): def volume_get_host(context, volume_id): volume_ref = volume_get(context, volume_id) - return volume_ref['node_name'] + return volume_ref['host'] def volume_get_shelf_and_blade(context, volume_id): diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index b9ed34bb11c9..9e15614f775f 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -20,23 +20,25 @@ SQLAlchemy models for nova data """ +# TODO(vish): clean up these imports from sqlalchemy.orm import relationship, backref, validates, exc -from sqlalchemy import Table, Column, Integer, String -from sqlalchemy import MetaData, ForeignKey, DateTime, Boolean, Text +from sqlalchemy import Column, Integer, String +from sqlalchemy import ForeignKey, DateTime, Boolean, Text from sqlalchemy.ext.declarative import declarative_base from nova.db.sqlalchemy.session import managed_session + from nova import auth from nova import exception from nova import flags FLAGS = flags.FLAGS - -Base = declarative_base() +BASE = declarative_base() class NovaBase(object): + """Base class for Nova Models""" __table_args__ = {'mysql_engine': 'InnoDB'} __table_initialized__ = False __prefix__ = 'none' @@ -46,6 +48,7 @@ class NovaBase(object): @classmethod def all(cls, session=None): + """Get all objects of this type""" if session: return session.query(cls) \ .filter_by(deleted=False) \ @@ -56,6 +59,7 @@ class NovaBase(object): @classmethod def count(cls, session=None): + """Count objects of this type""" if session: return session.query(cls) \ .filter_by(deleted=False) \ @@ -66,6 +70,7 @@ class NovaBase(object): @classmethod def find(cls, obj_id, session=None): + """Find object by id""" if session: try: return session.query(cls) \ @@ -80,14 +85,17 @@ class NovaBase(object): @classmethod def find_by_str(cls, str_id, session=None): - id = int(str_id.rpartition('-')[2]) - return cls.find(id, session=session) + """Find object by str_id""" + int_id = int(str_id.rpartition('-')[2]) + return cls.find(int_id, session=session) @property def str_id(self): + """Get string id of object (generally prefix + '-' + id)""" return "%s-%s" % (self.__prefix__, self.id) def save(self, session=None): + """Save this object""" if session: session.add(self) session.flush() @@ -96,6 +104,7 @@ class NovaBase(object): self.save(session=sess) def delete(self, session=None): + """Delete this object""" self.deleted = True self.save(session=session) @@ -106,7 +115,8 @@ class NovaBase(object): return getattr(self, key) -class Image(Base, NovaBase): +class Image(BASE, NovaBase): + """Represents an image in the datastore""" __tablename__ = 'images' __prefix__ = 'ami' id = Column(Integer, primary_key=True) @@ -139,36 +149,39 @@ class Image(Base, NovaBase): assert(val is None) -class PhysicalNode(Base, NovaBase): - __tablename__ = 'physical_nodes' +class Host(BASE, NovaBase): + """Represents a host where services are running""" + __tablename__ = 'hosts' id = Column(String(255), primary_key=True) -class Daemon(Base, NovaBase): +class Daemon(BASE, NovaBase): + """Represents a running service on a host""" __tablename__ = 'daemons' id = Column(Integer, primary_key=True) - node_name = Column(String(255)) # , ForeignKey('physical_node.id')) + host = Column(String(255), ForeignKey('hosts.id')) binary = Column(String(255)) report_count = Column(Integer, nullable=False, default=0) @classmethod - def find_by_args(cls, node_name, binary, session=None): + def find_by_args(cls, host, binary, session=None): if session: try: return session.query(cls) \ - .filter_by(node_name=node_name) \ + .filter_by(host=host) \ .filter_by(binary=binary) \ .filter_by(deleted=False) \ .one() except exc.NoResultFound: - raise exception.NotFound("No model for %s, %s" % (node_name, + raise exception.NotFound("No model for %s, %s" % (host, binary)) else: with managed_session() as sess: - return cls.find_by_args(node_name, binary, session=sess) + return cls.find_by_args(host, binary, session=sess) -class Instance(Base, NovaBase): +class Instance(BASE, NovaBase): + """Represents a guest vm""" __tablename__ = 'instances' __prefix__ = 'i' id = Column(Integer, primary_key=True) @@ -191,6 +204,9 @@ class Instance(Base, NovaBase): image_id = Column(Integer, ForeignKey('images.id'), nullable=True) kernel_id = Column(Integer, ForeignKey('images.id'), nullable=True) ramdisk_id = Column(Integer, ForeignKey('images.id'), nullable=True) +# ramdisk = relationship(Ramdisk, backref=backref('instances', order_by=id)) +# kernel = relationship(Kernel, backref=backref('instances', order_by=id)) +# project = relationship(Project, backref=backref('instances', order_by=id)) launch_index = Column(Integer) key_name = Column(String(255)) @@ -201,7 +217,7 @@ class Instance(Base, NovaBase): state_description = Column(String(255)) hostname = Column(String(255)) - node_name = Column(String(255)) # , ForeignKey('physical_node.id')) + host = Column(String(255), ForeignKey('hosts.id')) instance_type = Column(Integer) @@ -211,17 +227,17 @@ class Instance(Base, NovaBase): mac_address = Column(String(255)) def set_state(self, state_code, state_description=None): - # TODO(devcamcar): Move this out of models and into api + """Set the code and description of an instance""" + # TODO(devcamcar): Move this out of models and into driver from nova.compute import power_state self.state = state_code if not state_description: state_description = power_state.name(state_code) self.state_description = state_description self.save() -# ramdisk = relationship(Ramdisk, backref=backref('instances', order_by=id)) -# kernel = relationship(Kernel, backref=backref('instances', order_by=id)) -# project = relationship(Project, backref=backref('instances', order_by=id)) -#TODO - see Ewan's email about state improvements + + # TODO(vish): see Ewan's email about state improvements, probably + # should be in a driver base class or some such # vmstate_state = running, halted, suspended, paused # power_state = what we have # task_state = transitory and may trigger power state transition @@ -232,7 +248,8 @@ class Instance(Base, NovaBase): # 'shutdown', 'shutoff', 'crashed']) -class Volume(Base, NovaBase): +class Volume(BASE, NovaBase): + """Represents a block storage device that can be attached to a vm""" __tablename__ = 'volumes' __prefix__ = 'vol' id = Column(Integer, primary_key=True) @@ -240,7 +257,7 @@ class Volume(Base, NovaBase): user_id = Column(String(255)) project_id = Column(String(255)) - node_name = Column(String(255)) # , ForeignKey('physical_node.id')) + host = Column(String(255), ForeignKey('hosts.id')) size = Column(Integer) availability_zone = Column(String(255)) # TODO(vish): foreign key? instance_id = Column(Integer, ForeignKey('instances.id'), nullable=True) @@ -250,7 +267,8 @@ class Volume(Base, NovaBase): attach_status = Column(String(255)) # TODO(vish): enum -class ExportDevice(Base, NovaBase): +class ExportDevice(BASE, NovaBase): + """Represates a shelf and blade that a volume can be exported on""" __tablename__ = 'export_devices' id = Column(Integer, primary_key=True) shelf_id = Column(Integer) @@ -260,7 +278,8 @@ class ExportDevice(Base, NovaBase): uselist=False)) -class Network(Base, NovaBase): +class Network(BASE, NovaBase): + """Represents a network""" __tablename__ = 'networks' id = Column(Integer, primary_key=True) @@ -279,10 +298,16 @@ class Network(Base, NovaBase): dhcp_start = Column(String(255)) project_id = Column(String(255)) - node_name = Column(String(255)) # , ForeignKey('physical_node.id')) + host = Column(String(255), ForeignKey('hosts.id')) -class NetworkIndex(Base, NovaBase): +class NetworkIndex(BASE, NovaBase): + """Represents a unique offset for a network + + Currently vlan number, vpn port, and fixed ip ranges are keyed off of + this index. These may ultimately need to be converted to separate + pools. + """ __tablename__ = 'network_indexes' id = Column(Integer, primary_key=True) index = Column(Integer) @@ -292,7 +317,8 @@ class NetworkIndex(Base, NovaBase): # TODO(vish): can these both come from the same baseclass? -class FixedIp(Base, NovaBase): +class FixedIp(BASE, NovaBase): + """Represents a fixed ip for an instance""" __tablename__ = 'fixed_ips' id = Column(Integer, primary_key=True) address = Column(String(255)) @@ -324,7 +350,8 @@ class FixedIp(Base, NovaBase): return cls.find_by_str(str_id, session=sess) -class FloatingIp(Base, NovaBase): +class FloatingIp(BASE, NovaBase): + """Represents a floating ip that dynamically forwards to a fixed ip""" __tablename__ = 'floating_ips' id = Column(Integer, primary_key=True) address = Column(String(255)) @@ -332,7 +359,7 @@ class FloatingIp(Base, NovaBase): fixed_ip = relationship(FixedIp, backref=backref('floating_ips')) project_id = Column(String(255)) - node_name = Column(String(255)) # , ForeignKey('physical_node.id')) + host = Column(String(255), ForeignKey('hosts.id')) @property def str_id(self): @@ -354,8 +381,9 @@ class FloatingIp(Base, NovaBase): def register_models(): + """Register Models and create metadata""" from sqlalchemy import create_engine - models = (Image, PhysicalNode, Daemon, Instance, Volume, ExportDevice, + models = (Image, Host, Daemon, Instance, Volume, ExportDevice, FixedIp, FloatingIp, Network, NetworkIndex) engine = create_engine(FLAGS.sql_connection, echo=False) for model in models: diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py index 8e459c9351d3..c34eb5da9af7 100644 --- a/nova/endpoint/cloud.py +++ b/nova/endpoint/cloud.py @@ -230,7 +230,7 @@ class CloudController(object): # instance_id is passed in as a list of instances instance_ref = db.instance_get_by_str(context, instance_id[0]) return rpc.call('%s.%s' % (FLAGS.compute_topic, - instance_ref['node_name']), + instance_ref['host']), {"method": "get_console_output", "args": {"context": None, "instance_id": instance_ref['id']}}) @@ -257,7 +257,7 @@ class CloudController(object): v['status'] = '%s (%s, %s, %s, %s)' % ( volume['status'], volume['user_id'], - 'node_name', + 'host', volume['instance_id'], volume['mountpoint']) if volume['attach_status'] == 'attached': @@ -391,7 +391,7 @@ class CloudController(object): if context.user.is_admin(): i['key_name'] = '%s (%s, %s)' % (i['key_name'], instance.project_id, - 'node_name') # FIXME + 'host') # FIXME i['product_codes_set'] = self._convert_to_set([], 'product_codes') i['instance_type'] = instance.instance_type i['launch_time'] = instance.created_at diff --git a/nova/flags.py b/nova/flags.py index a991798373f7..ebbfe3ff8fc4 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -206,7 +206,7 @@ DEFINE_integer('auth_token_ttl', 3600, 'Seconds for auth tokens to linger') # UNUSED DEFINE_string('node_availability_zone', 'nova', 'availability zone of this node') -DEFINE_string('node_name', socket.gethostname(), +DEFINE_string('host', socket.gethostname(), 'name of this node') DEFINE_string('sql_connection', diff --git a/nova/network/manager.py b/nova/network/manager.py index 9eeb4923d2e1..dbb8e66da91b 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -93,7 +93,7 @@ class NetworkManager(manager.Manager): network_id = network_ref['id'] host = self.db.network_set_host(context, network_id, - FLAGS.node_name) + FLAGS.host) self._on_set_network_host(context, network_id) return host @@ -117,7 +117,7 @@ class NetworkManager(manager.Manager): """Gets an floating ip from the pool""" # TODO(vish): add floating ips through manage command return self.db.floating_ip_allocate_address(context, - FLAGS.node_name, + FLAGS.host, project_id) def associate_floating_ip(self, context, floating_address, fixed_address): diff --git a/nova/service.py b/nova/service.py index 94d91f60a1e2..d39a5cf10b93 100644 --- a/nova/service.py +++ b/nova/service.py @@ -89,11 +89,11 @@ class Service(object, service.Service): proxy=service_ref) consumer_node = rpc.AdapterConsumer( connection=conn, - topic='%s.%s' % (topic, FLAGS.node_name), + topic='%s.%s' % (topic, FLAGS.host), proxy=service_ref) pulse = task.LoopingCall(service_ref.report_state, - FLAGS.node_name, + FLAGS.host, bin_name) pulse.start(interval=report_interval, now=False) @@ -107,14 +107,14 @@ class Service(object, service.Service): return application @defer.inlineCallbacks - def report_state(self, node_name, binary, context=None): + def report_state(self, host, binary, context=None): """Update the state of this daemon in the datastore.""" try: try: - daemon_ref = db.daemon_get_by_args(context, node_name, binary) + daemon_ref = db.daemon_get_by_args(context, host, binary) daemon_id = daemon_ref['id'] except exception.NotFound: - daemon_id = db.daemon_create(context, {'node_name': node_name, + daemon_id = db.daemon_create(context, {'host': host, 'binary': binary, 'report_count': 0}) daemon_ref = db.daemon_get(context, daemon_id) diff --git a/nova/tests/model_unittest.py b/nova/tests/model_unittest.py index dc2441c24c6d..130516c66441 100644 --- a/nova/tests/model_unittest.py +++ b/nova/tests/model_unittest.py @@ -108,14 +108,14 @@ class ModelTestCase(test.TrialTestCase): self.assertEqual(x.identifier, 'i-test') def test_instance_associates_node(self): - """create, then check that it is listed for the node_name""" + """create, then check that it is listed for the host""" instance = self.create_instance() found = False - for x in model.InstanceDirectory().by_node(FLAGS.node_name): + for x in model.InstanceDirectory().by_node(FLAGS.host): if x.identifier == 'i-test': found = True self.assertFalse(found) - instance['node_name'] = 'test_node' + instance['host'] = 'test_node' instance.save() for x in model.InstanceDirectory().by_node('test_node'): if x.identifier == 'i-test': diff --git a/nova/tests/network_unittest.py b/nova/tests/network_unittest.py index 7cd20dfcd9af..f3124c1ba7a2 100644 --- a/nova/tests/network_unittest.py +++ b/nova/tests/network_unittest.py @@ -91,7 +91,7 @@ class NetworkTestCase(test.TrialTestCase): try: db.floating_ip_get_by_address(None, ip_str) except exception.NotFound: - db.floating_ip_create(None, ip_str, FLAGS.node_name) + db.floating_ip_create(None, ip_str, FLAGS.host) float_addr = self.network.allocate_floating_ip(self.context, self.projects[0].id) fix_addr = self._create_address(0) diff --git a/nova/tests/service_unittest.py b/nova/tests/service_unittest.py index 902f9bab1fc6..318abe645499 100644 --- a/nova/tests/service_unittest.py +++ b/nova/tests/service_unittest.py @@ -58,7 +58,7 @@ class ServiceTestCase(test.BaseTestCase): rpc.AdapterConsumer) rpc.AdapterConsumer(connection=mox.IgnoreArg(), - topic='fake.%s' % FLAGS.node_name, + topic='fake.%s' % FLAGS.host, proxy=mox.IsA(service.Service)).AndReturn( rpc.AdapterConsumer) @@ -82,37 +82,37 @@ class ServiceTestCase(test.BaseTestCase): # 'model_disconnected' and report_state doesn't really do much so this # these are mostly just for coverage def test_report_state(self): - node_name = 'foo' + host = 'foo' binary = 'bar' - daemon_ref = {'node_name': node_name, + daemon_ref = {'host': host, 'binary': binary, 'report_count': 0, 'id': 1} service.db.__getattr__('report_state') service.db.daemon_get_by_args(None, - node_name, + host, binary).AndReturn(daemon_ref) service.db.daemon_update(None, daemon_ref['id'], mox.ContainsKeyValue('report_count', 1)) self.mox.ReplayAll() s = service.Service() - rv = yield s.report_state(node_name, binary) + rv = yield s.report_state(host, binary) def test_report_state_no_daemon(self): - node_name = 'foo' + host = 'foo' binary = 'bar' - daemon_create = {'node_name': node_name, + daemon_create = {'host': host, 'binary': binary, 'report_count': 0} - daemon_ref = {'node_name': node_name, + daemon_ref = {'host': host, 'binary': binary, 'report_count': 0, 'id': 1} service.db.__getattr__('report_state') service.db.daemon_get_by_args(None, - node_name, + host, binary).AndRaise(exception.NotFound()) service.db.daemon_create(None, daemon_create).AndReturn(daemon_ref['id']) @@ -122,38 +122,38 @@ class ServiceTestCase(test.BaseTestCase): self.mox.ReplayAll() s = service.Service() - rv = yield s.report_state(node_name, binary) + rv = yield s.report_state(host, binary) def test_report_state_newly_disconnected(self): - node_name = 'foo' + host = 'foo' binary = 'bar' - daemon_ref = {'node_name': node_name, + daemon_ref = {'host': host, 'binary': binary, 'report_count': 0, 'id': 1} service.db.__getattr__('report_state') service.db.daemon_get_by_args(None, - node_name, + host, binary).AndRaise(Exception()) self.mox.ReplayAll() s = service.Service() - rv = yield s.report_state(node_name, binary) + rv = yield s.report_state(host, binary) self.assert_(s.model_disconnected) def test_report_state_newly_connected(self): - node_name = 'foo' + host = 'foo' binary = 'bar' - daemon_ref = {'node_name': node_name, + daemon_ref = {'host': host, 'binary': binary, 'report_count': 0, 'id': 1} service.db.__getattr__('report_state') service.db.daemon_get_by_args(None, - node_name, + host, binary).AndReturn(daemon_ref) service.db.daemon_update(None, daemon_ref['id'], mox.ContainsKeyValue('report_count', 1)) @@ -161,6 +161,6 @@ class ServiceTestCase(test.BaseTestCase): self.mox.ReplayAll() s = service.Service() s.model_disconnected = True - rv = yield s.report_state(node_name, binary) + rv = yield s.report_state(host, binary) self.assert_(not s.model_disconnected) diff --git a/nova/volume/manager.py b/nova/volume/manager.py index 94d2f7d703e4..e5f4805a1c3d 100644 --- a/nova/volume/manager.py +++ b/nova/volume/manager.py @@ -78,7 +78,7 @@ class AOEManager(manager.Manager): self.db.volume_update(context, volume_id, - {'node_name': FLAGS.node_name}) + {'host': FLAGS.host}) size = volume_ref['size'] logging.debug("volume %s: creating lv of size %sG", volume_id, size) @@ -111,7 +111,7 @@ class AOEManager(manager.Manager): volume_ref = self.db.volume_get(context, volume_id) if volume_ref['attach_status'] == "attached": raise exception.Error("Volume is still attached") - if volume_ref['node_name'] != FLAGS.node_name: + if volume_ref['host'] != FLAGS.host: raise exception.Error("Volume is not local to this node") shelf_id, blade_id = self.db.volume_get_shelf_and_blade(context, volume_id)