summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorNaveed Massjouni <naveedm9@gmail.com>2011-09-12 12:53:56 -0400
committerNaveed Massjouni <naveedm9@gmail.com>2011-09-12 12:53:56 -0400
commitcc9e254d9f28c12abe555b2ddad92ccc533bc547 (patch)
treefb7db71769733245ebc15236b924d09fce8e7f2f /nova
parent0a8ea633b56fece6280b2ff6752e544d99d4b301 (diff)
parent8e4cb45399ea4203bcc81d5c67e8197b482a1f8a (diff)
Merge from trunk
Diffstat (limited to 'nova')
-rw-r--r--nova/db/api.py6
-rw-r--r--nova/db/sqlalchemy/api.py9
-rw-r--r--nova/network/manager.py3
-rw-r--r--nova/tests/test_network.py3
-rw-r--r--nova/virt/disk.py17
5 files changed, 24 insertions, 14 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index c03a86671..a9d2dc065 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -324,13 +324,15 @@ def migration_get_by_instance_and_status(context, instance_uuid, status):
####################
-def fixed_ip_associate(context, address, instance_id, network_id=None):
+def fixed_ip_associate(context, address, instance_id, network_id=None,
+ reserved=False):
"""Associate fixed ip to instance.
Raises if fixed ip is not available.
"""
- return IMPL.fixed_ip_associate(context, address, instance_id, network_id)
+ return IMPL.fixed_ip_associate(context, address, instance_id, network_id,
+ reserved)
def fixed_ip_associate_pool(context, network_id, instance_id=None, host=None):
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 523258841..40e2ca167 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -669,14 +669,19 @@ def floating_ip_update(context, address, values):
@require_admin_context
-def fixed_ip_associate(context, address, instance_id, network_id=None):
+def fixed_ip_associate(context, address, instance_id, network_id=None,
+ reserved=False):
+ """Keyword arguments:
+ reserved -- should be a boolean value(True or False), exact value will be
+ used to filter on the fixed ip address
+ """
session = get_session()
with session.begin():
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).\
+ filter_by(reserved=reserved).\
filter_by(deleted=False).\
filter_by(address=address).\
with_lockmode('update').\
diff --git a/nova/network/manager.py b/nova/network/manager.py
index 05d928fab..da360720b 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -1005,7 +1005,8 @@ class VlanManager(RPCAllocateFixedIP, FloatingIP, NetworkManager):
address = network['vpn_private_address']
self.db.fixed_ip_associate(context,
address,
- instance_id)
+ instance_id,
+ reserved=True)
else:
address = kwargs.get('address', None)
if address:
diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py
index c947bbc58..926ea065a 100644
--- a/nova/tests/test_network.py
+++ b/nova/tests/test_network.py
@@ -286,7 +286,8 @@ class VlanNetworkTestCase(test.TestCase):
db.fixed_ip_associate(mox.IgnoreArg(),
mox.IgnoreArg(),
- mox.IgnoreArg()).AndReturn('192.168.0.1')
+ mox.IgnoreArg(),
+ reserved=True).AndReturn('192.168.0.1')
db.fixed_ip_update(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg())
diff --git a/nova/virt/disk.py b/nova/virt/disk.py
index 52b2881e8..12a2cea45 100644
--- a/nova/virt/disk.py
+++ b/nova/virt/disk.py
@@ -58,7 +58,7 @@ def extend(image, size):
file_size = os.path.getsize(image)
if file_size >= size:
return
- utils.execute('truncate', '-s', size, image)
+ utils.execute('qemu-img', 'resize', image, size)
# NOTE(vish): attempts to resize filesystem
utils.execute('e2fsck', '-fp', image, check_exit_code=False)
utils.execute('resize2fs', image, check_exit_code=False)
@@ -148,16 +148,17 @@ def destroy_container(target, instance, nbd=False):
LXC does not support qcow2 images yet.
"""
+ out, err = utils.execute('mount', run_as_root=True)
+ for loop in out.splitlines():
+ if instance['name'] in loop:
+ device = loop.split()[0]
+
try:
container_dir = '%s/rootfs' % target
utils.execute('umount', container_dir, run_as_root=True)
- finally:
- out, err = utils.execute('losetup', '-a', run_as_root=True)
- for loop in out.splitlines():
- if instance['name'] in loop:
- device = loop.split(loop, ':')
- _unlink_device(device, nbd)
-
+ _unlink_device(device, nbd)
+ except Exception, exn:
+ LOG.exception(_('Failed to remove container: %s'), exn)
def _link_device(image, nbd):
"""Link image to device using loopback or nbd"""