* Updated document vmware_readme.rst to mention VLAN networking

* Corrected docstrings as per pep0257 recommentations.
* Stream-lined the comments.
* Updated code with locals() where ever applicable.
* VIM : It stands for VMware Virtual Infrastructure Methodology. We have used the terminology from VMware.  we have added a question in FAQ inside vmware_readme.rst in doc/source
* New fake db: vmwareapi fake module uses a different set of fields and hence the structures required are different. Ex: bridge : 'xenbr0' does not hold good for VMware environment and bridge : 'vmnic0' is used instead. Also return values varies, hence went for implementing separate fake db.
* Now using eventlet library instead and removed io_utils.py from branch.
* Now using glance.client.Client instead of homegrown code to talk to Glance server to handle images.
* Corrected all mis-spelled function names and corresponding calls. Yeah, an auto-complete side-effect!
This commit is contained in:
sateesh
2011-03-16 21:54:02 +05:30
parent b12658f04c
commit 72fb6e3b3a
4 changed files with 30 additions and 21 deletions

View File

@@ -16,8 +16,9 @@
# under the License. # under the License.
""" """
Test suite for VMWareAPI Test suite for VMWareAPI.
""" """
import stubout import stubout
from nova import context from nova import context
@@ -38,9 +39,7 @@ FLAGS = flags.FLAGS
class VMWareAPIVMTestCase(test.TestCase): class VMWareAPIVMTestCase(test.TestCase):
""" """Unit tests for Vmware API connection calls."""
Unit tests for Vmware API connection calls
"""
def setUp(self): def setUp(self):
super(VMWareAPIVMTestCase, self).setUp() super(VMWareAPIVMTestCase, self).setUp()
@@ -61,7 +60,7 @@ class VMWareAPIVMTestCase(test.TestCase):
self.conn = vmwareapi_conn.get_connection(False) self.conn = vmwareapi_conn.get_connection(False)
def _create_vm(self): def _create_vm(self):
""" Create and spawn the VM """ """Create and spawn the VM."""
values = {'name': 1, values = {'name': 1,
'id': 1, 'id': 1,
'project_id': self.project.id, 'project_id': self.project.id,
@@ -78,15 +77,17 @@ class VMWareAPIVMTestCase(test.TestCase):
self._check_vm_record() self._check_vm_record()
def _check_vm_record(self): def _check_vm_record(self):
""" Check if the spawned VM's properties corresponds to the instance in """
the db """ Check if the spawned VM's properties correspond to the instance in
the db.
"""
instances = self.conn.list_instances() instances = self.conn.list_instances()
self.assertEquals(len(instances), 1) self.assertEquals(len(instances), 1)
# Get Nova record for VM # Get Nova record for VM
vm_info = self.conn.get_info(1) vm_info = self.conn.get_info(1)
# Get record for VMs # Get record for VM
vms = vmwareapi_fake._get_objects("VirtualMachine") vms = vmwareapi_fake._get_objects("VirtualMachine")
vm = vms[0] vm = vms[0]
@@ -106,8 +107,10 @@ class VMWareAPIVMTestCase(test.TestCase):
self.assertEquals(vm.get("runtime.powerState"), 'poweredOn') self.assertEquals(vm.get("runtime.powerState"), 'poweredOn')
def _check_vm_info(self, info, pwr_state=power_state.RUNNING): def _check_vm_info(self, info, pwr_state=power_state.RUNNING):
""" Check if the get_info returned values correspond to the instance """
object in the db """ Check if the get_info returned values correspond to the instance
object in the db.
"""
mem_kib = long(self.type_data['memory_mb']) << 10 mem_kib = long(self.type_data['memory_mb']) << 10
self.assertEquals(info["state"], pwr_state) self.assertEquals(info["state"], pwr_state)
self.assertEquals(info["max_mem"], mem_kib) self.assertEquals(info["max_mem"], mem_kib)
@@ -194,8 +197,9 @@ class VMWareAPIVMTestCase(test.TestCase):
pass pass
def dummy_callback_handler(self, ret): def dummy_callback_handler(self, ret):
""" Dummy callback function to be passed to suspend, resume, etc. """
calls """ Dummy callback function to be passed to suspend, resume, etc., calls.
"""
pass pass
def tearDown(self): def tearDown(self):

View File

@@ -14,3 +14,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"""
:mod:`vmwareapi` -- Stubs for VMware API
=======================================
"""

View File

@@ -26,7 +26,7 @@ from nova import utils
def stub_out_db_instance_api(stubs): def stub_out_db_instance_api(stubs):
""" Stubs out the db API for creating Instances """ """Stubs out the db API for creating Instances."""
INSTANCE_TYPES = { INSTANCE_TYPES = {
'm1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1), 'm1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1),
@@ -38,7 +38,7 @@ def stub_out_db_instance_api(stubs):
dict(memory_mb=16384, vcpus=8, local_gb=160, flavorid=5)} dict(memory_mb=16384, vcpus=8, local_gb=160, flavorid=5)}
class FakeModel(object): class FakeModel(object):
""" Stubs out for model """ """Stubs out for model."""
def __init__(self, values): def __init__(self, values):
self.values = values self.values = values
@@ -53,7 +53,7 @@ def stub_out_db_instance_api(stubs):
raise NotImplementedError() raise NotImplementedError()
def fake_instance_create(values): def fake_instance_create(values):
""" Stubs out the db.instance_create method """ """Stubs out the db.instance_create method."""
type_data = INSTANCE_TYPES[values['instance_type']] type_data = INSTANCE_TYPES[values['instance_type']]
@@ -77,7 +77,7 @@ def stub_out_db_instance_api(stubs):
return FakeModel(base_options) return FakeModel(base_options)
def fake_network_get_by_instance(context, instance_id): def fake_network_get_by_instance(context, instance_id):
""" Stubs out the db.network_get_by_instance method """ """Stubs out the db.network_get_by_instance method."""
fields = { fields = {
'bridge': 'vmnet0', 'bridge': 'vmnet0',
@@ -87,11 +87,11 @@ def stub_out_db_instance_api(stubs):
return FakeModel(fields) return FakeModel(fields)
def fake_instance_action_create(context, action): def fake_instance_action_create(context, action):
""" Stubs out the db.instance_action_create method """ """Stubs out the db.instance_action_create method."""
pass pass
def fake_instance_get_fixed_address(context, instance_id): def fake_instance_get_fixed_address(context, instance_id):
""" Stubs out the db.instance_get_fixed_address method """ """Stubs out the db.instance_get_fixed_address method."""
return '10.10.10.10' return '10.10.10.10'
def fake_instance_type_get_all(context, inactive=0): def fake_instance_type_get_all(context, inactive=0):

View File

@@ -25,17 +25,17 @@ from nova.virt.vmwareapi import vmware_images
def fake_get_vim_object(arg): def fake_get_vim_object(arg):
""" Stubs out the VMWareAPISession's get_vim_object method """ """Stubs out the VMWareAPISession's get_vim_object method."""
return fake.FakeVim() return fake.FakeVim()
def fake_is_vim_object(arg, module): def fake_is_vim_object(arg, module):
""" Stubs out the VMWareAPISession's is_vim_object method """ """Stubs out the VMWareAPISession's is_vim_object method."""
return isinstance(module, fake.FakeVim) return isinstance(module, fake.FakeVim)
def set_stubs(stubs): def set_stubs(stubs):
""" Set the stubs """ """Set the stubs."""
stubs.Set(vmware_images, 'fetch_image', fake.fake_fetch_image) stubs.Set(vmware_images, 'fetch_image', fake.fake_fetch_image)
stubs.Set(vmware_images, 'get_vmdk_size_and_properties', stubs.Set(vmware_images, 'get_vmdk_size_and_properties',
fake.fake_get_vmdk_size_and_properties) fake.fake_get_vmdk_size_and_properties)