summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMonsyne Dragon <mdragon@rackspace.com>2011-03-17 02:20:18 +0000
committerMonsyne Dragon <mdragon@rackspace.com>2011-03-17 02:20:18 +0000
commita766b4111addad804e47b8be3e6dedb5f80a83c4 (patch)
tree3032e94f7e3c97631b5fbbcb0363edea1a83874b
parentde7707f9707a0166d01d6a7dfce51f34c3c58967 (diff)
downloadnova-a766b4111addad804e47b8be3e6dedb5f80a83c4.tar.gz
nova-a766b4111addad804e47b8be3e6dedb5f80a83c4.tar.xz
nova-a766b4111addad804e47b8be3e6dedb5f80a83c4.zip
added in network qos support for xenserver.
Pull qos settings from flavor, use when creating instance.
-rw-r--r--nova/api/openstack/servers.py3
-rw-r--r--nova/tests/db/fakes.py30
-rw-r--r--nova/tests/test_xenapi.py8
-rw-r--r--nova/virt/xenapi/vm_utils.py9
-rw-r--r--nova/virt/xenapi/vmops.py9
-rw-r--r--plugins/xenserver/xenapi/etc/xapi.d/plugins/glance2
6 files changed, 49 insertions, 12 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 3ecd4fb01..2f26fa873 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -32,6 +32,7 @@ from nova.api.openstack import faults
from nova.auth import manager as auth_manager
from nova.compute import instance_types
from nova.compute import power_state
+from nova.quota import QuotaError
import nova.api.openstack
@@ -189,7 +190,7 @@ class Controller(wsgi.Controller):
metadata=metadata,
injected_files=injected_files)
except QuotaError as error:
- self._handle_quota_error(error)
+ self._handle_quota_errors(error)
server = _translate_keys(instances[0])
password = "%s%s" % (server['server']['name'][:4],
diff --git a/nova/tests/db/fakes.py b/nova/tests/db/fakes.py
index 5e9a3aa3b..2d25d5fc5 100644
--- a/nova/tests/db/fakes.py
+++ b/nova/tests/db/fakes.py
@@ -28,13 +28,33 @@ def stub_out_db_instance_api(stubs):
""" Stubs out the db API for creating Instances """
INSTANCE_TYPES = {
- 'm1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1),
- 'm1.small': dict(memory_mb=2048, vcpus=1, local_gb=20, flavorid=2),
+ 'm1.tiny': dict(memory_mb=512,
+ vcpus=1,
+ local_gb=0,
+ flavorid=1,
+ rxtx_cap=1),
+ 'm1.small': dict(memory_mb=2048,
+ vcpus=1,
+ local_gb=20,
+ flavorid=2,
+ rxtx_cap=2),
'm1.medium':
- dict(memory_mb=4096, vcpus=2, local_gb=40, flavorid=3),
- 'm1.large': dict(memory_mb=8192, vcpus=4, local_gb=80, flavorid=4),
+ dict(memory_mb=4096,
+ vcpus=2,
+ local_gb=40,
+ flavorid=3,
+ rxtx_cap=3),
+ 'm1.large': dict(memory_mb=8192,
+ vcpus=4,
+ local_gb=80,
+ flavorid=4,
+ rxtx_cap=4),
'm1.xlarge':
- dict(memory_mb=16384, vcpus=8, local_gb=160, flavorid=5)}
+ dict(memory_mb=16384,
+ vcpus=8,
+ local_gb=160,
+ flavorid=5,
+ rxtx_cap=5)}
class FakeModel(object):
""" Stubs out for model """
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 8b0affd5c..66a973a78 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -361,6 +361,14 @@ class XenAPIVMTestCase(test.TestCase):
glance_stubs.FakeGlance.IMAGE_RAMDISK)
self.check_vm_params_for_linux_with_external_kernel()
+ def test_spawn_with_network_qos(self):
+ self._create_instance()
+ for vif_ref in xenapi_fake.get_all('VIF'):
+ vif_rec = xenapi_fake.get_record('VIF', vif_ref)
+ self.assertEquals(vif_rec['qos_algorithm_type'], 'ratelimit')
+ self.assertEquals(vif_rec['qos_algorithm_params']['kbps'],
+ str(4 * 1024))
+
def tearDown(self):
super(XenAPIVMTestCase, self).tearDown()
self.manager.delete_project(self.project)
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 763c5fe40..e0621f73a 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -233,7 +233,9 @@ class VMHelper(HelperBase):
raise StorageError(_('Unable to destroy VBD %s') % vbd_ref)
@classmethod
- def create_vif(cls, session, vm_ref, network_ref, mac_address, dev="0"):
+ def create_vif(cls, session, vm_ref, network_ref, mac_address,
+ dev="0",
+ rxtx_cap=0):
"""Create a VIF record. Returns a Deferred that gives the new
VIF reference."""
vif_rec = {}
@@ -243,8 +245,9 @@ class VMHelper(HelperBase):
vif_rec['MAC'] = mac_address
vif_rec['MTU'] = '1500'
vif_rec['other_config'] = {}
- vif_rec['qos_algorithm_type'] = ''
- vif_rec['qos_algorithm_params'] = {}
+ vif_rec['qos_algorithm_type'] = "ratelimit" if rxtx_cap else ''
+ vif_rec['qos_algorithm_params'] = \
+ {"kbps": str(rxtx_cap * 1024)} if rxtx_cap else {}
LOG.debug(_('Creating VIF for VM %(vm_ref)s,'
' network %(network_ref)s.') % locals())
vif_ref = session.call_xenapi('VIF.create', vif_rec)
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 488a61e8e..29f162ad1 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -744,8 +744,12 @@ class VMOps(object):
Creates vifs for an instance
"""
- vm_ref = self._get_vm_opaque_ref(instance.id)
+ vm_ref = self._get_vm_opaque_ref(instance['id'])
+ admin_context = context.get_admin_context()
+ flavor = db.instance_type_get_by_name(admin_context,
+ instance.instance_type)
logging.debug(_("creating vif(s) for vm: |%s|"), vm_ref)
+ rxtx_cap = flavor['rxtx_cap']
if networks is None:
networks = db.network_get_all_by_instance(admin_context,
instance['id'])
@@ -766,7 +770,8 @@ class VMOps(object):
device = "0"
VMHelper.create_vif(self._session, vm_ref, network_ref,
- instance.mac_address, device)
+ instance.mac_address, device,
+ rxtx_cap=rxtx_cap)
def reset_network(self, instance):
"""
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
index c996f6ef4..db39cb0f4 100644
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
@@ -216,7 +216,7 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port, os_type):
'x-image-meta-status': 'queued',
'x-image-meta-disk-format': 'vhd',
'x-image-meta-container-format': 'ovf',
- 'x-image-meta-property-os-type': os_type
+ 'x-image-meta-property-os-type': os_type,
}
for header, value in headers.iteritems():