diff options
author | vladimir.p <vladimir@zadarastorage.com> | 2011-08-24 15:51:29 -0700 |
---|---|---|
committer | vladimir.p <vladimir@zadarastorage.com> | 2011-08-24 15:51:29 -0700 |
commit | 48cd9689de31e408c792052747f714a9dbe1f8f7 (patch) | |
tree | 2ca4c06ed95a47ecce683b166baddbd4dcb145b8 | |
parent | 2bc1e302910d9f66448618ddf140b72e85292d0f (diff) | |
download | nova-48cd9689de31e408c792052747f714a9dbe1f8f7.tar.gz |
added virtio flag; associate address for VSA; cosmetic changes. Prior to volume_types merge
-rwxr-xr-x | bin/nova-manage | 4 | ||||
-rwxr-xr-x | bin/nova-vsa | 1 | ||||
-rw-r--r-- | nova/api/openstack/contrib/drive_types.py | 1 | ||||
-rw-r--r-- | nova/api/openstack/contrib/virtual_storage_arrays.py | 49 | ||||
-rw-r--r-- | nova/db/sqlalchemy/migrate_repo/versions/037_add_vsa_data.py | 1 | ||||
-rw-r--r-- | nova/db/sqlalchemy/session.py | 2 | ||||
-rw-r--r-- | nova/network/linux_net.py | 1 | ||||
-rw-r--r-- | nova/scheduler/vsa.py | 1 | ||||
-rw-r--r-- | nova/tests/test_drive_types.py | 59 | ||||
-rw-r--r-- | nova/tests/test_vsa.py | 2 | ||||
-rw-r--r-- | nova/virt/libvirt.xml.template | 4 | ||||
-rw-r--r-- | nova/virt/libvirt/connection.py | 4 | ||||
-rw-r--r-- | nova/vsa/__init__.py | 1 | ||||
-rw-r--r-- | nova/vsa/api.py | 7 | ||||
-rw-r--r-- | nova/vsa/connection.py | 1 | ||||
-rw-r--r-- | nova/vsa/drive_types.py | 1 | ||||
-rw-r--r-- | nova/vsa/fake.py | 1 | ||||
-rw-r--r-- | nova/vsa/manager.py | 1 |
18 files changed, 88 insertions, 53 deletions
diff --git a/bin/nova-manage b/bin/nova-manage index 18a008d8c8..d7636b8118 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -64,9 +64,6 @@ import time from optparse import OptionParser - -import tempfile -import zipfile import ast # If ../nova/__init__.py exists, add ../ to Python search path, so that @@ -91,7 +88,6 @@ from nova import rpc from nova import utils from nova import version from nova.api.ec2 import ec2utils -from nova.api.ec2 import cloud from nova.auth import manager from nova.cloudpipe import pipelib from nova.compute import instance_types diff --git a/bin/nova-vsa b/bin/nova-vsa index 07f998117e..d765e8f9e8 100755 --- a/bin/nova-vsa +++ b/bin/nova-vsa @@ -3,7 +3,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 diff --git a/nova/api/openstack/contrib/drive_types.py b/nova/api/openstack/contrib/drive_types.py index f2cbd37154..1aa65374f1 100644 --- a/nova/api/openstack/contrib/drive_types.py +++ b/nova/api/openstack/contrib/drive_types.py @@ -2,7 +2,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 diff --git a/nova/api/openstack/contrib/virtual_storage_arrays.py b/nova/api/openstack/contrib/virtual_storage_arrays.py index d6c4a5ef43..81dbc9e1f2 100644 --- a/nova/api/openstack/contrib/virtual_storage_arrays.py +++ b/nova/api/openstack/contrib/virtual_storage_arrays.py @@ -2,7 +2,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 @@ -24,6 +23,7 @@ from webob import exc from nova import vsa from nova import volume from nova import compute +from nova import network from nova import db from nova import quota from nova import exception @@ -103,6 +103,7 @@ class VsaController(object): def __init__(self): self.vsa_api = vsa.API() self.compute_api = compute.API() + self.network_api = network.API() super(VsaController, self).__init__() def _items(self, req, details): @@ -186,6 +187,48 @@ class VsaController(object): except exception.NotFound: return faults.Fault(exc.HTTPNotFound()) + def associate_address(self, req, id, body): + """ /zadr-vsa/{vsa_id}/associate_address + auto or manually associate an IP to VSA + """ + context = req.environ['nova.context'] + + if body is None: + ip = 'auto' + else: + ip = body.get('ipAddress', 'auto') + + LOG.audit(_("Associate address %(ip)s to VSA %(id)s"), + locals(), context=context) + + try: + instances = self.compute_api.get_all(context, + search_opts={'metadata': dict(vsa_id=str(id))}) + + if instances is None or len(instances)==0: + return faults.Fault(exc.HTTPNotFound()) + + for instance in instances: + self.network_api.allocate_for_instance(context, instance, vpn=False) + return + + except exception.NotFound: + return faults.Fault(exc.HTTPNotFound()) + + def disassociate_address(self, req, id, body): + """ /zadr-vsa/{vsa_id}/disassociate_address + auto or manually associate an IP to VSA + """ + context = req.environ['nova.context'] + + if body is None: + ip = 'auto' + else: + ip = body.get('ipAddress', 'auto') + + LOG.audit(_("Disassociate address from VSA %(id)s"), + locals(), context=context) + class VsaVolumeDriveController(volumes.VolumeController): """The base class for VSA volumes & drives. @@ -515,7 +558,9 @@ class Virtual_storage_arrays(extensions.ExtensionDescriptor): VsaController(), collection_actions={'detail': 'GET'}, member_actions={'add_capacity': 'POST', - 'remove_capacity': 'POST'}) + 'remove_capacity': 'POST', + 'associate_address': 'POST', + 'disassociate_address': 'POST'}) resources.append(res) res = extensions.ResourceExtension('volumes', diff --git a/nova/db/sqlalchemy/migrate_repo/versions/037_add_vsa_data.py b/nova/db/sqlalchemy/migrate_repo/versions/037_add_vsa_data.py index 5a80f4e7ae..8a57bd2346 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/037_add_vsa_data.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/037_add_vsa_data.py @@ -2,7 +2,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 diff --git a/nova/db/sqlalchemy/session.py b/nova/db/sqlalchemy/session.py index 07f2819389..c678cb543e 100644 --- a/nova/db/sqlalchemy/session.py +++ b/nova/db/sqlalchemy/session.py @@ -30,11 +30,9 @@ import nova.exception import nova.flags import nova.log - FLAGS = nova.flags.FLAGS LOG = nova.log.getLogger("nova.db.sqlalchemy") - try: import MySQLdb except ImportError: diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 57c1d0c283..3de605ae23 100644 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -508,6 +508,7 @@ def get_dhcp_hosts(context, network_ref): if network_ref['multi_host'] and FLAGS.host != host: continue hosts.append(_host_dhcp(fixed_ref)) + return '\n'.join(hosts) diff --git a/nova/scheduler/vsa.py b/nova/scheduler/vsa.py index 10c9b5a02e..218ad5c7b6 100644 --- a/nova/scheduler/vsa.py +++ b/nova/scheduler/vsa.py @@ -2,7 +2,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 diff --git a/nova/tests/test_drive_types.py b/nova/tests/test_drive_types.py index e91c413215..b52e6705b8 100644 --- a/nova/tests/test_drive_types.py +++ b/nova/tests/test_drive_types.py @@ -2,7 +2,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 @@ -28,21 +27,21 @@ from nova import test from nova.vsa import drive_types FLAGS = flags.FLAGS -LOG = logging.getLogger('nova.tests.vsa') +LOG = logging.getLogger('nova.tests.test_drive_types') class DriveTypesTestCase(test.TestCase): """Test cases for driver types code""" def setUp(self): super(DriveTypesTestCase, self).setUp() - self.cntx = context.RequestContext(None, None) - self.cntx_admin = context.get_admin_context() - self._dtype = self._create_drive_type() + self.ctxt = context.RequestContext(None, None) + self.ctxt_admin = context.get_admin_context() + self._dtype = self._create_default_drive_type() def tearDown(self): self._dtype = None - def _create_drive_type(self): + def _create_default_drive_type(self): """Create a volume object.""" dtype = {} dtype['type'] = 'SATA' @@ -51,97 +50,97 @@ class DriveTypesTestCase(test.TestCase): dtype['capabilities'] = None dtype['visible'] = True - LOG.debug(_("Drive Type created %s"), dtype) + LOG.debug(_("Default values for Drive Type: %s"), dtype) return dtype def test_drive_type_create_delete(self): dtype = self._dtype - prev_all_dtypes = drive_types.get_all(self.cntx_admin, False) + prev_all_dtypes = drive_types.get_all(self.ctxt_admin, False) - new = drive_types.create(self.cntx_admin, **dtype) + new = drive_types.create(self.ctxt_admin, **dtype) for k, v in dtype.iteritems(): self.assertEqual(v, new[k], 'one of fields doesnt match') - new_all_dtypes = drive_types.get_all(self.cntx_admin, False) + new_all_dtypes = drive_types.get_all(self.ctxt_admin, False) self.assertNotEqual(len(prev_all_dtypes), len(new_all_dtypes), 'drive type was not created') - drive_types.delete(self.cntx_admin, new['id']) - new_all_dtypes = drive_types.get_all(self.cntx_admin, False) + drive_types.delete(self.ctxt_admin, new['id']) + new_all_dtypes = drive_types.get_all(self.ctxt_admin, False) self.assertEqual(prev_all_dtypes, new_all_dtypes, 'drive types was not deleted') def test_drive_type_check_name_generation(self): dtype = self._dtype - new = drive_types.create(self.cntx_admin, **dtype) + new = drive_types.create(self.ctxt_admin, **dtype) expected_name = FLAGS.drive_type_template_short % \ (dtype['type'], dtype['size_gb'], dtype['rpm']) self.assertEqual(new['name'], expected_name, 'name was not generated correctly') dtype['capabilities'] = 'SEC' - new2 = drive_types.create(self.cntx_admin, **dtype) + new2 = drive_types.create(self.ctxt_admin, **dtype) expected_name = FLAGS.drive_type_template_long % \ (dtype['type'], dtype['size_gb'], dtype['rpm'], dtype['capabilities']) self.assertEqual(new2['name'], expected_name, 'name was not generated correctly') - drive_types.delete(self.cntx_admin, new['id']) - drive_types.delete(self.cntx_admin, new2['id']) + drive_types.delete(self.ctxt_admin, new['id']) + drive_types.delete(self.ctxt_admin, new2['id']) def test_drive_type_create_delete_invisible(self): dtype = self._dtype dtype['visible'] = False - prev_all_dtypes = drive_types.get_all(self.cntx_admin, True) - new = drive_types.create(self.cntx_admin, **dtype) + prev_all_dtypes = drive_types.get_all(self.ctxt_admin, True) + new = drive_types.create(self.ctxt_admin, **dtype) - new_all_dtypes = drive_types.get_all(self.cntx_admin, True) + new_all_dtypes = drive_types.get_all(self.ctxt_admin, True) self.assertEqual(prev_all_dtypes, new_all_dtypes) - new_all_dtypes = drive_types.get_all(self.cntx_admin, False) + new_all_dtypes = drive_types.get_all(self.ctxt_admin, False) self.assertNotEqual(prev_all_dtypes, new_all_dtypes) - drive_types.delete(self.cntx_admin, new['id']) + drive_types.delete(self.ctxt_admin, new['id']) def test_drive_type_rename_update(self): dtype = self._dtype dtype['capabilities'] = None - new = drive_types.create(self.cntx_admin, **dtype) + new = drive_types.create(self.ctxt_admin, **dtype) for k, v in dtype.iteritems(): self.assertEqual(v, new[k], 'one of fields doesnt match') new_name = 'NEW_DRIVE_NAME' - new = drive_types.rename(self.cntx_admin, new['name'], new_name) + new = drive_types.rename(self.ctxt_admin, new['name'], new_name) self.assertEqual(new['name'], new_name) - new = drive_types.rename(self.cntx_admin, new_name) + new = drive_types.rename(self.ctxt_admin, new_name) expected_name = FLAGS.drive_type_template_short % \ (dtype['type'], dtype['size_gb'], dtype['rpm']) self.assertEqual(new['name'], expected_name) changes = {'rpm': 7200} - new = drive_types.update(self.cntx_admin, new['id'], **changes) + new = drive_types.update(self.ctxt_admin, new['id'], **changes) for k, v in changes.iteritems(): self.assertEqual(v, new[k], 'one of fields doesnt match') - drive_types.delete(self.cntx_admin, new['id']) + drive_types.delete(self.ctxt_admin, new['id']) def test_drive_type_get(self): dtype = self._dtype - new = drive_types.create(self.cntx_admin, **dtype) + new = drive_types.create(self.ctxt_admin, **dtype) - new2 = drive_types.get(self.cntx_admin, new['id']) + new2 = drive_types.get(self.ctxt_admin, new['id']) for k, v in new2.iteritems(): self.assertEqual(str(new[k]), str(new2[k]), 'one of fields doesnt match') - new2 = drive_types.get_by_name(self.cntx_admin, new['name']) + new2 = drive_types.get_by_name(self.ctxt_admin, new['name']) for k, v in new.iteritems(): self.assertEqual(str(new[k]), str(new2[k]), 'one of fields doesnt match') - drive_types.delete(self.cntx_admin, new['id']) + drive_types.delete(self.ctxt_admin, new['id']) diff --git a/nova/tests/test_vsa.py b/nova/tests/test_vsa.py index cff23a8005..726939744c 100644 --- a/nova/tests/test_vsa.py +++ b/nova/tests/test_vsa.py @@ -113,7 +113,7 @@ class VsaTestCase(test.TestCase): self.assertRaises(exception.ApiError, self.vsa_api.create, self.context, **param) vsa_list2 = self.vsa_api.get_all(self.context) - self.assertEqual(len(vsa_list2), len(vsa_list1) + 1) + self.assertEqual(len(vsa_list2), len(vsa_list1)) param = {'storage': [{'drive_name': 'wrong name'}]} self.assertRaises(exception.ApiError, diff --git a/nova/virt/libvirt.xml.template b/nova/virt/libvirt.xml.template index 210e2b0fb1..0b241120be 100644 --- a/nova/virt/libvirt.xml.template +++ b/nova/virt/libvirt.xml.template @@ -128,7 +128,9 @@ <interface type='bridge'> <source bridge='${nic.bridge_name}'/> <mac address='${nic.mac_address}'/> - <!-- <model type='virtio'/> CANT RUN virtio network right now --> +#if $getVar('use_virtio_for_bridges', True) + <model type='virtio'/> +#end if <filterref filter="nova-instance-${name}-${nic.id}"> <parameter name="IP" value="${nic.ip_address}" /> <parameter name="DHCPSERVER" value="${nic.dhcp_server}" /> diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index e8a657bac0..fb16aa57d7 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -130,6 +130,9 @@ flags.DEFINE_string('libvirt_vif_type', 'bridge', flags.DEFINE_string('libvirt_vif_driver', 'nova.virt.libvirt.vif.LibvirtBridgeDriver', 'The libvirt VIF driver to configure the VIFs.') +flags.DEFINE_bool('libvirt_use_virtio_for_bridges', + False, + 'Use virtio for bridge interfaces') def get_connection(read_only): @@ -1047,6 +1050,7 @@ class LibvirtConnection(driver.ComputeDriver): 'ebs_root': ebs_root, 'local_device': local_device, 'volumes': block_device_mapping, + 'use_virtio_for_bridges': FLAGS.libvirt_use_virtio_for_bridges, 'ephemerals': ephemerals} root_device_name = driver.block_device_info_get_root(block_device_info) diff --git a/nova/vsa/__init__.py b/nova/vsa/__init__.py index 779b7fb65a..09162e006e 100644 --- a/nova/vsa/__init__.py +++ b/nova/vsa/__init__.py @@ -2,7 +2,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 diff --git a/nova/vsa/api.py b/nova/vsa/api.py index 19185b907d..bb6e93b87d 100644 --- a/nova/vsa/api.py +++ b/nova/vsa/api.py @@ -2,7 +2,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 @@ -194,9 +193,9 @@ class API(base.Base): volume_params = self._check_storage_parameters(context, vsa_name, storage, shared) except exception.ApiError: - self.update_vsa_status(context, vsa_id, - status=VsaState.FAILED) - raise + self.db.vsa_destroy(context, vsa_id) + raise exception.ApiError(_("Error in storage parameters: %s") + % storage) # after creating DB entry, re-check and set some defaults updates = {} diff --git a/nova/vsa/connection.py b/nova/vsa/connection.py index 5de8021a77..8ac8a1dd56 100644 --- a/nova/vsa/connection.py +++ b/nova/vsa/connection.py @@ -2,7 +2,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 diff --git a/nova/vsa/drive_types.py b/nova/vsa/drive_types.py index 3c67fdbb9b..3cdbbfb091 100644 --- a/nova/vsa/drive_types.py +++ b/nova/vsa/drive_types.py @@ -2,7 +2,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 diff --git a/nova/vsa/fake.py b/nova/vsa/fake.py index d96138255b..0bb81484db 100644 --- a/nova/vsa/fake.py +++ b/nova/vsa/fake.py @@ -2,7 +2,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 diff --git a/nova/vsa/manager.py b/nova/vsa/manager.py index d98d0fcb2c..0f1718d386 100644 --- a/nova/vsa/manager.py +++ b/nova/vsa/manager.py @@ -2,7 +2,6 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. -# 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 |