Skip to content

Commit

Permalink
Merge pull request #964 from MirantisWorkloadMobility/devel
Browse files Browse the repository at this point in the history
Release 2016-04-11
  • Loading branch information
MirantisWorkloadMobility committed Apr 10, 2016
2 parents d7d35d5 + dd0d61e commit 524c416
Show file tree
Hide file tree
Showing 36 changed files with 1,166 additions and 620 deletions.
26 changes: 14 additions & 12 deletions cloudferry_devlab/cloudferry_devlab/generate_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from cloudferry_devlab.tests import cleanup
import cloudferry_devlab.tests.config as conf

TIMEOUT = 600
VM_SPAWNING_LIMIT = 5
CREATE_CLEAN_METHODS_MAP = {
'create_tenants': 'clean_tenants',
Expand Down Expand Up @@ -214,13 +213,13 @@ def _get_body_for_image_creating(_image):
dst_img_ids.append(dst_img_id)

self.wait_until_objects_created(img_ids, self.check_image_state,
TIMEOUT)
conf.TIMEOUT)

if dst_img_ids and self.dst_cloud:
self.wait_until_objects_created(
dst_img_ids,
self.chech_image_state_on_dst,
TIMEOUT)
conf.TIMEOUT)

tenant_list = self.keystoneclient.tenants.list()
for image_id in img_ids:
Expand Down Expand Up @@ -366,7 +365,7 @@ def wait_for_vm_creating():
set limit for vm spawning.
"""
spawning_vms = None
for _ in range(TIMEOUT):
for _ in range(conf.TIMEOUT):
all_vms = self.novaclient.servers.list(
search_opts={'all_tenants': 1})
spawning_vms = [vm.id for vm in all_vms
Expand All @@ -378,7 +377,7 @@ def wait_for_vm_creating():
else:
raise RuntimeError(
'VMs with ids {0} were in "BUILD" state more than {1} '
'seconds'.format(spawning_vms, TIMEOUT))
'seconds'.format(spawning_vms, conf.TIMEOUT))

def create_vms(vm_list):
vm_ids = []
Expand All @@ -390,7 +389,7 @@ def create_vms(vm_list):
if not vm.get('fip'):
continue
self.wait_until_objects_created([_vm.id], self.check_vm_state,
TIMEOUT)
conf.TIMEOUT)
fip = self.neutronclient.create_floatingip(
{"floatingip": {"floating_network_id": self.ext_net_id}})
_vm.add_floating_ip(fip['floatingip']['floating_ip_address'])
Expand Down Expand Up @@ -432,7 +431,7 @@ def create_vms(vm_list):

self.switch_user(user=self.username, password=self.password,
tenant=self.tenant)
self.wait_until_objects_created(vms, self.check_vm_state, TIMEOUT)
self.wait_until_objects_created(vms, self.check_vm_state, conf.TIMEOUT)

def create_vm_snapshots(self):

Expand All @@ -445,7 +444,7 @@ def create_vm_snapshots(self):
snapshot['image_name']))
snp_ids.append(snp.id)
self.wait_until_objects_created(snp_ids, self.check_snapshot_state,
TIMEOUT)
conf.TIMEOUT)

def create_networks(self, networks):

Expand Down Expand Up @@ -637,7 +636,10 @@ def wait_until_vms_with_fip_accessible(_vm_id):
fip_addr = self.migration_utils.get_vm_fip(vm)
except RuntimeError:
return
self.migration_utils.wait_until_vm_accessible_via_ssh(fip_addr)
base.BasePrerequisites.wait_until_objects_created(
[(fip_addr, 'pwd')],
self.migration_utils.wait_until_vm_accessible_via_ssh,
conf.TIMEOUT)

def get_params_for_volume_creating(_volume):
params = ['display_name', 'size', 'imageRef', 'metadata']
Expand Down Expand Up @@ -665,7 +667,7 @@ def get_params_for_volume_creating(_volume):
self.switch_user(user=self.username, password=self.password,
tenant=self.tenant)
self.wait_until_objects_created(vlm_ids, self.check_volume_state,
TIMEOUT)
conf.TIMEOUT)
vlm_ids = []
for volume in volumes_list:
if 'server_to_attach' not in volume:
Expand All @@ -678,7 +680,7 @@ def get_params_for_volume_creating(_volume):
server_id=vm_id, volume_id=vlm_id, device=volume['device'])
vlm_ids.append(vlm_id)
self.wait_until_objects_created(vlm_ids, self.check_volume_state,
TIMEOUT)
conf.TIMEOUT)

def create_cinder_snapshots(self, snapshot_list):
for snapshot in snapshot_list:
Expand Down Expand Up @@ -810,7 +812,7 @@ def emulate_vm_states(self):
def generate_vm_state_list(self):
data = {}
for vm in self.novaclient.servers.list(search_opts={'all_tenants': 1}):
for _ in range(TIMEOUT):
for _ in range(conf.TIMEOUT):
_vm = self.novaclient.servers.get(vm.id)
if _vm.status != u'RESIZE':
break
Expand Down
4 changes: 4 additions & 0 deletions cloudferry_devlab/cloudferry_devlab/tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

INVALID_STATUSES = ['creating', 'error', 'deleting', 'error_deleting']

TIMEOUT = 600
"""Timeout to wait for Openstack objects to create/update/be accessible.
Value in second."""

img_url = 'http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img'
username_for_ssh = 'cirros'
"""Username for ssh access for cirros image"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from nose.plugins.attrib import attr

import cloudferry_devlab.tests.config as config
import cloudferry_devlab.tests.base as base
from cloudferry_devlab.tests import functional_test
from cloudferry_devlab.tests import test_exceptions

Expand Down Expand Up @@ -657,7 +658,10 @@ def check_mount_point_exists(ip, vol):
vm_ip = self.migration_utils.get_vm_fip(vm)
self.migration_utils.open_ssh_port_secgroup(self.dst_cloud,
vm.tenant_id)
self.migration_utils.wait_until_vm_accessible_via_ssh(vm_ip)
base.BasePrerequisites.wait_until_objects_created(
[(vm_ip, 'pwd')],
self.migration_utils.wait_until_vm_accessible_via_ssh,
config.TIMEOUT)
check_mount_point_exists(vm_ip, volume)
cmd = 'mount {0} {1}'.format(volume['device'],
volume['mount_point'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import cloudferry_devlab.tests.config as config
from cloudferry_devlab.tests import functional_test

TIMEOUT = 600
TEST_TENANT_NAME = 'tenant4'
TEST_EXT_ROUTER_NAME = 'ext_router'
TEST_VM_NAME = 'VMtoVerifyDstCloudFunc'
Expand Down Expand Up @@ -288,14 +287,15 @@ def test_cinder_volume(self):
successfully."""
vm = self.dst_cloud.novaclient.servers.create(**self.TST_IMAGE)
base.BasePrerequisites.wait_until_objects_created(
[vm], self.check_vm_state, TIMEOUT)
[vm], self.check_vm_state, config.TIMEOUT)

vm.add_floating_ip(self.float_ip_address)

base.BasePrerequisites.wait_until_objects_created(
[(vm, self.float_ip_address)],
base.BasePrerequisites.check_floating_ip_assigned, TIMEOUT)
self.wait_service_on_vm_to_be_ready(TIMEOUT, self.float_ip_address,
base.BasePrerequisites.check_floating_ip_assigned, config.TIMEOUT)
self.wait_service_on_vm_to_be_ready(config.TIMEOUT,
self.float_ip_address,
DEFAULT_SERVICE_PORT, vm)

CINDER_VOLUME_PARAMS['server_to_attach'] = vm.name
Expand All @@ -313,14 +313,15 @@ def test_create_vm(self):
"""Validate destination cloud's VMs running successfully."""
vm = self.dst_cloud.novaclient.servers.create(**self.TST_IMAGE)
base.BasePrerequisites.wait_until_objects_created(
[vm], self.check_vm_state, TIMEOUT)
[vm], self.check_vm_state, config.TIMEOUT)

vm.add_floating_ip(self.float_ip_address)

base.BasePrerequisites.wait_until_objects_created(
[(vm, self.float_ip_address)],
base.BasePrerequisites.check_floating_ip_assigned, TIMEOUT)
self.wait_service_on_vm_to_be_ready(TIMEOUT, self.float_ip_address,
base.BasePrerequisites.check_floating_ip_assigned, config.TIMEOUT)
self.wait_service_on_vm_to_be_ready(config.TIMEOUT,
self.float_ip_address,
DEFAULT_SERVICE_PORT, vm)

status_msg, status_state = self.check_vm_ssh_access(
Expand Down
19 changes: 6 additions & 13 deletions cloudferry_devlab/cloudferry_devlab/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import collections
import time

from fabric import api as fabric_api
from fabric import network
Expand All @@ -22,8 +21,6 @@

import cloudferry_devlab.tests.config as config

VM_ACCESSIBILITY_ATTEMPTS = 20


def convert(data):
""" Method converts all unicode objects to string objects"""
Expand Down Expand Up @@ -176,16 +173,12 @@ def get_all_images_from_config(self):
images.append(image)
return images

def wait_until_vm_accessible_via_ssh(self, ip_addr):
for _ in range(VM_ACCESSIBILITY_ATTEMPTS):
try:
self.execute_command_on_vm(ip_addr, 'pwd')
break
except RuntimeError:
time.sleep(1)
else:
msg = 'VM with ip "{}" is not accessible via ssh after {} attempts'
raise RuntimeError(msg.format(ip_addr, VM_ACCESSIBILITY_ATTEMPTS))
def wait_until_vm_accessible_via_ssh(self, ip_addr, cmd):
try:
self.execute_command_on_vm(ip_addr, cmd)
except RuntimeError:
return False
return True

@staticmethod
def open_ssh_port_secgroup(client, tenant_id):
Expand Down
25 changes: 8 additions & 17 deletions cloudferry_devlab/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
ecdsa
oslo.i18n==1.5.0
stevedore==1.5.0
oslo.serialization==1.4.0
debtcollector==0.3.0
cliff==1.4.3
oslo.config==1.15.0
oslo.utils==1.9.0
fabric>=1.8.2
pycrypto
python-cinderclient==1.1.0
python-glanceclient==0.12.0
oslo.utils==3.5.0
python-cinderclient==1.3.1
python-glanceclient==1.1.0
python-keystoneclient==1.6.0
python-neutronclient==2.3.4
python-novaclient==2.20.0
python-neutronclient==2.6.0
python-novaclient==2.25.0
python-swiftclient==2.3.1
pyyaml
pyyaml==3.11
nose==1.3.7
nose-testconfig==0.9.1
sqlalchemy
PyMySQL==0.6.7
sqlalchemy==1.0.12
PyMySQL==0.6.7
4 changes: 2 additions & 2 deletions cloudferrylib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Schema(marshmallow.Schema):
credential = fields.Nested(Credential.Schema)
scope = fields.Nested(Scope.Schema)
ssh_settings = fields.Nested(SshSettings.Schema, load_from='ssh')
discover = OneOrMore(fields.String(), default=MODEL_LIST)
discover = OneOrMore(fields.String(), missing=MODEL_LIST)

@marshmallow.post_load
def to_cloud(self, data):
Expand Down Expand Up @@ -232,7 +232,7 @@ class Schema(marshmallow.Schema):
@marshmallow.validates_schema(skip_on_field_errors=True)
def check_migration_have_correct_source_and_dict(self, data):
clouds = data['clouds']
migrations = data['migrations']
migrations = data.get('migrations', {})
for migration_name, migration in migrations.items():
if migration.source not in clouds:
raise marshmallow.ValidationError(
Expand Down
10 changes: 2 additions & 8 deletions cloudferrylib/os/actions/instance_floatingip_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import copy

from cloudferrylib.base.action import action
from cloudferrylib.os.network import network_utils
from cloudferrylib.utils import utils as utl


Expand All @@ -30,16 +31,9 @@ class AssociateFloatingip(action.Action):

def run(self, info=None, **kwargs):
if self.cfg.migrate.keep_floatingip:
info_compute = copy.deepcopy(info)
network_resource = self.cloud.resources[utl.NETWORK_RESOURCE]
network_utils.associate_floatingip(info, network_resource)

instance = info_compute[utl.INSTANCES_TYPE].values()[0]
networks_info = instance[utl.INSTANCE_BODY].get('nics', [])
for net in networks_info:
fip = net.get('floatingip')
if fip is not None:
network_resource.update_floatingip(
fip['dst_floatingip_id'], fip['dst_port_id'])
return {}


Expand Down
12 changes: 6 additions & 6 deletions cloudferrylib/os/actions/is_not_copy_diff_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def run(self, info=None, **kwargs):
dst_compute = self.dst_cloud.resources[utl.COMPUTE_RESOURCE]
backend_ephem_drv_src = src_compute.config.compute.backend
backend_ephem_drv_dst = dst_compute.config.compute.backend
instance_boot = \
info[INST].values()[0][BODY]['boot_mode']
if ((instance_boot == utl.BOOT_FROM_IMAGE) and
(backend_ephem_drv_src == ISCSI) and
(backend_ephem_drv_dst == ISCSI)):
self.set_next_path(PATH_COPY_DIFF)
for instance in info[INST].values():
instance_boot = instance[BODY]['boot_mode']
if ((instance_boot == utl.BOOT_FROM_IMAGE) and
(backend_ephem_drv_src == ISCSI) and
(backend_ephem_drv_dst == ISCSI)):
self.set_next_path(PATH_COPY_DIFF)
return {}
Loading

0 comments on commit 524c416

Please sign in to comment.