def error_cleanup():
    global curr_deploy_conf
    test_lib.lib_error_cleanup(test_obj_dict)
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0]
    if not l3_2:
        try:
            net_ops.add_l3_resource(curr_deploy_conf, l3_name = l3_2.name)
        except Exception as e:
            test_util.test_warn('Fail to recover [l3:] %s resource. It will impact later test case.' % l3_name2)
            raise e
Example #2
0
def error_cleanup():
    global curr_deploy_conf
    global l3_name
    global l3
    test_lib.lib_error_cleanup(test_obj_dict)
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)
    if not l3s:
        try:
            net_ops.add_l3_resource(curr_deploy_conf, l3_name)
        except Exception as e:
            test_util.test_warn('Fail to recover [l3:] %s resource. It will impact later test case.' % l3_name)
            raise e
Example #3
0
def test():
    global curr_deploy_conf
    global l3_name
    global l3
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)
    test_util.test_dsc('Create test vm and delete l3.')
    l3_name = os.environ.get('l3VlanNetworkName1')
    l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0]
    vm = test_stub.create_vlan_vm(l3_name)
    test_obj_dict.add_vm(vm)
    vm.check()
    net_ops.delete_l3(l3.uuid)
    if len(test_lib.lib_find_vr_by_l3_uuid(l3.uuid)) != 0:
        test_util.test_fail('VR VM should be delete when associated L3 is deleted')

    vm.destroy()
    net_ops.add_l3_resource(curr_deploy_conf, l3_name)

    test_util.test_pass('Create VirtualRouter VM delete l3 Test Success')
def test():
    global curr_deploy_conf
    global l3_1
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name1)[0]
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid

    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING,
                                                    conditions)[0].uuid
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    test_util.test_dsc('Delete l3_1')
    net_ops.delete_l3(l3_1.uuid)

    #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic.
    #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED)
    #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED)

    #vm1.set_state(vm_header.DESTROYED)
    #vm2.set_state(vm_header.DESTROYED)

    vm1.check()
    vm2.check()

    net_ops.add_l3_resource(curr_deploy_conf, l3_name=l3_1.name)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete L3 Test 2 Success')
def test():
    global curr_deploy_conf
    global l3_1
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name1)[0]
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid

    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    test_util.test_dsc('Delete l3_1')
    net_ops.delete_l3(l3_1.uuid)

    #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic. 
    #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED)
    #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED)

    #vm1.set_state(vm_header.DESTROYED)
    #vm2.set_state(vm_header.DESTROYED)

    vm1.check()
    vm2.check()

    net_ops.add_l3_resource(curr_deploy_conf, l3_name = l3_1.name)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete L3 Test 2 Success')
def test():
    global curr_deploy_conf
    global l3_2
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name2)[0]
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(
        test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up l3
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name1)[0]

    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING,
                                                    conditions)[0].uuid
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    test_util.test_dsc('Delete l3_2')
    net_ops.delete_l3(l3_2.uuid)

    #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic.
    #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    #vm1.set_state(vm_header.STOPPED)
    vm2.update()
    #vm2.set_state(vm_header.STOPPED)

    vm1.check()
    vm2.check()

    #test_util.test_dsc('start vm again. vm should remove the deleted l3')
    #vm1.start()
    #vm2.start()

    net_ops.add_l3_resource(curr_deploy_conf, l3_name=l3_2.name)

    #update l3_2, since it is readded.
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name2)[0]
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

    #check vm1 vm2 status.
    vm1.check()
    vm2.check()

    if not len(vm1.get_vm().vmNics) == 1:
        test_util.test_fail(
            'vm1 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid)

    if not len(vm2.get_vm().vmNics) == 1:
        test_util.test_fail(
            'vm2 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid)

    #check vm3 status
    vm3.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete L3 Test Success')
def env_recover():
    global curr_deploy_conf
    global test_obj_dict
    global l3_name
    test_lib.lib_error_cleanup(test_obj_dict)
    net_ops.add_l3_resource(curr_deploy_conf, l3_name)
def test():
    global curr_deploy_conf
    global l3_2
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0]
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up l3
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name1)[0]

    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    test_util.test_dsc('Delete l3_2')
    net_ops.delete_l3(l3_2.uuid)

    #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic. 
    #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    #vm1.set_state(vm_header.STOPPED)
    vm2.update()
    #vm2.set_state(vm_header.STOPPED)

    vm1.check()
    vm2.check()

    #test_util.test_dsc('start vm again. vm should remove the deleted l3')
    #vm1.start()
    #vm2.start()

    net_ops.add_l3_resource(curr_deploy_conf, l3_name = l3_2.name)

    #update l3_2, since it is readded.
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0]
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    vm3 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm3)

    #check vm1 vm2 status.
    vm1.check()
    vm2.check()

    if not len(vm1.get_vm().vmNics) == 1:
        test_util.test_fail('vm1 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid)

    if not len(vm2.get_vm().vmNics) == 1:
        test_util.test_fail('vm2 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid)

    #check vm3 status
    vm3.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete L3 Test Success')