* 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.
"""
Test suite for VMWareAPI
Test suite for VMWareAPI.
"""
import stubout
from nova import context
@@ -38,9 +39,7 @@ FLAGS = flags.FLAGS
class VMWareAPIVMTestCase(test.TestCase):
"""
Unit tests for Vmware API connection calls
"""
"""Unit tests for Vmware API connection calls."""
def setUp(self):
super(VMWareAPIVMTestCase, self).setUp()
@@ -61,7 +60,7 @@ class VMWareAPIVMTestCase(test.TestCase):
self.conn = vmwareapi_conn.get_connection(False)
def _create_vm(self):
""" Create and spawn the VM """
"""Create and spawn the VM."""
values = {'name': 1,
'id': 1,
'project_id': self.project.id,
@@ -78,15 +77,17 @@ class VMWareAPIVMTestCase(test.TestCase):
self._check_vm_record()
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()
self.assertEquals(len(instances), 1)
# Get Nova record for VM
vm_info = self.conn.get_info(1)
# Get record for VMs
# Get record for VM
vms = vmwareapi_fake._get_objects("VirtualMachine")
vm = vms[0]
@@ -106,8 +107,10 @@ class VMWareAPIVMTestCase(test.TestCase):
self.assertEquals(vm.get("runtime.powerState"), 'poweredOn')
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
self.assertEquals(info["state"], pwr_state)
self.assertEquals(info["max_mem"], mem_kib)
@@ -194,8 +197,9 @@ class VMWareAPIVMTestCase(test.TestCase):
pass
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
def tearDown(self):

View File

@@ -14,3 +14,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# 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):
""" Stubs out the db API for creating Instances """
"""Stubs out the db API for creating Instances."""
INSTANCE_TYPES = {
'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)}
class FakeModel(object):
""" Stubs out for model """
"""Stubs out for model."""
def __init__(self, values):
self.values = values
@@ -53,7 +53,7 @@ def stub_out_db_instance_api(stubs):
raise NotImplementedError()
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']]
@@ -77,7 +77,7 @@ def stub_out_db_instance_api(stubs):
return FakeModel(base_options)
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 = {
'bridge': 'vmnet0',
@@ -87,11 +87,11 @@ def stub_out_db_instance_api(stubs):
return FakeModel(fields)
def fake_instance_action_create(context, action):
""" Stubs out the db.instance_action_create method """
"""Stubs out the db.instance_action_create method."""
pass
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'
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):
""" Stubs out the VMWareAPISession's get_vim_object method """
"""Stubs out the VMWareAPISession's get_vim_object method."""
return fake.FakeVim()
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)
def set_stubs(stubs):
""" Set the stubs """
"""Set the stubs."""
stubs.Set(vmware_images, 'fetch_image', fake.fake_fetch_image)
stubs.Set(vmware_images, 'get_vmdk_size_and_properties',
fake.fake_get_vmdk_size_and_properties)