summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Short <zulcss@ubuntu.com>2011-06-08 22:03:48 -0400
committerChuck Short <zulcss@ubuntu.com>2011-06-08 22:03:48 -0400
commit22ffa88cc7d030e915d3aac051dd540ab6ea70a5 (patch)
treeb3340a93c97fdbdbec55b0efa18bfc3013b9ebce
parent0c3c0ef6e0604e24ab3f2ec25554a867fe64bd45 (diff)
parent8ff87c649e13e21ba968ec85a1158230e8cf118d (diff)
downloadnova-22ffa88cc7d030e915d3aac051dd540ab6ea70a5.tar.gz
nova-22ffa88cc7d030e915d3aac051dd540ab6ea70a5.tar.xz
nova-22ffa88cc7d030e915d3aac051dd540ab6ea70a5.zip
Fix merge conflict
-rwxr-xr-xbin/nova-manage15
-rw-r--r--nova/api/direct.py2
-rw-r--r--nova/api/ec2/admin.py4
-rw-r--r--nova/api/ec2/cloud.py24
-rw-r--r--nova/api/openstack/extensions.py4
-rw-r--r--nova/api/openstack/views/limits.py9
-rw-r--r--nova/db/sqlalchemy/api.py20
-rw-r--r--nova/db/sqlalchemy/models.py1
-rw-r--r--nova/network/manager.py12
-rw-r--r--nova/tests/test_cloud.py67
-rw-r--r--nova/tests/test_libvirt.py90
-rw-r--r--nova/tests/xenapi/stubs.py18
-rw-r--r--nova/twistd.py6
-rw-r--r--nova/utils.py18
-rw-r--r--nova/virt/libvirt/connection.py6
-rw-r--r--nova/virt/xenapi/fake.py6
16 files changed, 197 insertions, 105 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index 1f8ccf268..4261a4a3a 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -96,6 +96,7 @@ flags.DECLARE('network_size', 'nova.network.manager')
flags.DECLARE('vlan_start', 'nova.network.manager')
flags.DECLARE('vpn_start', 'nova.network.manager')
flags.DECLARE('fixed_range_v6', 'nova.network.manager')
+flags.DECLARE('gateway_v6', 'nova.network.manager')
flags.DECLARE('images_path', 'nova.image.local')
flags.DECLARE('libvirt_type', 'nova.virt.libvirt.connection')
flags.DEFINE_flag(flags.HelpFlag())
@@ -545,13 +546,10 @@ class FloatingIpCommands(object):
class NetworkCommands(object):
"""Class for managing networks."""
- def create(self, fixed_range=None, num_networks=None,
- network_size=None, vlan_start=None,
- vpn_start=None, fixed_range_v6=None, label='public'):
- """Creates fixed ips for host by range
- arguments: fixed_range=FLAG, [num_networks=FLAG],
- [network_size=FLAG], [vlan_start=FLAG],
- [vpn_start=FLAG], [fixed_range_v6=FLAG]"""
+ def create(self, fixed_range=None, num_networks=None, network_size=None,
+ vlan_start=None, vpn_start=None, fixed_range_v6=None,
+ gateway_v6=None, label='public'):
+ """Creates fixed ips for host by range"""
if not fixed_range:
msg = _('Fixed range in the form of 10.0.0.0/8 is '
'required to create networks.')
@@ -567,6 +565,8 @@ class NetworkCommands(object):
vpn_start = FLAGS.vpn_start
if not fixed_range_v6:
fixed_range_v6 = FLAGS.fixed_range_v6
+ if not gateway_v6:
+ gateway_v6 = FLAGS.gateway_v6
net_manager = utils.import_object(FLAGS.network_manager)
try:
net_manager.create_networks(context.get_admin_context(),
@@ -576,6 +576,7 @@ class NetworkCommands(object):
vlan_start=int(vlan_start),
vpn_start=int(vpn_start),
cidr_v6=fixed_range_v6,
+ gateway_v6=gateway_v6,
label=label)
except ValueError, e:
print e
diff --git a/nova/api/direct.py b/nova/api/direct.py
index ea20042a7..ec79151b1 100644
--- a/nova/api/direct.py
+++ b/nova/api/direct.py
@@ -324,7 +324,7 @@ class Limited(object):
def __init__(self, proxy):
self._proxy = proxy
- if not self.__doc__:
+ if not self.__doc__: # pylint: disable=E0203
self.__doc__ = proxy.__doc__
if not self._allowed:
self._allowed = []
diff --git a/nova/api/ec2/admin.py b/nova/api/ec2/admin.py
index aeebd86fb..57d0a0339 100644
--- a/nova/api/ec2/admin.py
+++ b/nova/api/ec2/admin.py
@@ -324,7 +324,3 @@ class AdminController(object):
rv.append(host_dict(host, compute, instances, volume, volumes,
now))
return {'hosts': rv}
-
- def describe_host(self, _context, name, **_kwargs):
- """Returns status info for single node."""
- return host_dict(db.host_get(name))
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index ceeaa3e48..1f84fdd54 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -136,6 +136,13 @@ class CloudController(object):
return services[0]['availability_zone']
return 'unknown zone'
+ def _get_image_state(self, image):
+ # NOTE(vish): fallback status if image_state isn't set
+ state = image.get('status')
+ if state == 'active':
+ state = 'available'
+ return image['properties'].get('image_state', state)
+
def get_metadata(self, address):
ctxt = context.get_admin_context()
instance_ref = self.compute_api.get_all(ctxt, fixed_ip=address)
@@ -895,6 +902,16 @@ class CloudController(object):
if kwargs.get('ramdisk_id'):
ramdisk = self._get_image(context, kwargs['ramdisk_id'])
kwargs['ramdisk_id'] = ramdisk['id']
+ image = self._get_image(context, kwargs['image_id'])
+
+ if image:
+ image_state = self._get_image_state(image)
+ else:
+ raise exception.ImageNotFound(image_id=kwargs['image_id'])
+
+ if image_state != 'available':
+ raise exception.ApiError(_('Image must be available'))
+
instances = self.compute_api.create(context,
instance_type=instance_types.get_instance_type_by_name(
kwargs.get('instance_type', None)),
@@ -1010,11 +1027,8 @@ class CloudController(object):
get('image_location'), name)
else:
i['imageLocation'] = image['properties'].get('image_location')
- # NOTE(vish): fallback status if image_state isn't set
- state = image.get('status')
- if state == 'active':
- state = 'available'
- i['imageState'] = image['properties'].get('image_state', state)
+
+ i['imageState'] = self._get_image_state(image)
i['displayName'] = name
i['description'] = image.get('description')
display_mapping = {'aki': 'kernel',
diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/extensions.py
index 881b61733..54e17e23d 100644
--- a/nova/api/openstack/extensions.py
+++ b/nova/api/openstack/extensions.py
@@ -137,7 +137,7 @@ class ActionExtensionResource(wsgi.Resource):
def __init__(self, application):
controller = ActionExtensionController(application)
- super(ActionExtensionResource, self).__init__(controller)
+ wsgi.Resource.__init__(self, controller)
def add_action(self, action_name, handler):
self.controller.add_action(action_name, handler)
@@ -164,7 +164,7 @@ class RequestExtensionResource(wsgi.Resource):
def __init__(self, application):
controller = RequestExtensionController(application)
- super(RequestExtensionResource, self).__init__(controller)
+ wsgi.Resource.__init__(self, controller)
def add_handler(self, handler):
self.controller.add_handler(handler)
diff --git a/nova/api/openstack/views/limits.py b/nova/api/openstack/views/limits.py
index e21c9f2fd..934b4921a 100644
--- a/nova/api/openstack/views/limits.py
+++ b/nova/api/openstack/views/limits.py
@@ -29,9 +29,6 @@ class ViewBuilder(object):
def _build_rate_limit(self, rate_limit):
raise NotImplementedError()
- def _build_absolute_limits(self, absolute_limit):
- raise NotImplementedError()
-
def build(self, rate_limits, absolute_limits):
rate_limits = self._build_rate_limits(rate_limits)
absolute_limits = self._build_absolute_limits(absolute_limits)
@@ -67,12 +64,6 @@ class ViewBuilder(object):
limits[name] = value
return limits
- def _build_rate_limits(self, rate_limits):
- raise NotImplementedError()
-
- def _build_rate_limit(self, rate_limit):
- raise NotImplementedError()
-
class ViewBuilderV10(ViewBuilder):
"""Openstack API v1.0 limits view builder."""
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 6dbf53a6c..73870d2f3 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -743,7 +743,7 @@ def fixed_ip_get_all_by_instance(context, instance_id):
filter_by(instance_id=instance_id).\
filter_by(deleted=False)
if not rv:
- raise exception.NoFloatingIpsFoundForInstance(instance_id=instance_id)
+ raise exception.NoFixedIpsFoundForInstance(instance_id=instance_id)
return rv
@@ -1127,7 +1127,7 @@ def key_pair_destroy_all_by_user(context, user_id):
with session.begin():
session.query(models.KeyPair).\
filter_by(user_id=user_id).\
- update({'deleted': 1,
+ update({'deleted': True,
'deleted_at': utils.utcnow(),
'updated_at': literal_column('updated_at')})
@@ -1659,7 +1659,7 @@ def volume_destroy(context, volume_id):
with session.begin():
session.query(models.Volume).\
filter_by(id=volume_id).\
- update({'deleted': 1,
+ update({'deleted': True,
'deleted_at': utils.utcnow(),
'updated_at': literal_column('updated_at')})
session.query(models.ExportDevice).\
@@ -1817,7 +1817,7 @@ def snapshot_destroy(context, snapshot_id):
with session.begin():
session.query(models.Snapshot).\
filter_by(id=snapshot_id).\
- update({'deleted': 1,
+ update({'deleted': True,
'deleted_at': utils.utcnow(),
'updated_at': literal_column('updated_at')})
@@ -1972,17 +1972,17 @@ def security_group_destroy(context, security_group_id):
with session.begin():
session.query(models.SecurityGroup).\
filter_by(id=security_group_id).\
- update({'deleted': 1,
+ update({'deleted': True,
'deleted_at': utils.utcnow(),
'updated_at': literal_column('updated_at')})
session.query(models.SecurityGroupInstanceAssociation).\
filter_by(security_group_id=security_group_id).\
- update({'deleted': 1,
+ update({'deleted': True,
'deleted_at': utils.utcnow(),
'updated_at': literal_column('updated_at')})
session.query(models.SecurityGroupIngressRule).\
filter_by(group_id=security_group_id).\
- update({'deleted': 1,
+ update({'deleted': True,
'deleted_at': utils.utcnow(),
'updated_at': literal_column('updated_at')})
@@ -1993,11 +1993,11 @@ def security_group_destroy_all(context, session=None):
session = get_session()
with session.begin():
session.query(models.SecurityGroup).\
- update({'deleted': 1,
+ update({'deleted': True,
'deleted_at': utils.utcnow(),
'updated_at': literal_column('updated_at')})
session.query(models.SecurityGroupIngressRule).\
- update({'deleted': 1,
+ update({'deleted': True,
'deleted_at': utils.utcnow(),
'updated_at': literal_column('updated_at')})
@@ -2678,7 +2678,7 @@ def instance_metadata_update_or_create(context, instance_id, metadata):
meta_ref = models.InstanceMetadata()
meta_ref.update({"key": key, "value": value,
"instance_id": instance_id,
- "deleted": 0})
+ "deleted": False})
meta_ref.save(session=session)
return metadata
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 55efe6886..239f6e96a 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -46,6 +46,7 @@ class NovaBase(object):
updated_at = Column(DateTime, onupdate=utils.utcnow)
deleted_at = Column(DateTime)
deleted = Column(Boolean, default=False)
+ metadata = None
def save(self, session=None):
"""Save this object."""
diff --git a/nova/network/manager.py b/nova/network/manager.py
index f037312db..38bcbe0e5 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -85,6 +85,7 @@ flags.DEFINE_string('floating_range', '4.4.4.0/24',
'Floating IP address block')
flags.DEFINE_string('fixed_range', '10.0.0.0/8', 'Fixed IP address block')
flags.DEFINE_string('fixed_range_v6', 'fd00::/48', 'Fixed IPv6 address block')
+flags.DEFINE_string('gateway_v6', None, 'Default IPv6 gateway')
flags.DEFINE_integer('cnt_vpn_clients', 0,
'Number of addresses reserved for vpn clients')
flags.DEFINE_string('network_driver', 'nova.network.linux_net',
@@ -291,7 +292,7 @@ class NetworkManager(manager.SchedulerDependentManager):
return host
def create_networks(self, context, cidr, num_networks, network_size,
- cidr_v6, label, *args, **kwargs):
+ cidr_v6, gateway_v6, label, *args, **kwargs):
"""Create networks based on parameters."""
fixed_net = netaddr.IPNetwork(cidr)
fixed_net_v6 = netaddr.IPNetwork(cidr_v6)
@@ -322,8 +323,15 @@ class NetworkManager(manager.SchedulerDependentManager):
cidr_v6 = '%s/%s' % (fixed_net_v6[start_v6],
significant_bits_v6)
net['cidr_v6'] = cidr_v6
+
project_net_v6 = netaddr.IPNetwork(cidr_v6)
- net['gateway_v6'] = str(list(project_net_v6)[1])
+
+ if gateway_v6:
+ # use a pre-defined gateway if one is provided
+ net['gateway_v6'] = str(list(gateway_v6)[1]))
+ else:
+ net['gateway_v6'] = str(list(project_net_v6)[1])
+
net['netmask_v6'] = str(project_net_v6._prefixlen)
network_ref = self.db.network_create_safe(context, net)
diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py
index 1bf1271c4..ba133c860 100644
--- a/nova/tests/test_cloud.py
+++ b/nova/tests/test_cloud.py
@@ -26,17 +26,16 @@ from eventlet import greenthread
from nova import context
from nova import crypto
from nova import db
+from nova import exception
from nova import flags
from nova import log as logging
from nova import rpc
from nova import test
from nova import utils
-from nova import exception
from nova.auth import manager
from nova.api.ec2 import cloud
from nova.api.ec2 import ec2utils
from nova.image import local
-from nova.exception import NotFound
FLAGS = flags.FLAGS
@@ -68,7 +67,7 @@ class CloudTestCase(test.TestCase):
def fake_show(meh, context, id):
return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1,
- 'type': 'machine'}}
+ 'type': 'machine', 'image_state': 'available'}}
self.stubs.Set(local.LocalImageService, 'show', fake_show)
self.stubs.Set(local.LocalImageService, 'show_by_name', fake_show)
@@ -290,7 +289,7 @@ class CloudTestCase(test.TestCase):
'type': 'machine'}}]
def fake_show_none(meh, context, id):
- raise NotFound
+ raise exception.ImageNotFound(image_id='bad_image_id')
self.stubs.Set(local.LocalImageService, 'detail', fake_detail)
# list all
@@ -308,7 +307,7 @@ class CloudTestCase(test.TestCase):
self.stubs.UnsetAll()
self.stubs.Set(local.LocalImageService, 'show', fake_show_none)
self.stubs.Set(local.LocalImageService, 'show_by_name', fake_show_none)
- self.assertRaises(NotFound, describe_images,
+ self.assertRaises(exception.ImageNotFound, describe_images,
self.context, ['ami-fake'])
def test_describe_image_attribute(self):
@@ -445,6 +444,64 @@ class CloudTestCase(test.TestCase):
self._create_key('test')
self.cloud.delete_key_pair(self.context, 'test')
+ def test_run_instances(self):
+ kwargs = {'image_id': FLAGS.default_image,
+ 'instance_type': FLAGS.default_instance_type,
+ 'max_count': 1}
+ run_instances = self.cloud.run_instances
+ result = run_instances(self.context, **kwargs)
+ instance = result['instancesSet'][0]
+ self.assertEqual(instance['imageId'], 'ami-00000001')
+ self.assertEqual(instance['displayName'], 'Server 1')
+ self.assertEqual(instance['instanceId'], 'i-00000001')
+ self.assertEqual(instance['instanceState']['name'], 'networking')
+ self.assertEqual(instance['instanceType'], 'm1.small')
+
+ def test_run_instances_image_state_none(self):
+ kwargs = {'image_id': FLAGS.default_image,
+ 'instance_type': FLAGS.default_instance_type,
+ 'max_count': 1}
+ run_instances = self.cloud.run_instances
+
+ def fake_show_no_state(self, context, id):
+ return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1,
+ 'type': 'machine'}}
+
+ self.stubs.UnsetAll()
+ self.stubs.Set(local.LocalImageService, 'show', fake_show_no_state)
+ self.assertRaises(exception.ApiError, run_instances,
+ self.context, **kwargs)
+
+ def test_run_instances_image_state_invalid(self):
+ kwargs = {'image_id': FLAGS.default_image,
+ 'instance_type': FLAGS.default_instance_type,
+ 'max_count': 1}
+ run_instances = self.cloud.run_instances
+
+ def fake_show_decrypt(self, context, id):
+ return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1,
+ 'type': 'machine', 'image_state': 'decrypting'}}
+
+ self.stubs.UnsetAll()
+ self.stubs.Set(local.LocalImageService, 'show', fake_show_decrypt)
+ self.assertRaises(exception.ApiError, run_instances,
+ self.context, **kwargs)
+
+ def test_run_instances_image_status_active(self):
+ kwargs = {'image_id': FLAGS.default_image,
+ 'instance_type': FLAGS.default_instance_type,
+ 'max_count': 1}
+ run_instances = self.cloud.run_instances
+
+ def fake_show_stat_active(self, context, id):
+ return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1,
+ 'type': 'machine'}, 'status': 'active'}
+
+ self.stubs.Set(local.LocalImageService, 'show', fake_show_stat_active)
+
+ result = run_instances(self.context, **kwargs)
+ self.assertEqual(len(result['instancesSet']), 1)
+
def test_terminate_instances(self):
inst1 = db.instance_create(self.context, {'reservation_id': 'a',
'image_ref': 1,
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index b6b36745a..8b4183164 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import copy
import eventlet
import mox
import os
@@ -125,6 +126,7 @@ class CacheConcurrencyTestCase(test.TestCase):
class LibvirtConnTestCase(test.TestCase):
+
def setUp(self):
super(LibvirtConnTestCase, self).setUp()
connection._late_load_cheetah()
@@ -207,6 +209,29 @@ class LibvirtConnTestCase(test.TestCase):
self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn')
connection.LibvirtConnection._conn = fake
+ def fake_lookup(self, instance_name):
+
+ class FakeVirtDomain(object):
+
+ def snapshotCreateXML(self, *args):
+ return None
+
+ def XMLDesc(self, *args):
+ return """
+ <domain type='kvm'>
+ <devices>
+ <disk type='file'>
+ <source file='filename'/>
+ </disk>
+ </devices>
+ </domain>
+ """
+
+ return FakeVirtDomain()
+
+ def fake_execute(self, *args):
+ open(args[-1], "a").close()
+
def create_service(self, **kwargs):
service_ref = {'host': kwargs.get('host', 'dummy'),
'binary': 'nova-compute',
@@ -283,43 +308,56 @@ class LibvirtConnTestCase(test.TestCase):
self._check_xml_and_container(instance_data)
def test_snapshot(self):
+ if not self.lazy_load_library_exists():
+ return
+
FLAGS.image_service = 'nova.image.fake.FakeImageService'
- # Only file-based instance storages are supported at the moment
- test_xml = """
- <domain type='kvm'>
- <devices>
- <disk type='file'>
- <source file='filename'/>
- </disk>
- </devices>
- </domain>
- """
+ # Start test
+ image_service = utils.import_object(FLAGS.image_service)
- class FakeVirtDomain(object):
+ # Assuming that base image already exists in image_service
+ instance_ref = db.instance_create(self.context, self.test_instance)
+ properties = {'instance_id': instance_ref['id'],
+ 'user_id': str(self.context.user_id)}
+ snapshot_name = 'test-snap'
+ sent_meta = {'name': snapshot_name, 'is_public': False,
+ 'status': 'creating', 'properties': properties}
+ # Create new image. It will be updated in snapshot method
+ # To work with it from snapshot, the single image_service is needed
+ recv_meta = image_service.create(context, sent_meta)
- def __init__(self):
- pass
+ self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn')
+ connection.LibvirtConnection._conn.lookupByName = self.fake_lookup
+ self.mox.StubOutWithMock(connection.utils, 'execute')
+ connection.utils.execute = self.fake_execute
- def snapshotCreateXML(self, *args):
- return None
+ self.mox.ReplayAll()
- def XMLDesc(self, *args):
- return test_xml
+ conn = connection.LibvirtConnection(False)
+ conn.snapshot(instance_ref, recv_meta['id'])
- def fake_lookup(instance_name):
- if instance_name == instance_ref.name:
- return FakeVirtDomain()
+ snapshot = image_service.show(context, recv_meta['id'])
+ self.assertEquals(snapshot['properties']['image_state'], 'available')
+ self.assertEquals(snapshot['status'], 'active')
+ self.assertEquals(snapshot['name'], snapshot_name)
- def fake_execute(*args):
- # Touch filename to pass 'with open(out_path)'
- open(args[-1], "a").close()
+ def test_snapshot_no_image_architecture(self):
+ if not self.lazy_load_library_exists():
+ return
+
+ FLAGS.image_service = 'nova.image.fake.FakeImageService'
# Start test
image_service = utils.import_object(FLAGS.image_service)
+ # Assign image_ref = 2 from nova/images/fakes for testing different
+ # base image
+ test_instance = copy.deepcopy(self.test_instance)
+ test_instance["image_ref"] = "2"
+
# Assuming that base image already exists in image_service
- instance_ref = db.instance_create(self.context, self.test_instance)
+ instance_ref = db.instance_create(self.context, test_instance)
properties = {'instance_id': instance_ref['id'],
'user_id': str(self.context.user_id)}
snapshot_name = 'test-snap'
@@ -330,9 +368,9 @@ class LibvirtConnTestCase(test.TestCase):
recv_meta = image_service.create(context, sent_meta)
self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn')
- connection.LibvirtConnection._conn.lookupByName = fake_lookup
+ connection.LibvirtConnection._conn.lookupByName = self.fake_lookup
self.mox.StubOutWithMock(connection.utils, 'execute')
- connection.utils.execute = fake_execute
+ connection.utils.execute = self.fake_execute
self.mox.ReplayAll()
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index 35308d95f..151a3e909 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -42,20 +42,6 @@ def stubout_instance_snapshot(stubs):
stubs.Set(vm_utils.VMHelper, 'fetch_image', fake_fetch_image)
- def fake_wait_for_vhd_coalesce(session, instance_id, sr_ref, vdi_ref,
- original_parent_uuid):
- from nova.virt.xenapi.fake import create_vdi
- name_label = "instance-%s" % instance_id
- #TODO: create fake SR record
- sr_ref = "fakesr"
- vdi_ref = create_vdi(name_label=name_label, read_only=False,
- sr_ref=sr_ref, sharable=False)
- vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref)
- vdi_uuid = vdi_rec['uuid']
- return vdi_uuid
-
- stubs.Set(vm_utils.VMHelper, 'fetch_image', fake_fetch_image)
-
def fake_parse_xmlrpc_value(val):
return val
@@ -251,10 +237,10 @@ class FakeSessionForMigrationTests(fake.SessionBase):
def __init__(self, uri):
super(FakeSessionForMigrationTests, self).__init__(uri)
- def VDI_get_by_uuid(*args):
+ def VDI_get_by_uuid(self, *args):
return 'hurr'
- def VDI_resize_online(*args):
+ def VDI_resize_online(self, *args):
pass
def VM_start(self, _1, ref, _2, _3):
diff --git a/nova/twistd.py b/nova/twistd.py
index c07ed991f..15cf67825 100644
--- a/nova/twistd.py
+++ b/nova/twistd.py
@@ -78,7 +78,7 @@ def WrapTwistedOptions(wrapped):
self._absorbParameters()
self._absorbHandlers()
- super(TwistedOptionsToFlags, self).__init__()
+ wrapped.__init__(self)
def _absorbFlags(self):
twistd_flags = []
@@ -163,12 +163,12 @@ def WrapTwistedOptions(wrapped):
def parseArgs(self, *args):
# TODO(termie): figure out a decent way of dealing with args
#return
- super(TwistedOptionsToFlags, self).parseArgs(*args)
+ wrapped.parseArgs(self, *args)
def postOptions(self):
self._doHandlers()
- super(TwistedOptionsToFlags, self).postOptions()
+ wrapped.postOptions(self)
def __getitem__(self, key):
key = key.replace('-', '_')
diff --git a/nova/utils.py b/nova/utils.py
index b1638e72c..691134ada 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -142,24 +142,26 @@ def execute(*cmd, **kwargs):
env = os.environ.copy()
if addl_env:
env.update(addl_env)
+ _PIPE = subprocess.PIPE # pylint: disable=E1101
obj = subprocess.Popen(cmd,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
+ stdin=_PIPE,
+ stdout=_PIPE,
+ stderr=_PIPE,
env=env)
result = None
if process_input is not None:
result = obj.communicate(process_input)
else:
result = obj.communicate()
- obj.stdin.close()
- if obj.returncode:
- LOG.debug(_('Result was %s') % obj.returncode)
+ obj.stdin.close() # pylint: disable=E1101
+ _returncode = obj.returncode # pylint: disable=E1101
+ if _returncode:
+ LOG.debug(_('Result was %s') % _returncode)
if type(check_exit_code) == types.IntType \
- and obj.returncode != check_exit_code:
+ and _returncode != check_exit_code:
(stdout, stderr) = result
raise exception.ProcessExecutionError(
- exit_code=obj.returncode,
+ exit_code=_returncode,
stdout=stdout,
stderr=stderr,
cmd=' '.join(cmd))
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index da5911a1a..c68bdcbaf 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -402,8 +402,7 @@ class LibvirtConnection(driver.ComputeDriver):
'is_public': False,
'status': 'active',
'name': snapshot['name'],
- 'properties': {'architecture':
- base['properties']['architecture'],
+ 'properties': {
'kernel_id': instance['kernel_id'],
'image_location': 'snapshot',
'image_state': 'available',
@@ -411,6 +410,9 @@ class LibvirtConnection(driver.ComputeDriver):
'ramdisk_id': instance['ramdisk_id'],
}
}
+ if 'architecture' in base['properties']:
+ arch = base['properties']['architecture']
+ metadata['properties']['architecture'] = arch
# Make the snapshot
snapshot_name = uuid.uuid4().hex
diff --git a/nova/virt/xenapi/fake.py b/nova/virt/xenapi/fake.py
index 165888cb2..113198689 100644
--- a/nova/virt/xenapi/fake.py
+++ b/nova/virt/xenapi/fake.py
@@ -340,10 +340,6 @@ class SessionBase(object):
return
db_ref['xenstore_data'][key] = None
- def network_get_all_records_where(self, _1, _2):
- # TODO (salvatore-orlando): filter table on _2
- return _db_content['network']
-
def VM_add_to_xenstore_data(self, _1, vm_ref, key, value):
db_ref = _db_content['VM'][vm_ref]
if not 'xenstore_data' in db_ref:
@@ -354,7 +350,7 @@ class SessionBase(object):
#Always return 12GB available
return 12 * 1024 * 1024 * 1024
- def host_call_plugin(*args):
+ def host_call_plugin(self, *args):
return 'herp'
def network_get_all_records_where(self, _1, filter):