def add_zone_resource(deploy_config, zone_name): session_uuid = acc_ops.login_as_admin() try: dep_ops.add_zone(deploy_config, session_uuid, zone_name=zone_name) dep_ops.add_l2_network(deploy_config, session_uuid, \ zone_name = zone_name) dep_ops.add_primary_storage(deploy_config, session_uuid, \ zone_name = zone_name) dep_ops.add_cluster(deploy_config, session_uuid, \ zone_name = zone_name) dep_ops.add_host(deploy_config, session_uuid, \ zone_name = zone_name) dep_ops.add_l3_network(deploy_config, session_uuid, \ zone_name = zone_name) dep_ops.add_virtual_router(deploy_config, session_uuid, \ zone_name = zone_name) zone = res_ops.get_resource(res_ops.ZONE, session_uuid, \ name = zone_name)[0] except Exception as e: test_util.test_logger( '[Error] zstack deployment meets exception when adding zone resource .' ) traceback.print_exc(file=sys.stdout) raise e finally: acc_ops.logout(session_uuid) test_util.action_logger('Complete add zone resources for [uuid:] %s' \ % zone.uuid)
def add_l3_resource(deploy_config, l3_name, l2_name = None, zone_name = None, \ session_uuid = None): session_uuid_flag = True if not session_uuid: session_uuid = acc_ops.login_as_admin() session_uuid_flag = False try: dep_ops.add_l3_network(None, None, deploy_config, session_uuid, l3_name = l3_name, \ l2_name = l2_name, zone_name = zone_name) dep_ops.add_virtual_router(None, None, deploy_config, session_uuid, \ l3_name = l3_name, zone_name = zone_name) l3_uuid = res_ops.get_resource(res_ops.L3_NETWORK, session_uuid, \ name = l3_name)[0].uuid except Exception as e: test_util.test_logger( '[Error] zstack deployment meets exception when adding l3 resource .' ) traceback.print_exc(file=sys.stdout) raise e finally: if not session_uuid_flag: acc_ops.logout(session_uuid) test_util.action_logger('Complete add l3 resources for [uuid:] %s' \ % l3_uuid)
def add_zone_resource(deploy_config, zone_name): session_uuid = acc_ops.login_as_admin() try: test_util.test_dsc('-------add zone operation-------') dep_ops.add_zone(deploy_config, session_uuid, zone_name = zone_name) test_util.test_dsc('-------add l2 operation-------') dep_ops.add_l2_network(deploy_config, session_uuid, \ zone_name = zone_name) test_util.test_dsc('-------add primary stroage operation-------') dep_ops.add_primary_storage(deploy_config, session_uuid, \ zone_name = zone_name) test_util.test_dsc('-------add cluster operation-------') dep_ops.add_cluster(deploy_config, session_uuid, \ zone_name = zone_name) test_util.test_dsc('-------add host operation-------') dep_ops.add_host(deploy_config, session_uuid, \ zone_name = zone_name) test_util.test_dsc('-------add l3 operation-------') dep_ops.add_l3_network(deploy_config, session_uuid, \ zone_name = zone_name) test_util.test_dsc('-------add virtual router offering operation-------') dep_ops.add_virtual_router(deploy_config, session_uuid, \ zone_name = zone_name) zone = res_ops.get_resource(res_ops.ZONE, session_uuid, \ name = zone_name)[0] except Exception as e: test_util.test_logger('[Error] zstack deployment meets exception when adding zone resource .') traceback.print_exc(file=sys.stdout) raise e finally: acc_ops.logout(session_uuid) test_util.action_logger('Complete add zone resources for [uuid:] %s' \ % zone.uuid)
def error_cleanup(): global deploy_conf global vm_inv global vm cond = res_ops.gen_query_conditions('zone.vmInstance.uuid', '=', vm_inv.uuid) if len(res_ops.query_resource(res_ops.VR_OFFERING, cond)) == 0: session_uuid = acc_ops.login_as_admin() dep_ops.add_virtual_router(deploy_conf, session_uuid) vm.reboot() test_lib.lib_error_cleanup(test_obj_dict)
def add_l2_resource(deploy_config, l2_name, zone_name = None, \ session_uuid = None): session_uuid_flag = True if not session_uuid: session_uuid = acc_ops.login_as_admin() session_uuid_flag = False try: dep_ops.add_l2_network(deploy_config, session_uuid, l2_name, \ zone_name = zone_name) l2_uuid = res_ops.get_resource(res_ops.L2_NETWORK, session_uuid, \ name = l2_name)[0].uuid for zone in xmlobject.safe_list(deploy_config.zones.zone): if zone_name and zone_name != zone.name_: continue for cluster in xmlobject.safe_list(zone.clusters.cluster): if xmlobject.has_element(cluster, 'l2NetworkRef'): for l2ref in xmlobject.safe_list(cluster.l2NetworkRef): if l2_name != l2ref.text_: continue cluster_uuid = res_ops.get_resource(res_ops.CLUSTER, \ session_uuid, name=cluster.name_)[0].uuid attach_l2(l2_uuid, cluster_uuid, session_uuid) dep_ops.add_l3_network(None, None, deploy_config, session_uuid, l2_name = l2_name, \ zone_name = zone_name) cond = res_ops.gen_query_conditions('l2NetworkUuid', '=', l2_uuid) l3_name = res_ops.query_resource(res_ops.L3_NETWORK, cond, \ session_uuid)[0].name dep_ops.add_virtual_router(None, None, deploy_config, session_uuid, \ l3_name = l3_name, zone_name = zone_name) except Exception as e: test_util.test_logger( '[Error] zstack deployment meets exception when adding l2 resource .' ) traceback.print_exc(file=sys.stdout) raise e finally: if not session_uuid_flag: acc_ops.logout(session_uuid) test_util.action_logger('Complete add l2 resources for [uuid:] %s' \ % l2_uuid)
def add_l2_resource(deploy_config, l2_name, zone_name = None, \ session_uuid = None): session_uuid_flag = True if not session_uuid: session_uuid = acc_ops.login_as_admin() session_uuid_flag = False try: dep_ops.add_l2_network(deploy_config, session_uuid, l2_name, \ zone_name = zone_name) l2_uuid = res_ops.get_resource(res_ops.L2_NETWORK, session_uuid, \ name = l2_name)[0].uuid for zone in xmlobject.safe_list(deploy_config.zones.zone): if zone_name and zone_name != zone.name_: continue for cluster in xmlobject.safe_list(zone.clusters.cluster): if xmlobject.has_element(cluster, 'l2NetworkRef'): for l2ref in xmlobject.safe_list(cluster.l2NetworkRef): if l2_name != l2ref.text_: continue cluster_uuid = res_ops.get_resource(res_ops.CLUSTER, \ session_uuid, name=cluster.name_)[0].uuid attach_l2(l2_uuid, cluster_uuid, session_uuid) dep_ops.add_l3_network(None, None, deploy_config, session_uuid, l2_name = l2_name, \ zone_name = zone_name) cond = res_ops.gen_query_conditions('l2NetworkUuid', '=', l2_uuid) l3_name = res_ops.query_resource(res_ops.L3_NETWORK, cond, \ session_uuid)[0].name dep_ops.add_virtual_router(None, None, deploy_config, session_uuid, \ l3_name = l3_name, zone_name = zone_name) except Exception as e: test_util.test_logger('[Error] zstack deployment meets exception when adding l2 resource .') traceback.print_exc(file=sys.stdout) raise e finally: if not session_uuid_flag: acc_ops.logout(session_uuid) test_util.action_logger('Complete add l2 resources for [uuid:] %s' \ % l2_uuid)
def test(): global deploy_conf global vm_inv global vm test_util.test_dsc('Test Delete VR Offering and Teboot Normal VM') vm = test_stub.create_basic_vm() test_obj_dict.add_vm(vm) vm_inv = vm.get_vm() vm_ip = vm_inv.vmNics[0].ip vm.check() test_util.test_dsc('Record current virtual router offering information') deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) cond = res_ops.gen_query_conditions('zone.vmInstance.uuid', '=', vm_inv.uuid) vr_offering_uuid = res_ops.query_resource(res_ops.VR_OFFERING, cond)[0].uuid test_util.test_dsc('Delete VR-RM and VR-Offering') cond = res_ops.gen_query_conditions('zone.vmInstance.uuid', '=', vm_inv.uuid) vr_vm_uuid = res_ops.query_resource(res_ops.VIRTUALROUTER_VM, cond)[0].uuid vm_ops.destroy_vm(vr_vm_uuid) vm_ops.delete_instance_offering(vr_offering_uuid) test_util.test_dsc( 'Create new VR-Offering, same as the former one, stop and start VM') session_uuid = acc_ops.login_as_admin() dep_ops.add_virtual_router(None, None, deploy_conf, session_uuid) vm.reboot() vm.destroy() test_obj_dict.rm_vm(vm) test_util.test_pass('Delete VR Offering and reboot normal VM: SUCCESS')
def add_l3_resource(deploy_config, l3_name, l2_name = None, zone_name = None, \ session_uuid = None): session_uuid_flag = True if not session_uuid: session_uuid = acc_ops.login_as_admin() session_uuid_flag = False try: dep_ops.add_l3_network(None, None, deploy_config, session_uuid, l3_name = l3_name, \ l2_name = l2_name, zone_name = zone_name) dep_ops.add_virtual_router(None, None, deploy_config, session_uuid, \ l3_name = l3_name, zone_name = zone_name) l3_uuid = res_ops.get_resource(res_ops.L3_NETWORK, session_uuid, \ name = l3_name)[0].uuid except Exception as e: test_util.test_logger('[Error] zstack deployment meets exception when adding l3 resource .') traceback.print_exc(file=sys.stdout) raise e finally: if not session_uuid_flag: acc_ops.logout(session_uuid) test_util.action_logger('Complete add l3 resources for [uuid:] %s' \ % l3_uuid)
def test(): global deploy_conf global vm_inv global vm test_util.test_dsc('Test Delete VR Offering and Teboot Normal VM') vm = test_stub.create_basic_vm() test_obj_dict.add_vm(vm) vm_inv = vm.get_vm() vm_ip = vm_inv.vmNics[0].ip vm.check() test_util.test_dsc('Record current virtual router offering information') deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) cond = res_ops.gen_query_conditions('zone.vmInstance.uuid', '=', vm_inv.uuid) vr_offering_uuid = res_ops.query_resource(res_ops.VR_OFFERING, cond)[0].uuid test_util.test_dsc('Delete VR-RM and VR-Offering') cond = res_ops.gen_query_conditions('zone.vmInstance.uuid', '=', vm_inv.uuid) vr_vm_uuid = res_ops.query_resource(res_ops.VIRTUALROUTER_VM, cond)[0].uuid vm_ops.destroy_vm(vr_vm_uuid) vm_ops.delete_instance_offering(vr_offering_uuid) test_util.test_dsc('Create new VR-Offering, same as the former one, stop and start VM') session_uuid = acc_ops.login_as_admin() dep_ops.add_virtual_router(None, None, deploy_conf, session_uuid) vm.reboot() vm.destroy() test_obj_dict.rm_vm(vm) test_util.test_pass('Delete VR Offering and reboot normal VM: SUCCESS')