added virtio flag; associate address for VSA; cosmetic changes. Prior to volume_types merge
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'])
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user