summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-08-30 20:42:31 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-08-30 20:42:31 -0700
commit4374bef0536846afe9be1156b340b34e6d4c8d2d (patch)
tree8adc26124576c7124bee38c30a1f7ab90b6ee2dd
parent73c7bbce87e72b5223f11c194ff41d2da1df5c86 (diff)
downloadnova-4374bef0536846afe9be1156b340b34e6d4c8d2d.tar.gz
nova-4374bef0536846afe9be1156b340b34e6d4c8d2d.tar.xz
nova-4374bef0536846afe9be1156b340b34e6d4c8d2d.zip
more cleanup and pylint fixes
-rw-r--r--nova/auth/manager.py2
-rw-r--r--nova/db/api.py4
-rw-r--r--nova/db/sqlalchemy/api.py33
-rw-r--r--nova/db/sqlalchemy/models.py86
-rw-r--r--nova/network/linux_net.py5
-rw-r--r--nova/tests/network_unittest.py1
-rw-r--r--nova/virt/libvirt_conn.py41
-rw-r--r--nova/volume/driver.py76
-rw-r--r--nova/volume/manager.py21
9 files changed, 149 insertions, 120 deletions
diff --git a/nova/auth/manager.py b/nova/auth/manager.py
index 62ec3f4e4..d5fbec7c5 100644
--- a/nova/auth/manager.py
+++ b/nova/auth/manager.py
@@ -574,7 +574,7 @@ class AuthManager(object):
if not network_ref['vpn_public_port']:
raise exception.NotFound('project network data has not been set')
- return (network_ref['vpn_public_ip_str'],
+ return (network_ref['vpn_public_address'],
network_ref['vpn_public_port'])
def delete_project(self, project, context=None):
diff --git a/nova/db/api.py b/nova/db/api.py
index 9b8c48934..d95d1ce6e 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -128,9 +128,9 @@ def fixed_ip_allocate(context, network_id):
return _impl.fixed_ip_allocate(context, network_id)
-def fixed_ip_create(context, network_id, address, reserved=False):
+def fixed_ip_create(context, values):
"""Create a fixed ip from the values dictionary."""
- return _impl.fixed_ip_create(context, network_id, address, reserved)
+ return _impl.fixed_ip_create(context, values)
def fixed_ip_deallocate(context, address):
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index e366e989f..b00ad19ff 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -21,6 +21,7 @@ from nova import exception
from nova import flags
from nova.db.sqlalchemy import models
from nova.db.sqlalchemy.session import managed_session
+from sqlalchemy import or_
FLAGS = flags.FLAGS
@@ -37,7 +38,9 @@ def daemon_get_by_args(context, node_name, binary):
def daemon_create(context, values):
- daemon_ref = models.Daemon(**values)
+ daemon_ref = models.Daemon()
+ for (key, value) in values.iteritems():
+ daemon_ref[key] = value
daemon_ref.save()
return daemon_ref.id
@@ -67,12 +70,12 @@ def floating_ip_allocate_address(context, node_name, project_id):
floating_ip_ref['project_id'] = project_id
session.add(floating_ip_ref)
session.commit()
- return floating_ip_ref['str_id']
+ return floating_ip_ref['address']
def floating_ip_create(context, address, host):
floating_ip_ref = models.FloatingIp()
- floating_ip_ref['ip_str'] = address
+ floating_ip_ref['address'] = address
floating_ip_ref['node_name'] = host
floating_ip_ref.save()
return floating_ip_ref
@@ -95,7 +98,7 @@ def floating_ip_disassociate(context, address):
session=session)
fixed_ip_ref = floating_ip_ref.fixed_ip
if fixed_ip_ref:
- fixed_ip_address = fixed_ip_ref['str_id']
+ fixed_ip_address = fixed_ip_ref['address']
else:
fixed_ip_address = None
floating_ip_ref.fixed_ip = None
@@ -128,8 +131,10 @@ 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)
fixed_ip_ref = session.query(models.FixedIp) \
- .filter_by(network_id=network_id) \
+ .filter(network_or_none) \
.filter_by(reserved=False) \
.filter_by(allocated=False) \
.filter_by(leased=False) \
@@ -140,19 +145,20 @@ def fixed_ip_allocate(context, network_id):
# then this has concurrency issues
if not fixed_ip_ref:
raise db.NoMoreAddresses()
+ if not fixed_ip_ref.network:
+ fixed_ip_ref.network = models.Network.find(network_id)
fixed_ip_ref['allocated'] = True
session.add(fixed_ip_ref)
session.commit()
- return fixed_ip_ref['str_id']
+ return fixed_ip_ref['address']
-def fixed_ip_create(context, network_id, address, reserved=False):
+def fixed_ip_create(context, values):
fixed_ip_ref = models.FixedIp()
- fixed_ip_ref.network = db.network_get(context, network_id)
- fixed_ip_ref['ip_str'] = address
- fixed_ip_ref['reserved'] = reserved
+ for (key, value) in values.iteritems():
+ fixed_ip_ref[key] = value
fixed_ip_ref.save()
- return fixed_ip_ref
+ return fixed_ip_ref['address']
def fixed_ip_get_by_address(context, address):
@@ -248,7 +254,7 @@ def instance_get_fixed_address(context, instance_id):
instance_ref = models.Instance.find(instance_id, session=session)
if not instance_ref.fixed_ip:
return None
- return instance_ref.fixed_ip['str_id']
+ return instance_ref.fixed_ip['address']
def instance_get_floating_address(context, instance_id):
@@ -259,7 +265,7 @@ def instance_get_floating_address(context, instance_id):
if not instance_ref.fixed_ip.floating_ips:
return None
# NOTE(vish): this just returns the first floating ip
- return instance_ref.fixed_ip.floating_ips[0]['str_id']
+ return instance_ref.fixed_ip.floating_ips[0]['address']
def instance_get_host(context, instance_id):
@@ -325,7 +331,6 @@ def network_create(context, values):
network_ref[key] = value
network_ref.save()
return network_ref
- return network_ref.id
def network_destroy(context, network_id):
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 53aa1f469..b9ed34bb1 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -260,12 +260,44 @@ class ExportDevice(Base, NovaBase):
uselist=False))
+class Network(Base, NovaBase):
+ __tablename__ = 'networks'
+ id = Column(Integer, primary_key=True)
+
+ injected = Column(Boolean, default=False)
+ cidr = Column(String(255))
+ netmask = Column(String(255))
+ bridge = Column(String(255))
+ gateway = Column(String(255))
+ broadcast = Column(String(255))
+ dns = Column(String(255))
+
+ vlan = Column(Integer)
+ vpn_public_address = Column(String(255))
+ vpn_public_port = Column(Integer)
+ vpn_private_address = Column(String(255))
+ dhcp_start = Column(String(255))
+
+ project_id = Column(String(255))
+ node_name = Column(String(255)) # , ForeignKey('physical_node.id'))
+
+
+class NetworkIndex(Base, NovaBase):
+ __tablename__ = 'network_indexes'
+ id = Column(Integer, primary_key=True)
+ index = Column(Integer)
+ network_id = Column(Integer, ForeignKey('networks.id'), nullable=True)
+ network = relationship(Network, backref=backref('network_index',
+ uselist=False))
+
+
# TODO(vish): can these both come from the same baseclass?
class FixedIp(Base, NovaBase):
__tablename__ = 'fixed_ips'
id = Column(Integer, primary_key=True)
- ip_str = Column(String(255))
- network_id = Column(Integer, ForeignKey('networks.id'), nullable=False)
+ address = Column(String(255))
+ network_id = Column(Integer, ForeignKey('networks.id'), nullable=True)
+ network = relationship(Network, backref=backref('fixed_ips'))
instance_id = Column(Integer, ForeignKey('instances.id'), nullable=True)
instance = relationship(Instance, backref=backref('fixed_ip',
uselist=False))
@@ -275,18 +307,18 @@ class FixedIp(Base, NovaBase):
@property
def str_id(self):
- return self.ip_str
+ return self.address
@classmethod
def find_by_str(cls, str_id, session=None):
if session:
try:
return session.query(cls) \
- .filter_by(ip_str=str_id) \
+ .filter_by(address=str_id) \
.filter_by(deleted=False) \
.one()
except exc.NoResultFound:
- raise exception.NotFound("No model for ip_str %s" % str_id)
+ raise exception.NotFound("No model for address %s" % str_id)
else:
with managed_session() as sess:
return cls.find_by_str(str_id, session=sess)
@@ -295,7 +327,7 @@ class FixedIp(Base, NovaBase):
class FloatingIp(Base, NovaBase):
__tablename__ = 'floating_ips'
id = Column(Integer, primary_key=True)
- ip_str = Column(String(255))
+ address = Column(String(255))
fixed_ip_id = Column(Integer, ForeignKey('fixed_ips.id'), nullable=True)
fixed_ip = relationship(FixedIp, backref=backref('floating_ips'))
@@ -304,59 +336,23 @@ class FloatingIp(Base, NovaBase):
@property
def str_id(self):
- return self.ip_str
+ return self.address
@classmethod
def find_by_str(cls, str_id, session=None):
if session:
try:
return session.query(cls) \
- .filter_by(ip_str=str_id) \
+ .filter_by(address=str_id) \
.filter_by(deleted=False) \
.one()
except exc.NoResultFound:
- raise exception.NotFound("No model for ip_str %s" % str_id)
+ raise exception.NotFound("No model for address %s" % str_id)
else:
with managed_session() as sess:
return cls.find_by_str(str_id, session=sess)
-class Network(Base, NovaBase):
- __tablename__ = 'networks'
- id = Column(Integer, primary_key=True)
-
- injected = Column(Boolean, default=False)
- cidr = Column(String(255))
- netmask = Column(String(255))
- bridge = Column(String(255))
- gateway = Column(String(255))
- broadcast = Column(String(255))
- dns = Column(String(255))
-
- vlan = Column(Integer)
- vpn_public_ip_str = Column(String(255))
- vpn_public_port = Column(Integer)
- vpn_private_ip_str = Column(String(255))
- dhcp_start = Column(String(255))
-
- project_id = Column(String(255))
- node_name = Column(String(255)) # , ForeignKey('physical_node.id'))
-
- fixed_ips = relationship(FixedIp,
- single_parent=True,
- backref=backref('network'),
- cascade='all, delete, delete-orphan')
-
-
-class NetworkIndex(Base, NovaBase):
- __tablename__ = 'network_indexes'
- id = Column(Integer, primary_key=True)
- index = Column(Integer)
- network_id = Column(Integer, ForeignKey('networks.id'), nullable=True)
- network = relationship(Network, backref=backref('network_index',
- uselist=False))
-
-
def register_models():
from sqlalchemy import create_engine
models = (Image, PhysicalNode, Daemon, Instance, Volume, ExportDevice,
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index 6114e4ffe..1506e85ad 100644
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -99,6 +99,7 @@ def ensure_vlan_bridge(vlan_num, bridge, net_attrs=None):
def ensure_vlan(vlan_num):
+ """Create a vlan unless it already exists"""
interface = "vlan%s" % vlan_num
if not _device_exists(interface):
logging.debug("Starting VLAN inteface %s", interface)
@@ -109,6 +110,7 @@ def ensure_vlan(vlan_num):
def ensure_bridge(bridge, interface, net_attrs=None):
+ """Create a bridge unless it already exists"""
if not _device_exists(bridge):
logging.debug("Starting Bridge inteface for %s", interface)
_execute("sudo brctl addbr %s" % bridge)
@@ -128,6 +130,7 @@ def ensure_bridge(bridge, interface, net_attrs=None):
def get_dhcp_hosts(context, network_id):
+ """Get a string containing a network's hosts config in dnsmasq format"""
hosts = []
for fixed_ip in db.network_get_associated_fixed_ips(context, network_id):
hosts.append(_host_dhcp(fixed_ip['str_id']))
@@ -158,7 +161,7 @@ def update_dhcp(context, network_id):
try:
os.kill(pid, signal.SIGHUP)
return
- except Exception as exc: # pylint: disable=W0703
+ except Exception as exc: # pylint: disable-msg=W0703
logging.debug("Hupping dnsmasq threw %s", exc)
# FLAGFILE and DNSMASQ_INTERFACE in env
diff --git a/nova/tests/network_unittest.py b/nova/tests/network_unittest.py
index 15ec8dbf4..fccfc23fb 100644
--- a/nova/tests/network_unittest.py
+++ b/nova/tests/network_unittest.py
@@ -28,7 +28,6 @@ from nova import flags
from nova import test
from nova import utils
from nova.auth import manager
-from nova.network import service
FLAGS = flags.FLAGS
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py
index 823eb1e0b..b353fc44b 100644
--- a/nova/virt/libvirt_conn.py
+++ b/nova/virt/libvirt_conn.py
@@ -126,7 +126,7 @@ class LibvirtConnection(object):
def destroy(self, instance):
try:
- virt_dom = self._conn.lookupByName(instance.name)
+ virt_dom = self._conn.lookupByName(instance['name'])
virt_dom.destroy()
except Exception as _err:
pass
@@ -140,7 +140,7 @@ class LibvirtConnection(object):
timer = task.LoopingCall(f=None)
def _wait_for_shutdown():
try:
- instance.set_state(self.get_info(instance.name)['state'])
+ instance.set_state(self.get_info(instance['name'])['state'])
if instance.state == power_state.SHUTDOWN:
timer.stop()
d.callback(None)
@@ -153,7 +153,7 @@ class LibvirtConnection(object):
return d
def _cleanup(self, instance):
- target = os.path.join(FLAGS.instances_path, instance.name)
+ target = os.path.join(FLAGS.instances_path, instance['name'])
logging.info("Deleting instance files at %s", target)
if os.path.exists(target):
shutil.rmtree(target)
@@ -162,20 +162,20 @@ class LibvirtConnection(object):
@exception.wrap_exception
def reboot(self, instance):
xml = self.to_xml(instance)
- yield self._conn.lookupByName(instance.name).destroy()
+ yield self._conn.lookupByName(instance['name']).destroy()
yield self._conn.createXML(xml, 0)
d = defer.Deferred()
timer = task.LoopingCall(f=None)
def _wait_for_reboot():
try:
- instance.set_state(self.get_info(instance.name)['state'])
+ instance.set_state(self.get_info(instance['name'])['state'])
if instance.state == power_state.RUNNING:
- logging.debug('rebooted instance %s' % instance.name)
+ logging.debug('rebooted instance %s' % instance['name'])
timer.stop()
d.callback(None)
except Exception, exn:
- logging.error('_wait_for_reboot failed: %s' % exn)
+ logging.error('_wait_for_reboot failed: %s', exn)
instance.set_state(power_state.SHUTDOWN)
timer.stop()
d.callback(None)
@@ -198,13 +198,14 @@ class LibvirtConnection(object):
timer = task.LoopingCall(f=None)
def _wait_for_boot():
try:
- instance.set_state(self.get_info(instance.name)['state'])
+ instance.set_state(self.get_info(instance['name'])['state'])
if instance.state == power_state.RUNNING:
- logging.debug('booted instance %s' % instance.name)
+ logging.debug('booted instance %s', instance['name'])
timer.stop()
local_d.callback(None)
except:
- logging.exception('Failed to boot instance %s' % instance.name)
+ logging.exception('Failed to boot instance %s',
+ instance['name'])
instance.set_state(power_state.SHUTDOWN)
timer.stop()
local_d.callback(None)
@@ -215,7 +216,9 @@ class LibvirtConnection(object):
@defer.inlineCallbacks
def _create_image(self, inst, libvirt_xml):
# syntactic nicety
- basepath = lambda x='': os.path.join(FLAGS.instances_path, inst.name, x)
+ basepath = lambda fname='': os.path.join(FLAGS.instances_path,
+ inst['name'],
+ fname)
# ensure directories exist and are writable
yield process.simple_execute('mkdir -p %s' % basepath())
@@ -224,7 +227,7 @@ class LibvirtConnection(object):
# TODO(termie): these are blocking calls, it would be great
# if they weren't.
- logging.info('Creating image for: %s', inst.name)
+ logging.info('Creating image for: %s', inst['name'])
f = open(basepath('libvirt.xml'), 'w')
f.write(libvirt_xml)
f.close()
@@ -245,10 +248,11 @@ class LibvirtConnection(object):
key = inst.key_data
net = None
- network_ref = db.project_get_network(None, project.id) # FIXME
+ network_ref = db.project_get_network(None, project.id)
if network_ref['injected']:
+ address = db.instance_get_fixed_address(None, inst['id'])
with open(FLAGS.injected_network_template) as f:
- net = f.read() % {'address': inst.fixed_ip['ip_str'], # FIXME
+ net = f.read() % {'address': address,
'network': network_ref['network'],
'netmask': network_ref['netmask'],
'gateway': network_ref['gateway'],
@@ -269,12 +273,13 @@ class LibvirtConnection(object):
def to_xml(self, instance):
# TODO(termie): cache?
logging.debug("Starting the toXML method")
- network = db.project_get_network(None, instance['project_id']) # FIXME
+ network = db.project_get_network(None, instance['project_id'])
# FIXME(vish): stick this in db
- instance_type = instance_types.INSTANCE_TYPES[instance.instance_type]
+ instance_type = instance_types.INSTANCE_TYPES[instance['instance_type']]
xml_info = {'type': FLAGS.libvirt_type,
- 'name': instance.name,
- 'basepath': os.path.join(FLAGS.instances_path, instance.name),
+ 'name': instance['name'],
+ 'basepath': os.path.join(FLAGS.instances_path,
+ instance['name']),
'memory_kb': instance_type['memory_mb'] * 1024,
'vcpus': instance_type['vcpus'],
'bridge_name': network['bridge'],
diff --git a/nova/volume/driver.py b/nova/volume/driver.py
index 990bfe958..e82449b27 100644
--- a/nova/volume/driver.py
+++ b/nova/volume/driver.py
@@ -35,36 +35,16 @@ flags.DEFINE_string('aoe_eth_dev', 'eth0',
'Which device to export the volumes on')
-class FakeAOEDriver(object):
- def create_volume(self, volume_id, size):
- logging.debug("Fake AOE: create_volume %s, %s", volume_id, size)
-
- def delete_volume(self, volume_id):
- logging.debug("Fake AOE: delete_volume %s", volume_id)
-
- def create_export(self, volume_id, shelf_id, blade_id):
- logging.debug("Fake AOE: create_export %s, %s, %s",
- volume_id, shelf_id, blade_id)
-
- def remove_export(self, volume_id, shelf_id, blade_id):
- logging.debug("Fake AOE: remove_export %s, %s, %s",
- volume_id, shelf_id, blade_id)
-
- def ensure_exports(self):
- logging.debug("Fake AOE: ensure_export")
-
class AOEDriver(object):
- def __init__(self, *args, **kwargs):
- super(AOEDriver, self).__init__(*args, **kwargs)
+ """Executes commands relating to AOE volumes"""
@defer.inlineCallbacks
- def _ensure_vg(self):
+ @staticmethod
+ def create_volume(volume_id, size):
+ """Creates a logical volume"""
+ # NOTE(vish): makes sure that the volume group exists
yield process.simple_execute("vgs | grep %s" % FLAGS.volume_group)
-
- @defer.inlineCallbacks
- def create_volume(self, volume_id, size):
- self._ensure_vg()
if int(size) == 0:
sizestr = '100M'
else:
@@ -76,14 +56,18 @@ class AOEDriver(object):
terminate_on_stderr=False)
@defer.inlineCallbacks
- def delete_volume(self, volume_id):
+ @staticmethod
+ def delete_volume(volume_id):
+ """Deletes a logical volume"""
yield process.simple_execute(
"sudo lvremove -f %s/%s" % (FLAGS.volume_group,
volume_id),
terminate_on_stderr=False)
@defer.inlineCallbacks
- def create_export(self, volume_id, shelf_id, blade_id):
+ @staticmethod
+ def create_export(volume_id, shelf_id, blade_id):
+ """Creates an export for a logical volume"""
yield process.simple_execute(
"sudo vblade-persist setup %s %s %s /dev/%s/%s" %
(shelf_id,
@@ -94,7 +78,9 @@ class AOEDriver(object):
terminate_on_stderr=False)
@defer.inlineCallbacks
- def remove_export(self, _volume_id, shelf_id, blade_id):
+ @staticmethod
+ def remove_export(_volume_id, shelf_id, blade_id):
+ """Removes an export for a logical volume"""
yield process.simple_execute(
"sudo vblade-persist stop %s %s" % (shelf_id, blade_id),
terminate_on_stderr=False)
@@ -103,10 +89,42 @@ class AOEDriver(object):
terminate_on_stderr=False)
@defer.inlineCallbacks
- def ensure_exports(self):
+ @staticmethod
+ def ensure_exports():
+ """Runs all existing exports"""
# NOTE(ja): wait for blades to appear
yield process.simple_execute("sleep 5")
yield process.simple_execute("sudo vblade-persist auto all",
check_exit_code=False)
yield process.simple_execute("sudo vblade-persist start all",
check_exit_code=False)
+
+
+class FakeAOEDriver(AOEDriver):
+ """Logs calls instead of executing"""
+ @staticmethod
+ def create_volume(volume_id, size):
+ """Creates a logical volume"""
+ logging.debug("Fake AOE: create_volume %s, %s", volume_id, size)
+
+ @staticmethod
+ def delete_volume(volume_id):
+ """Deletes a logical volume"""
+ logging.debug("Fake AOE: delete_volume %s", volume_id)
+
+ @staticmethod
+ def create_export(volume_id, shelf_id, blade_id):
+ """Creates an export for a logical volume"""
+ logging.debug("Fake AOE: create_export %s, %s, %s",
+ volume_id, shelf_id, blade_id)
+
+ @staticmethod
+ def remove_export(volume_id, shelf_id, blade_id):
+ """Removes an export for a logical volume"""
+ logging.debug("Fake AOE: remove_export %s, %s, %s",
+ volume_id, shelf_id, blade_id)
+
+ @staticmethod
+ def ensure_exports():
+ """Runs all existing exports"""
+ logging.debug("Fake AOE: ensure_export")
diff --git a/nova/volume/manager.py b/nova/volume/manager.py
index c57c920c9..ad5aa22a2 100644
--- a/nova/volume/manager.py
+++ b/nova/volume/manager.py
@@ -48,6 +48,7 @@ flags.DEFINE_integer('blades_per_shelf',
class AOEManager(manager.Manager):
+ """Manages Ata-Over_Ethernet volumes"""
def __init__(self, volume_driver=None, *args, **kwargs):
if not volume_driver:
# NOTE(vish): support the legacy fake storage flag
@@ -59,6 +60,7 @@ class AOEManager(manager.Manager):
super(AOEManager, self).__init__(*args, **kwargs)
def _ensure_blades(self, context):
+ """Ensure that blades have been created in datastore"""
total_blades = FLAGS.num_shelves * FLAGS.blades_per_shelf
if self.db.export_device_count(context) >= total_blades:
return
@@ -69,8 +71,8 @@ class AOEManager(manager.Manager):
@defer.inlineCallbacks
def create_volume(self, context, volume_id):
- """Creates and exports the volume."""
- logging.info("volume %s: creating" % (volume_id))
+ """Creates and exports the volume"""
+ logging.info("volume %s: creating", volume_id)
volume_ref = self.db.volume_get(context, volume_id)
@@ -79,15 +81,15 @@ class AOEManager(manager.Manager):
{'node_name': FLAGS.node_name})
size = volume_ref['size']
- logging.debug("volume %s: creating lv of size %sG" % (volume_id, size))
+ logging.debug("volume %s: creating lv of size %sG", volume_id, size)
yield self.driver.create_volume(volume_id, size)
- logging.debug("volume %s: allocating shelf & blade" % (volume_id))
+ logging.debug("volume %s: allocating shelf & blade", volume_id)
self._ensure_blades(context)
rval = self.db.volume_allocate_shelf_and_blade(context, volume_id)
(shelf_id, blade_id) = rval
- logging.debug("volume %s: exporting shelf %s & blade %s" % (volume_id,
+ logging.debug("volume %s: exporting shelf %s & blade %s", (volume_id,
shelf_id, blade_id))
yield self.driver.create_export(volume_id, shelf_id, blade_id)
@@ -96,15 +98,16 @@ class AOEManager(manager.Manager):
self.db.volume_update(context, volume_id, {'status': 'available'})
- logging.debug("volume %s: re-exporting all values" % (volume_id))
+ logging.debug("volume %s: re-exporting all values", volume_id)
yield self.driver.ensure_exports()
- logging.debug("volume %s: created successfully" % (volume_id))
+ logging.debug("volume %s: created successfully", volume_id)
defer.returnValue(volume_id)
@defer.inlineCallbacks
def delete_volume(self, context, volume_id):
- logging.debug("Deleting volume with id of: %s" % (volume_id))
+ """Deletes and unexports volume"""
+ logging.debug("Deleting volume with id of: %s", volume_id)
volume_ref = self.db.volume_get(context, volume_id)
if volume_ref['attach_status'] == "attached":
raise exception.Error("Volume is still attached")
@@ -113,6 +116,6 @@ class AOEManager(manager.Manager):
shelf_id, blade_id = self.db.volume_get_shelf_and_blade(context,
volume_id)
yield self.driver.remove_export(volume_id, shelf_id, blade_id)
- yield self.driver.delete_volume(volume_id)
+ yield self.driver.delete_volumevolume_id
self.db.volume_destroy(context, volume_id)
defer.returnValue(True)