Пример #1
0
def error_cleanup():
    global vm1_inv
    global vm2_inv

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm1_inv.uuid)
    sce_ops.destroy_vm(zstack_management_ip, vm2_inv.uuid)
    test_lib.lib_error_cleanup(test_obj_dict)
def error_cleanup():
    global vm1_inv
    global vm2_inv
    
    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm1_inv.uuid)
    sce_ops.destroy_vm(zstack_management_ip, vm2_inv.uuid)
    test_lib.lib_error_cleanup(test_obj_dict)
def error_cleanup():
    global vm_inv
    global zone_inv
    global cluster_inv
    global host_inv

    test_util.test_dsc('Create test vm to test zstack install MN on centos7.1 and add the HOST')
    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm_inv.uuid)
    test_lib.lib_error_cleanup(test_obj_dict)
Пример #4
0
def error_cleanup():
    global vm_inv
    global zone_inv
    global cluster_inv
    global host_inv

    test_util.test_dsc('Create test vm to test zstack install MN on centos7.1 and add the HOST')
    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm_inv.uuid)
    test_lib.lib_error_cleanup(test_obj_dict)
def test():
    global vm_inv
    test_util.test_dsc(
        'Create test vm to test zstack upgrade and re-install with -r.')

    conditions = res_ops.gen_query_conditions(
        'name', 'like', os.environ.get('imageNameBase_o'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]

    vm_inv = create_vm(image)

    time.sleep(60)

    test_util.test_dsc('Install zstack with -o -r -I')
    vm_ip = vm_inv.vmNics[0].ip
    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, target_file)
    ssh_cmd = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    args = "-o -r /home/zstack-test -I eth0"
    test_stub.execute_install_with_args(ssh_cmd, args, target_file, tmp_file)
    ins_path = "/home/zstack-test"
    check_installtion_path(ssh_cmd, ins_path)
    test_stub.check_installation(ssh_cmd, tmp_file, vm_inv)

    test_util.test_dsc('Upgrade zstack to latest')
    upgrade_target_file = '/root/zstack-upgrade-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, upgrade_target_file)
    test_stub.upgrade_zstack(ssh_cmd, upgrade_target_file, tmp_file)
    check_installtion_path(ssh_cmd, ins_path)
    test_stub.check_installation(ssh_cmd, tmp_file, vm_inv)

    test_util.test_dsc('Install zstack with default path')
    cmd = '%s "[ -e /usr/local/zstack ] && echo yes || echo no"' % ssh_cmd
    (process_result,
     cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
    if process_result != 0:
        test_util.test_fail('check /usr/local/zstack fail, cmd_stdout:%s' %
                            cmd_stdout)
    cmd_stdout = cmd_stdout[:-1]
    if cmd_stdout == "yes":
        cmd = '%s "rm -rf /usr/local/zstack"' % ssh_cmd
        (process_result,
         cmd_stdout) = test_stub.execute_shell_in_process_stdout(
             cmd, tmp_file)
        if process_result != 0:
            test_util.test_fail('delete /usr/local/zstack fail')
    args = "-D"
    test_stub.execute_install_with_args(ssh_cmd, args, target_file, tmp_file)
    ins_path = "/usr/local/zstack"
    check_installtion_path(ssh_cmd, ins_path)
    test_stub.check_installation(ssh_cmd, tmp_file, vm_inv)

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm_inv.uuid)
    test_util.test_pass('Install ZStack with -R aliyun -r -I Success')
def test():
    global vm_inv
    test_util.test_dsc('Create test vm to test zstack upgrade and re-install with -r.')

    conditions = res_ops.gen_query_conditions('name', '=', os.environ.get('imageNameBase_10'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]
    vm_inv = create_vm(image)
    time.sleep(60)
    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc('Install zstack with -o -r -I')
    vm_ip = vm_inv.vmNics[0].ip
    test_stub.make_ssh_no_password(vm_ip, tmp_file)
    test_util.test_dsc('Upgrade master iso')   
    test_stub.update_iso(vm_ip, tmp_file, iso_path, upgrade_script_path)

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, target_file)
    ssh_cmd = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    args = "-o -r /home/zstack-test -I eth0"
    test_stub.execute_install_with_args(ssh_cmd, args, target_file, tmp_file)
    ins_path = "/home/zstack-test"
    check_installtion_path(ssh_cmd, ins_path)
    test_stub.check_installation(vm_ip, tmp_file)
    test_stub.stop_mn(vm_ip, tmp_file)
     
    #test_util.test_dsc('Upgrade zstack to latest') 
    #upgrade_target_file = '/root/zstack-upgrade-all-in-one.tgz' 
    #test_stub.prepare_test_env(vm_inv, upgrade_target_file)
    #test_stub.upgrade_zstack(vm_ip, upgrade_target_file, tmp_file) 
    ##check_installtion_path(ssh_cmd, ins_path)
    #test_stub.check_installation(vm_ip, tmp_file)

    test_util.test_dsc('Install zstack with default path')
    cmd= '%s "[ -e /usr/local/zstack ] && echo yes || echo no"' % ssh_cmd
    (process_result, cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
    if process_result != 0:
        test_util.test_fail('check /usr/local/zstack fail, cmd_stdout:%s' % cmd_stdout)
    cmd_stdout = cmd_stdout[:-1]   
    if cmd_stdout == "yes":
        cmd = '%s "rm -rf /usr/local/zstack"' % ssh_cmd
        (process_result, cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
        if process_result != 0:
            test_util.test_fail('delete /usr/local/zstack fail')
    args = "-D"
    test_stub.execute_install_with_args(ssh_cmd, args, target_file, tmp_file)
    ins_path = "/usr/local/zstack"
    check_installtion_path(ssh_cmd, ins_path)
    test_stub.check_installation(vm_ip, tmp_file)

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm_inv.uuid)
    test_util.test_pass('Install ZStack with -R aliyun -r -I Success')
def test():
    global vm_inv
    global zone_inv
    global cluster_inv
    global host_inv

    test_util.test_dsc(
        'Create test vm to test zstack install MN on centos7.2 and add the HOST'
    )

    conditions = res_ops.gen_query_conditions(
        'name', '=', os.environ.get('imageNameBase_c72'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]
    vm_inv = create_vm(image)
    time.sleep(100)
    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc('Install zstack with -o')
    vm_ip = vm_inv.vmNics[0].ip
    test_stub.make_ssh_no_password(vm_ip, tmp_file)
    test_util.test_dsc('Upgrade master iso')
    test_stub.update_iso(vm_ip, tmp_file, iso_path, upgrade_script_path)

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, target_file)
    ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    args = "-o"

    test_util.test_dsc('start installing the latest zstack-MN')

    test_stub.execute_install_with_args(ssh_cmd, args, target_file, tmp_file)

    test_util.test_dsc('check add the sftp bs and delete the sftp bs')
    test_stub.check_installation(vm_ip, tmp_file)

    test_util.test_dsc('create zone name is zone1')
    zone_inv = test_stub.create_zone1(vm_ip, tmp_file)
    zone_uuid = zone_inv.uuid

    test_util.test_dsc('create cluster name is clsuter1')

    cluster_inv = test_stub.create_cluster1(vm_ip, zone_uuid, tmp_file)
    cluster_uuid = cluster_inv.uuid

    test_util.test_dsc('add host name is HOST1')

    host_inv = test_stub.add_kvm_host1(vm_ip, cluster_uuid, tmp_file)
    host_uuid = host_inv.uuid

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm_inv.uuid)
    test_util.test_pass('Install ZStack with -o  centos7.2 mini-iso Success')
def test():
    global vm_inv
    global zone_inv
    global cluster_inv
    global host_inv

    test_util.test_dsc('Create test vm to test zstack install MN on centos7.1 and add the HOST')
    
    conditions = res_ops.gen_query_conditions('name', '=', os.environ.get('imageNameBase_c71'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]
    vm_inv = create_vm(image)
    time.sleep(100)
    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc('Install zstack with -o')

    vm_ip = vm_inv.vmNics[0].ip
    test_stub.make_ssh_no_password(vm_ip, tmp_file)
    test_util.test_dsc('Upgrade master iso')

    test_stub.update_iso(vm_ip, tmp_file, iso_path, upgrade_script_path)

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, target_file)
    ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    args = "-o"

    test_util.test_dsc('start install the latest zstack-MN')

    test_stub.execute_install_with_args(ssh_cmd, args, target_file, tmp_file)

    test_util.test_dsc('check the add the sftp BS and delete sftp bs')
    test_stub.check_installation(vm_ip, tmp_file)\

    test_util.test_dsc('create zone names is zone1')
    zone_inv = test_stub.create_zone1(vm_ip, tmp_file)
    zone_uuid = zone_inv.uuid

    test_util.test_dsc('create cluster names is clsuter1')
    cluster_inv = test_stub.create_cluster1(vm_ip, zone_uuid, tmp_file)
    cluster_uuid = cluster_inv.uuid

    test_util.test_dsc('add HOST names is HOST1')
    host_inv = test_stub.add_kvm_host1(vm_ip, cluster_uuid, tmp_file)
    host_uuid = host_inv.uuid

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm_inv.uuid)
    test_util.test_pass('Install ZStack with -o  Success')
Пример #9
0
def test():
    global vm_inv

    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')
    test_util.test_dsc(
        'Create test vm to test zstack installation with console proxy.')

    conditions = res_ops.gen_query_conditions(
        'name', '=', os.environ.get('imageNameBase_zstack'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]

    vm_inv = create_vm(image)

    time.sleep(60)

    vm_ip = vm_inv.vmNics[0].ip
    vip = '172.20.61.253'
    if vip == vm_ip:
        vip = '172.20.61.254'

    ssh_cmd = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    ssh.make_ssh_no_password(vm_ip, test_lib.lib_get_vm_username(vm_inv),
                             test_lib.lib_get_vm_password(vm_inv))
    cmd = '%s ifconfig eth0:0 %s up' % (ssh_cmd, vip)
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    test_stub.update_iso(vm_ip, tmp_file, iso_path, upgrade_script_path)

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, target_file)
    args = '-o -C %s -I %s' % (vip, vm_ip)
    test_stub.execute_install_with_args(ssh_cmd, args, target_file, tmp_file)
    test_stub.check_installation(vm_ip, tmp_file)

    cmd = '%s cat /usr/local/zstack/apache-tomcat/webapps/zstack/WEB-INF/classes/zstack.properties | grep \'consoleProxyOverriddenIp = %s\'' % (
        ssh_cmd, vip)
    (process_result,
     check_result) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
    check_result = check_result[:-1]
    test_util.test_dsc('cat result: |%s|' % check_result)
    expect_result = "consoleProxyOverriddenIp = %s" % vip
    if check_result != expect_result:
        test_util.test_fail('Fail to install ZStack with console proxy')

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm_inv.uuid)
    test_util.test_pass('ZStack installation Test Success')
def test():
    global vm_inv
    
    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')
    test_util.test_dsc('Create test vm to test zstack installation with console proxy.')

    conditions = res_ops.gen_query_conditions('name', '=', os.environ.get('imageNameBase_21_ex'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]

    vm_inv = create_vm(image) 

    time.sleep(60)

    vm_ip = vm_inv.vmNics[0].ip
    vip = '172.20.61.253'
    if vip == vm_ip:
        vip = '172.20.61.254'

    ssh_cmd = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    ssh.make_ssh_no_password(vm_ip, test_lib.lib_get_vm_username(vm_inv), test_lib.lib_get_vm_password(vm_inv))
    cmd = '%s ifconfig eth0:0 %s up' % (ssh_cmd, vip)
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    test_stub.update_iso(vm_ip, tmp_file, iso_path, upgrade_script_path)

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, target_file)
    args = '-o -C %s -I %s' % (vip, vm_ip)
    test_stub.execute_install_with_args(ssh_cmd, args, target_file, tmp_file)
    test_stub.check_installation(vm_ip, tmp_file)

    cmd = '%s cat /usr/local/zstack/apache-tomcat/webapps/zstack/WEB-INF/classes/zstack.properties | grep \'consoleProxyOverriddenIp = %s\'' % (ssh_cmd, vip)
    (process_result, check_result) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
    check_result = check_result[:-1]
    test_util.test_dsc('cat result: |%s|' % check_result)
    expect_result = "consoleProxyOverriddenIp = %s" % vip
    if check_result != expect_result:
        test_util.test_fail('Fail to install ZStack with console proxy')

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm_inv.uuid)    
    test_util.test_pass('ZStack installation Test Success')
def test():
    global vm1_inv
    global vm2_inv

    zstack_latest_version = os.environ.get('zstackLatestVersion')
    zstack_latest_path = os.environ.get('zstackLatestInstaller')

    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc('Create 2 CentOS7 vm to test install management node installation')

    conditions = res_ops.gen_query_conditions('name', '=', os.environ.get('imageNameBase_210_mn'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]
    
    conditions = res_ops.gen_query_conditions('name', '=', os.environ.get('imageNameBase_21_ex'))
    image1 = res_ops.query_resource(res_ops.IMAGE, conditions)[0]

    vm1_inv = create_vm(image) 
    vm2_inv = create_vm(image1)

    vm1_ip = vm1_inv.vmNics[0].ip
    vm2_ip = vm2_inv.vmNics[0].ip

    time.sleep(60)
    test_stub.make_ssh_no_password(vm1_ip, tmp_file)

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm1_inv, target_file)
    ssh_cmd1 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm1_ip
    ssh_cmd2 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm2_ip

    test_util.test_dsc('Update MN IP and check installation on vm1')
    test_stub.update_mn_hostname(vm1_ip, tmp_file)
    test_stub.update_mn_ip(vm1_ip, tmp_file)
    test_stub.start_mn(vm1_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Upgrade the latest master zstack')
    test_stub.update_iso(vm1_ip, tmp_file, iso_path, upgrade_script_path)
    test_stub.update_repo(vm1_ip, tmp_file)
    test_stub.upgrade_zstack(vm1_ip, zstack_latest_path, tmp_file)
    test_stub.check_zstack_version(vm1_ip, tmp_file, zstack_latest_version)
    test_stub.start_mn(vm1_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('only Install one management node on vm2')
    host_list = 'root:password@%s ' % vm2_ip
    cmd = '%s "zstack-ctl install_management_node --host=%s"' % (ssh_cmd1, host_list)
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    test_util.test_dsc('Check installation on vm1')
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Check installation on vm2 vm1')
    test_stub.make_ssh_no_password(vm2_ip, tmp_file)
    test_stub.start_node(vm1_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Check installation on vm1')
    test_stub.make_ssh_no_password(vm2_ip, tmp_file)
    test_stub.start_node(vm1_ip, tmp_file)
    test_stub.stop_node(vm2_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Check installation on vm2')
    test_stub.make_ssh_no_password(vm2_ip, tmp_file)
    test_stub.stop_node(vm1_ip, tmp_file)
    test_stub.start_node(vm2_ip, tmp_file)
    #test_stub.check_installation(vm2_ip, tmp_file)

    #test_util.test_dsc('Upgrade install management node on vm2')
    #cmd = '%s "zstack-ctl upgrade_management_node --host=%s"' % (ssh_cmd1, host_list) 
    #process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    #test_util.test_dsc('After upgrade, check installation on vm1')
    #test_stub.check_installation(vm1_ip, tmp_file)

    #test_util.test_dsc('After upgrade, check installation on vm2')
    #cmd = '%s "zstack-ctl start_node"' % ssh_cmd2
    #process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
    #test_stub.check_installation(vm2_ip, tmp_file)

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm1_inv.uuid)
    sce_ops.destroy_vm(zstack_management_ip, vm2_inv.uuid)

    test_util.test_pass('ZStack install management nodes installation Test Success')
def test():
    global vm_inv
    global zone_inv
    global cluster_inv
    global host_inv
    global ps_inv
    global bs_inv
    global image_inv
    global vmoffering_inv
    global l2_inv
    global l3_inv
    global l3_uuid
    global image_uuid
    global vmoffering_uuid
    global image_uuid
    global vm_ip

    test_util.test_dsc('Create test vm to test zstack install MN on centos7.1 and add the HOST')
    
    conditions = res_ops.gen_query_conditions('name', '=', os.environ.get('imageNameBase_c72'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]
    vm_inv = create_vm(image)
    time.sleep(100)
    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc('Install zstack with -o')
    vm_ip = vm_inv.vmNics[0].ip
    test_stub.make_ssh_no_password(vm_ip, tmp_file)
    test_util.test_dsc('Upgrade master iso')

    test_util.test_logger('Update MN IP')
    test_stub.update_mn_hostname(vm_ip, tmp_file)
    test_stub.update_mn_ip(vm_ip, tmp_file)
    test_stub.start_mn(vm_ip, tmp_file)

    test_stub.update_iso(vm_ip, tmp_file, iso_path, upgrade_script_path)

    test_util.test_dsc('Install zstack with default path')
    ssh_cmd = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    cmd= '%s "[ -e /usr/local/zstack ] && echo yes || echo no"' % ssh_cmd
    (process_result, cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
    if process_result != 0:
        test_util.test_fail('check /usr/local/zstack fail, cmd_stdout:%s' % cmd_stdout)
    cmd_stdout = cmd_stdout[:-1]
    if cmd_stdout == "yes":
        cmd = '%s "rm -rf /usr/local/zstack"' % ssh_cmd
        (process_result, cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
        if process_result != 0:
            test_util.test_fail('delete /usr/local/zstack fail')

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, target_file)
    ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    args = "-D"

    test_util.test_dsc('start install the latest zstack-MN')
    test_stub.execute_install_with_args(ssh_cmd, args, target_file, tmp_file)

    test_util.test_dsc('create zone names is zone1')
    zone_inv = test_stub.create_zone1(vm_ip, tmp_file)
    zone_uuid = zone_inv.uuid

    test_util.test_dsc('create cluster names is clsuter1')
    cluster_name = 'Cluster1'
    cluster_inv = test_stub.create_cluster1(vm_ip, cluster_name, zone_uuid, tmp_file)
    cluster_uuid = cluster_inv.uuid

    test_util.test_dsc('add HOST names is HOST1')
    host_inv = test_stub.add_kvm_host1(vm_ip, cluster_uuid, tmp_file)
    host_uuid = host_inv.uuid

    test_util.test_dsc('add ps names is PS1')
    ps_inv = test_stub.create_local_ps(vm_ip, zone_uuid, tmp_file)
    ps_uuid = ps_inv.uuid

    test_stub.attach_ps(vm_ip, ps_uuid, cluster_uuid, tmp_file)

    test_util.test_dsc('add BS names is bs1')
    bs_inv = test_stub.create_sftp_backup_storage(vm_ip, tmp_file)
    bs_uuid = bs_inv.uuid

    test_stub.attach_bs(vm_ip, bs_uuid, zone_uuid, tmp_file)

    test_util.test_dsc('add image names is image1.4')
    image_inv = test_stub.add_image_local(vm_ip, bs_uuid, tmp_file)
    image_uuid = image_inv.uuid

    test_util.test_dsc('add vm instance offering names is 1-1G')
    vmoffering_inv = test_stub.create_vm_offering(vm_ip, tmp_file)
    vmoffering_uuid = vmoffering_inv.uuid

    test_util.test_dsc('create L2_vlan network  names is L2_vlan')
    l2_inv = sce_ops.create_l2_vlan(vm_ip, 'L2_vlan', 'eth0', '2200', zone_uuid)
    l2_uuid = l2_inv.inventory.uuid

    test_util.test_dsc('attach L2 netowrk to cluster')
    sce_ops.attach_l2(vm_ip, l2_uuid, cluster_uuid)

    test_util.test_dsc('create L3_flat_network names is L3_flat_network')
    l3_inv = sce_ops.create_l3(vm_ip, 'l3_flat_network', 'L3BasicNetwork', l2_uuid, 'local.com')
    l3_uuid = l3_inv.inventory.uuid    

    l3_dns = '223.5.5.5'
    start_ip = '192.168.109.5'
    end_ip = '192.168.109.200'
    gateway = '192.168.109.1'
    netmask = '255.255.255.0'

    test_util.test_dsc('add DNS and IP_Range for L3_flat_network')
    sce_ops.add_dns_to_l3(vm_ip, l3_uuid, l3_dns)
    sce_ops.add_ip_range(vm_ip,'IP_range', l3_uuid, start_ip, end_ip, gateway, netmask)
    
    test_util.test_dsc('query flat provider and attach network service to  L3_flat_network')
    provider_name = 'Flat Network Service Provider'
    conditions = res_ops.gen_query_conditions('name', '=', provider_name)
    net_provider_list = sce_ops.query_resource(vm_ip, res_ops.NETWORK_SERVICE_PROVIDER, conditions).inventories[0]
    pro_uuid = net_provider_list.uuid
    sce_ops.attach_flat_network_service_to_l3network(vm_ip, l3_uuid, pro_uuid)

    test_util.test_dsc('create a vm with L3_flat_network')
    new_vm_inv = create_new_vm(image_inv)

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm_inv.uuid)
    test_util.test_pass('Install ZStack with -o on centos7.2 and create a vmSuccess')
def test():
    global vm_inv
    global zone_inv
    global cluster_inv
    global host_inv
    global ps_inv
    global bs_inv
    global image_inv
    global vmoffering_inv
    global l2_inv
    global l3_inv
    global l3_uuid
    global image_uuid
    global vmoffering_uuid
    global image_uuid
    global vm_ip

    test_util.test_dsc('Create test vm to test zstack install MN on centos7.4 and add the HOST')
    
    conditions = res_ops.gen_query_conditions('name', '=', os.environ.get('imageNameBase_c74_231_ex'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]
    vm_inv = create_vm(image)
    time.sleep(100)
    #c74_iso_path = os.environ.get('iso_250_c74_path')
    #upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc('Install zstack with -o')
    vm_ip = vm_inv.vmNics[0].ip
    test_stub.make_ssh_no_password(vm_ip, tmp_file)
    #test_util.test_dsc('Upgrade 2.5.0 c74  iso')

    #test_stub.update_c74_iso(vm_ip, tmp_file, c74_iso_path, upgrade_script_path)

    test_stub.update_repo(vm_ip, tmp_file)
    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, target_file)
    ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    args = "-o"

    test_util.test_dsc('start install the latest zstack-MN')
    test_stub.execute_install_with_args(ssh_cmd, args, target_file, tmp_file)

       
    os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = vm_ip

    test_util.test_dsc('create zone names is zone1')
    zone_inv = test_stub.create_zone1(vm_ip, tmp_file)
    zone_uuid = zone_inv.uuid

    test_util.test_dsc('create cluster names is clsuter1')
    cluster_name = 'cluster1'
    cluster_inv = test_stub.create_cluster1(vm_ip, cluster_name, zone_uuid, tmp_file)
    cluster_uuid = cluster_inv.uuid

    test_util.test_dsc('add HOST names is HOST1')
    host_ip = vm_ip
    host_name = 'host1'
    host_inv = test_stub.add_kvm_host1(vm_ip, host_ip, host_name, cluster_uuid, tmp_file)
    host_uuid = host_inv.uuid

    test_util.test_dsc('add ps names is PS1')
    ps_inv = test_stub.create_local_ps(vm_ip, zone_uuid, tmp_file)
    ps_uuid = ps_inv.uuid

    test_stub.attach_ps(vm_ip, ps_uuid, cluster_uuid, tmp_file)

    test_util.test_dsc('add BS names is bs1')
    bs_inv = test_stub.create_sftp_backup_storage(vm_ip, tmp_file)
    bs_uuid = bs_inv.uuid

    test_stub.attach_bs(vm_ip, bs_uuid, zone_uuid, tmp_file)

    test_util.test_dsc('add image names is image1.4')
    image_inv = test_stub.add_image_local(vm_ip, bs_uuid, tmp_file)
    image_uuid = image_inv.uuid

    test_util.test_dsc('add vm instance offering names is 1-1G')
    vmoffering_inv = test_stub.create_vm_offering(vm_ip, tmp_file)
    vmoffering_uuid = vmoffering_inv.uuid

    test_util.test_dsc('create L2_vlan network  names is L2_vlan')
    l2_inv = sce_ops.create_l2_vlan(vm_ip, 'L2_vlan', 'eth0', '2204', zone_uuid)
    l2_uuid = l2_inv.inventory.uuid

    test_util.test_dsc('attach L2 netowrk to cluster')
    sce_ops.attach_l2(vm_ip, l2_uuid, cluster_uuid)

    test_util.test_dsc('create L3_flat_network names is L3_flat_network')
    l3_inv = sce_ops.create_l3(vm_ip, 'l3_flat_network', 'L3BasicNetwork', l2_uuid, 'local.com')
    l3_uuid = l3_inv.inventory.uuid    

    l3_dns = '223.5.5.5'
    start_ip = '192.168.108.5'
    end_ip = '192.168.108.200'
    gateway = '192.168.108.1'
    netmask = '255.255.255.0'

    test_util.test_dsc('add DNS and IP_Range for L3_flat_network')
    sce_ops.add_dns_to_l3(vm_ip, l3_uuid, l3_dns)
    sce_ops.add_ip_range(vm_ip,'IP_range', l3_uuid, start_ip, end_ip, gateway, netmask)
    
    test_util.test_dsc('query flat provider and attach network service to  L3_flat_network')
    provider_name = 'Flat Network Service Provider'
    conditions = res_ops.gen_query_conditions('name', '=', provider_name)
    net_provider_list = sce_ops.query_resource(vm_ip, res_ops.NETWORK_SERVICE_PROVIDER, conditions).inventories[0]
    pro_uuid = net_provider_list.uuid
    sce_ops.attach_flat_network_service_to_l3network(vm_ip, l3_uuid, pro_uuid)

    test_util.test_dsc('create a vm with L3_flat_network')
    new_vm_inv = create_new_vm(image_inv)

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm_inv.uuid)
    test_util.test_pass('Install ZStack with -o on centos7.4 and create a vmSuccess')
def test():
    global vm1_inv
    global vm2_inv

    zstack_latest_version = os.environ.get('zstackLatestVersion')
    zstack_latest_path = os.environ.get('zstackLatestInstaller')

    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc(
        'Create 2 CentOS7 vm to test install management node installation')

    conditions = res_ops.gen_query_conditions(
        'name', '=', os.environ.get('imageNameBase_210_mn'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]

    conditions = res_ops.gen_query_conditions(
        'name', '=', os.environ.get('imageNameBase_21_ex'))
    image1 = res_ops.query_resource(res_ops.IMAGE, conditions)[0]

    vm1_inv = create_vm(image)
    vm2_inv = create_vm(image1)

    vm1_ip = vm1_inv.vmNics[0].ip
    vm2_ip = vm2_inv.vmNics[0].ip

    time.sleep(60)
    test_stub.make_ssh_no_password(vm1_ip, tmp_file)

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm1_inv, target_file)
    ssh_cmd1 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm1_ip
    ssh_cmd2 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm2_ip

    test_util.test_dsc('Update MN IP and check installation on vm1')
    test_stub.update_mn_hostname(vm1_ip, tmp_file)
    test_stub.update_mn_ip(vm1_ip, tmp_file)
    test_stub.start_mn(vm1_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Upgrade the latest master zstack')
    test_stub.update_iso(vm1_ip, tmp_file, iso_path, upgrade_script_path)
    test_stub.update_repo(vm1_ip, tmp_file)
    test_stub.upgrade_zstack(vm1_ip, zstack_latest_path, tmp_file)
    test_stub.check_zstack_version(vm1_ip, tmp_file, zstack_latest_version)
    test_stub.start_mn(vm1_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('only Install one management node on vm2')
    host_list = 'root:password@%s ' % vm2_ip
    cmd = '%s "zstack-ctl install_management_node --host=%s"' % (ssh_cmd1,
                                                                 host_list)
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    test_util.test_dsc('Check installation on vm1')
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Check installation on vm2 vm1')
    test_stub.make_ssh_no_password(vm2_ip, tmp_file)
    test_stub.start_node(vm1_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Check installation on vm1')
    test_stub.make_ssh_no_password(vm2_ip, tmp_file)
    test_stub.start_node(vm1_ip, tmp_file)
    test_stub.stop_node(vm2_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Check installation on vm2')
    test_stub.make_ssh_no_password(vm2_ip, tmp_file)
    test_stub.stop_node(vm1_ip, tmp_file)
    test_stub.start_node(vm2_ip, tmp_file)
    #test_stub.check_installation(vm2_ip, tmp_file)

    #test_util.test_dsc('Upgrade install management node on vm2')
    #cmd = '%s "zstack-ctl upgrade_management_node --host=%s"' % (ssh_cmd1, host_list)
    #process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    #test_util.test_dsc('After upgrade, check installation on vm1')
    #test_stub.check_installation(vm1_ip, tmp_file)

    #test_util.test_dsc('After upgrade, check installation on vm2')
    #cmd = '%s "zstack-ctl start_node"' % ssh_cmd2
    #process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
    #test_stub.check_installation(vm2_ip, tmp_file)

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm1_inv.uuid)
    sce_ops.destroy_vm(zstack_management_ip, vm2_inv.uuid)

    test_util.test_pass(
        'ZStack install management nodes installation Test Success')
Пример #15
0
def test():
    global vm1_inv
    global vm2_inv

    zstack_latest_version = os.environ.get('zstackLatestVersion')
    zstack_latest_path = os.environ.get('zstackLatestInstaller')

    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc(
        'Create 2 CentOS7 vm to test install management node installation')

    conditions = res_ops.gen_query_conditions(
        'name', '=', os.environ.get('imageNameBase_21_ex'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]

    vm1_inv = create_vm(image)
    vm2_inv = create_vm(image)

    vm1_ip = vm1_inv.vmNics[0].ip
    vm2_ip = vm2_inv.vmNics[0].ip

    time.sleep(60)
    test_stub.make_ssh_no_password(vm1_ip, tmp_file)
    test_stub.update_iso(vm1_ip, tmp_file, iso_path, upgrade_script_path)

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm1_inv, target_file)
    ssh_cmd1 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm1_ip
    ssh_cmd2 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm2_ip

    test_util.test_dsc('Install zstack 2.1.1 master mangement node on vm1')
    cmd = '%s "[ -e /usr/local/zstack ] && echo yes || echo no"' % ssh_cmd1
    (process_result,
     cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
    if process_result != 0:
        test_util.test_fail('check /usr/local/zstack fail, cmd_stdout:%s' %
                            cmd_stdout)
    cmd_stdout = cmd_stdout[:-1]
    if cmd_stdout == "yes":
        cmd = '%s "rm -rf /usr/local/zstack"' % ssh_cmd
        (process_result,
         cmd_stdout) = test_stub.execute_shell_in_process_stdout(
             cmd, tmp_file)
        if process_result != 0:
            test_util.test_fail('delete /usr/local/zstack fail')
    test_stub.execute_all_install(ssh_cmd1, target_file, tmp_file)

    #test_util.test_dsc('Upgrade the latest master zstack')
    #test_stub.upgrade_zstack(vm1_ip, zstack_latest_path, tmp_file)
    #test_stub.check_zstack_version(vm1_ip, tmp_file, zstack_latest_version)
    #test_stub.start_mn(vm1_ip, tmp_file)
    #test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('only Install one management node on vm2')
    host_list = 'root:password@%s ' % vm2_ip
    cmd = '%s "zstack-ctl install_management_node --host=%s"' % (ssh_cmd1,
                                                                 host_list)
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    test_util.test_dsc('Check installation on vm1')
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Check installation on vm2')
    test_stub.make_ssh_no_password(vm2_ip, tmp_file)
    cmd = '%s "zstack-ctl start_node"' % ssh_cmd2
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('check installation stop_node one ')
    test_stub.stop_node(vm1_ip, tmp_file)
    test_stub.start_node(vm2_ip, tmp_file)
    test_stub.check_installation(vm2_ip, tmp_file)

    test_util.test_dsc('check installation stop_node the second one ')
    test_stub.start_node(vm1_ip, tmp_file)
    test_stub.stop_node(vm2_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm1_inv.uuid)
    sce_ops.destroy_vm(zstack_management_ip, vm2_inv.uuid)

    test_util.test_pass(
        'ZStack install management nodes installation Test Success')
Пример #16
0
def test():
    global vm_inv
    global zone_inv
    global cluster_inv
    global host_inv
    global ps_inv
    global bs_inv
    global image_inv
    global vmoffering_inv
    global l2_inv
    global l3_inv
    global l3_uuid
    global image_uuid
    global vmoffering_uuid
    global image_uuid
    global vm_ip

    test_util.test_dsc(
        'Create test vm to test zstack install MN on centos7.1 and add the HOST'
    )

    conditions = res_ops.gen_query_conditions(
        'name', '=', os.environ.get('imageNameBase_c72'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]
    vm_inv = create_vm(image)
    time.sleep(100)
    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc('Install zstack with -o')
    vm_ip = vm_inv.vmNics[0].ip
    test_stub.make_ssh_no_password(vm_ip, tmp_file)
    test_util.test_dsc('Upgrade master iso')

    test_util.test_logger('Update MN IP')
    test_stub.update_mn_hostname(vm_ip, tmp_file)
    test_stub.update_mn_ip(vm_ip, tmp_file)
    test_stub.start_mn(vm_ip, tmp_file)

    test_stub.update_iso(vm_ip, tmp_file, iso_path, upgrade_script_path)

    test_util.test_dsc('Install zstack with default path')
    ssh_cmd = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    cmd = '%s "[ -e /usr/local/zstack ] && echo yes || echo no"' % ssh_cmd
    (process_result,
     cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
    if process_result != 0:
        test_util.test_fail('check /usr/local/zstack fail, cmd_stdout:%s' %
                            cmd_stdout)
    cmd_stdout = cmd_stdout[:-1]
    if cmd_stdout == "yes":
        cmd = '%s "rm -rf /usr/local/zstack"' % ssh_cmd
        (process_result,
         cmd_stdout) = test_stub.execute_shell_in_process_stdout(
             cmd, tmp_file)
        if process_result != 0:
            test_util.test_fail('delete /usr/local/zstack fail')

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm_inv, target_file)
    ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
    args = "-D"

    test_util.test_dsc('start install the latest zstack-MN')
    test_stub.execute_install_with_args(ssh_cmd, args, target_file, tmp_file)

    test_util.test_dsc('create zone names is zone1')
    zone_inv = test_stub.create_zone1(vm_ip, tmp_file)
    zone_uuid = zone_inv.uuid

    test_util.test_dsc('create cluster names is clsuter1')
    cluster_inv = test_stub.create_cluster1(vm_ip, zone_uuid, tmp_file)
    cluster_uuid = cluster_inv.uuid

    test_util.test_dsc('add HOST names is HOST1')
    host_inv = test_stub.add_kvm_host1(vm_ip, cluster_uuid, tmp_file)
    host_uuid = host_inv.uuid

    test_util.test_dsc('add ps names is PS1')
    ps_inv = test_stub.create_local_ps(vm_ip, zone_uuid, tmp_file)
    ps_uuid = ps_inv.uuid

    test_stub.attach_ps(vm_ip, ps_uuid, cluster_uuid, tmp_file)

    test_util.test_dsc('add BS names is bs1')
    bs_inv = test_stub.create_sftp_backup_storage(vm_ip, tmp_file)
    bs_uuid = bs_inv.uuid

    test_stub.attach_bs(vm_ip, bs_uuid, zone_uuid, tmp_file)

    test_util.test_dsc('add image names is image1.4')
    image_inv = test_stub.add_image_local(vm_ip, bs_uuid, tmp_file)
    image_uuid = image_inv.uuid

    test_util.test_dsc('add vm instance offering names is 1-1G')
    vmoffering_inv = test_stub.create_vm_offering(vm_ip, tmp_file)
    vmoffering_uuid = vmoffering_inv.uuid

    test_util.test_dsc('create L2_vlan network  names is L2_vlan')
    l2_inv = sce_ops.create_l2_vlan(vm_ip, 'L2_vlan', 'eth0', '2200',
                                    zone_uuid)
    l2_uuid = l2_inv.inventory.uuid

    test_util.test_dsc('attach L2 netowrk to cluster')
    sce_ops.attach_l2(vm_ip, l2_uuid, cluster_uuid)

    test_util.test_dsc('create L3_flat_network names is L3_flat_network')
    l3_inv = sce_ops.create_l3(vm_ip, 'l3_flat_network', 'L3BasicNetwork',
                               l2_uuid, 'local.com')
    l3_uuid = l3_inv.inventory.uuid

    l3_dns = '223.5.5.5'
    start_ip = '192.168.109.5'
    end_ip = '192.168.109.200'
    gateway = '192.168.109.1'
    netmask = '255.255.255.0'

    test_util.test_dsc('add DNS and IP_Range for L3_flat_network')
    sce_ops.add_dns_to_l3(vm_ip, l3_uuid, l3_dns)
    sce_ops.add_ip_range(vm_ip, 'IP_range', l3_uuid, start_ip, end_ip, gateway,
                         netmask)

    test_util.test_dsc(
        'query flat provider and attach network service to  L3_flat_network')
    provider_name = 'Flat Network Service Provider'
    conditions = res_ops.gen_query_conditions('name', '=', provider_name)
    net_provider_list = sce_ops.query_resource(
        vm_ip, res_ops.NETWORK_SERVICE_PROVIDER, conditions).inventories[0]
    pro_uuid = net_provider_list.uuid
    sce_ops.attach_flat_network_service_to_l3network(vm_ip, l3_uuid, pro_uuid)

    test_util.test_dsc('create a vm with L3_flat_network')
    new_vm_inv = create_new_vm(image_inv)

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm_inv.uuid)
    test_util.test_pass(
        'Install ZStack with -o on centos7.2 and create a vmSuccess')
Пример #17
0
def destroy_vm_scenario(vm_uuid):
    zstack_management_ip = test_lib.all_scenario_config.basicConfig.zstackManagementIp.text_
    scen_ops.destroy_vm(zstack_management_ip, vm_uuid)
Пример #18
0
def test():
    global vm1_inv
    global vm2_inv
    global vm3_inv

    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc(
        'Create 3 CentOS7 vm to test multi management node installation')

    conditions = res_ops.gen_query_conditions(
        'name', '=', os.environ.get('imageNameBase_21_ex'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]

    vm1_inv = create_vm(image)
    vm2_inv = create_vm(image)
    vm3_inv = create_vm(image)

    vm1_ip = vm1_inv.vmNics[0].ip
    vm2_ip = vm2_inv.vmNics[0].ip
    vm3_ip = vm3_inv.vmNics[0].ip

    time.sleep(60)

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm1_inv, target_file)
    ssh_cmd1 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm1_ip
    ssh_cmd2 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm2_ip
    ssh_cmd3 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm3_ip

    #test_util.test_dsc('Update MN IP and check installation on vm1')
    #cmd='%s "zstack-ctl change_ip --ip="%s'%(ssh_cmd1,vm1_ip)
    #test_stub.execute_shell_in_process(cmd, tmp_file)
    #cmd='%s "zstack-ctl start"'%ssh_cmd1
    #test_stub.execute_shell_in_process(cmd, tmp_file)
    #test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Update master iso')
    test_stub.update_iso(vm1_ip, tmp_file, iso_path, upgrade_script_path)

    test_util.test_dsc('Install zstack mangement node on vm1')
    cmd = '%s "[ -e /usr/local/zstack ] && echo yes || echo no"' % ssh_cmd1
    (process_result,
     cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
    if process_result != 0:
        test_util.test_fail('check /usr/local/zstack fail, cmd_stdout:%s' %
                            cmd_stdout)
    cmd_stdout = cmd_stdout[:-1]
    if cmd_stdout == "yes":
        cmd = '%s "rm -rf /usr/local/zstack"' % ssh_cmd
        (process_result,
         cmd_stdout) = test_stub.execute_shell_in_process_stdout(
             cmd, tmp_file)
        if process_result != 0:
            test_util.test_fail('delete /usr/local/zstack fail')
    test_stub.execute_all_install(ssh_cmd1, target_file, tmp_file)

    test_util.test_dsc('Install multi management node on vm2 and vm3')
    host_list = 'root:password@%s root:password@%s' % (vm2_ip, vm3_ip)
    cmd = '%s "zstack-ctl add_multi_management --host-list %s"' % (ssh_cmd1,
                                                                   host_list)
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    test_util.test_dsc('Check installation on vm1')
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Check installation on vm2')
    ssh.make_ssh_no_password(vm2_ip, test_lib.lib_get_vm_username(vm2_inv), \
            test_lib.lib_get_vm_password(vm2_inv))
    cmd = '%s "zstack-ctl start"' % ssh_cmd2
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
    test_stub.check_installation(vm2_ip, tmp_file)

    test_util.test_dsc('Check installation on vm3')
    ssh.make_ssh_no_password(vm3_ip, test_lib.lib_get_vm_username(vm3_inv), \
            test_lib.lib_get_vm_password(vm3_inv))
    cmd = '%s "zstack-ctl start"' % ssh_cmd3
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
    test_stub.check_installation(vm3_ip, tmp_file)

    #test_util.test_dsc('Upgrade multi management node on vm2 and vm3')
    #cmd = '%s "zstack-ctl upgrade_multi_management_node --installer-bin %s"' % (ssh_cmd1, target_file)
    #process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    #test_util.test_dsc('After upgrade, check installation on vm1')
    #test_stub.check_installation(vm1_ip, tmp_file)

    #test_util.test_dsc('After upgrade, check installation on vm2')
    #ssh.make_ssh_no_password(vm2_ip, test_lib.lib_get_vm_username(vm2_inv), \
    #        test_lib.lib_get_vm_password(vm2_inv))
    #cmd = '%s "zstack-ctl start"' % ssh_cmd2
    #process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
    #test_stub.check_installation(vm2_ip, tmp_file)

    #test_util.test_dsc('After upgrade, check installation on vm3')
    #ssh.make_ssh_no_password(vm3_ip, test_lib.lib_get_vm_username(vm3_inv), \
    #        test_lib.lib_get_vm_password(vm3_inv))
    #cmd = '%s "zstack-ctl start"' % ssh_cmd3
    #process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
    #test_stub.check_installation(vm3_ip, tmp_file)

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm1_inv.uuid)
    sce_ops.destroy_vm(zstack_management_ip, vm2_inv.uuid)
    sce_ops.destroy_vm(zstack_management_ip, vm3_inv.uuid)

    test_util.test_pass(
        'ZStack multi management nodes installation Test Success')
def test():
    global vm1_inv
    global vm2_inv
    global vm3_inv

    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc('Create 3 CentOS7 vm to test multi management node installation')

    conditions = res_ops.gen_query_conditions('name', '=', os.environ.get('imageNameBase_21_ex'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]
    
    vm1_inv = create_vm(image) 
    vm2_inv = create_vm(image)
    vm3_inv = create_vm(image)

    vm1_ip = vm1_inv.vmNics[0].ip
    vm2_ip = vm2_inv.vmNics[0].ip
    vm3_ip = vm3_inv.vmNics[0].ip

    time.sleep(60)

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm1_inv, target_file)
    ssh_cmd1 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm1_ip
    ssh_cmd2 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm2_ip
    ssh_cmd3 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm3_ip
    test_util.test_dsc('ssh no password on vm1 vm2 vm3')
    test_stub.make_ssh_no_password(vm1_ip, tmp_file)

    test_util.test_dsc('Update master iso')
    test_stub.update_iso(vm1_ip, tmp_file, iso_path, upgrade_script_path)

    test_util.test_dsc('Install zstack mangement node on vm1')
    cmd= '%s "[ -e /usr/local/zstack ] && echo yes || echo no"' % ssh_cmd1
    (process_result, cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
    if process_result != 0:
        test_util.test_fail('check /usr/local/zstack fail, cmd_stdout:%s' % cmd_stdout)
    cmd_stdout = cmd_stdout[:-1]
    if cmd_stdout == "yes":
        cmd = '%s "rm -rf /usr/local/zstack"' % ssh_cmd
        (process_result, cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
        if process_result != 0:
            test_util.test_fail('delete /usr/local/zstack fail')
    test_stub.execute_all_install(ssh_cmd1, target_file, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Install multi management node on vm2 and vm3')
    host_list = 'root:password@%s root:password@%s' % (vm2_ip, vm3_ip)
    cmd = '%s "zstack-ctl add_multi_management --host-list %s"' % (ssh_cmd1, host_list)
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    test_util.test_dsc('Check installation on vm1 and start_node vm2 and vm3')
    test_stub.start_node(vm1_ip, tmp_file)
    test_stub.make_ssh_no_password(vm2_ip, tmp_file)
    test_stub.start_node(vm2_ip, tmp_file)
    test_stub.make_ssh_no_password(vm3_ip, tmp_file)
    test_stub.start_node(vm3_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)
    test_stub.check_installation(vm2_ip, tmp_file)
    test_stub.check_installation(vm3_ip, tmp_file)

    test_util.test_dsc('Check installation on vm2 and stop_node vm1 and vm3')
    test_stub.stop_node(vm1_ip, tmp_file)
    test_stub.start_node(vm2_ip, tmp_file)
    test_stub.stop_node(vm3_ip, tmp_file)
    test_stub.check_installation(vm2_ip, tmp_file)

    test_util.test_dsc('Check installation on vm3 and stop_node vm1 and vm2')
    test_stub.stop_node(vm1_ip, tmp_file)
    test_stub.stop_node(vm2_ip, tmp_file)
    test_stub.start_node(vm3_ip, tmp_file)
    test_stub.check_installation(vm3_ip, tmp_file)

    test_util.test_dsc('Check installation on vm1 and stop_node vm2 and vm3')
    test_stub.start_node(vm1_ip, tmp_file)
    test_stub.stop_node(vm2_ip, tmp_file)
    test_stub.stop_node(vm3_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    #test_util.test_dsc('Upgrade multi management node on vm2 and vm3')
    #cmd = '%s "zstack-ctl upgrade_multi_management_node --installer-bin %s"' % (ssh_cmd1, target_file) 
    #process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    #test_util.test_dsc('After upgrade, check installation on vm1')
    #test_stub.check_installation(vm1_ip, tmp_file)

    #test_util.test_dsc('After upgrade, check installation on vm2')
    #ssh.make_ssh_no_password(vm2_ip, test_lib.lib_get_vm_username(vm2_inv), \
    #        test_lib.lib_get_vm_password(vm2_inv))
    #cmd = '%s "zstack-ctl start"' % ssh_cmd2
    #process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
    #test_stub.check_installation(vm2_ip, tmp_file)

    #test_util.test_dsc('After upgrade, check installation on vm3')
    #ssh.make_ssh_no_password(vm3_ip, test_lib.lib_get_vm_username(vm3_inv), \
    #        test_lib.lib_get_vm_password(vm3_inv))
    #cmd = '%s "zstack-ctl start"' % ssh_cmd3
    #process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
    #test_stub.check_installation(vm3_ip, tmp_file)

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm1_inv.uuid)
    sce_ops.destroy_vm(zstack_management_ip, vm2_inv.uuid)
    sce_ops.destroy_vm(zstack_management_ip, vm3_inv.uuid)

    test_util.test_pass('ZStack multi management nodes installation Test Success')
def test():
    global vm1_inv
    global vm2_inv

    zstack_latest_version = os.environ.get('zstackLatestVersion')
    zstack_latest_path = os.environ.get('zstackLatestInstaller')

    iso_path = os.environ.get('iso_path')
    upgrade_script_path = os.environ.get('upgradeScript')

    test_util.test_dsc('Create 2 CentOS7 vm to test install management node installation')

    conditions = res_ops.gen_query_conditions('name', '=', os.environ.get('imageNameBase_21_ex'))
    image = res_ops.query_resource(res_ops.IMAGE, conditions)[0]
    
    vm1_inv = create_vm(image) 
    vm2_inv = create_vm(image)

    vm1_ip = vm1_inv.vmNics[0].ip
    vm2_ip = vm2_inv.vmNics[0].ip

    time.sleep(60)
    test_stub.make_ssh_no_password(vm1_ip, tmp_file)
    test_stub.update_iso(vm1_ip, tmp_file, iso_path, upgrade_script_path)

    target_file = '/root/zstack-all-in-one.tgz'
    test_stub.prepare_test_env(vm1_inv, target_file)
    ssh_cmd1 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm1_ip
    ssh_cmd2 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm2_ip

    test_util.test_dsc('Install zstack 2.1.1 master mangement node on vm1')
    cmd= '%s "[ -e /usr/local/zstack ] && echo yes || echo no"' % ssh_cmd1
    (process_result, cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
    if process_result != 0:
        test_util.test_fail('check /usr/local/zstack fail, cmd_stdout:%s' % cmd_stdout)
    cmd_stdout = cmd_stdout[:-1]
    if cmd_stdout == "yes":
        cmd = '%s "rm -rf /usr/local/zstack"' % ssh_cmd
        (process_result, cmd_stdout) = test_stub.execute_shell_in_process_stdout(cmd, tmp_file)
        if process_result != 0:
            test_util.test_fail('delete /usr/local/zstack fail')
    test_stub.execute_all_install(ssh_cmd1, target_file, tmp_file)
    

    #test_util.test_dsc('Upgrade the latest master zstack')
    #test_stub.upgrade_zstack(vm1_ip, zstack_latest_path, tmp_file)
    #test_stub.check_zstack_version(vm1_ip, tmp_file, zstack_latest_version)
    #test_stub.start_mn(vm1_ip, tmp_file)
    #test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('only Install one management node on vm2')
    host_list = 'root:password@%s ' % vm2_ip
    cmd = '%s "zstack-ctl install_management_node --host=%s"' % (ssh_cmd1, host_list)
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)

    test_util.test_dsc('Check installation on vm1')
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('Check installation on vm2')
    test_stub.make_ssh_no_password(vm2_ip, tmp_file)
    cmd = '%s "zstack-ctl start_node"' % ssh_cmd2
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    test_util.test_dsc('check installation stop_node one ')
    test_stub.stop_node(vm1_ip, tmp_file)
    test_stub.start_node(vm2_ip, tmp_file)
    test_stub.check_installation(vm2_ip, tmp_file)

    test_util.test_dsc('check installation stop_node the second one ')
    test_stub.start_node(vm1_ip, tmp_file)
    test_stub.stop_node(vm2_ip, tmp_file)
    test_stub.check_installation(vm1_ip, tmp_file)

    os.system('rm -f %s' % tmp_file)
    sce_ops.destroy_vm(zstack_management_ip, vm1_inv.uuid)
    sce_ops.destroy_vm(zstack_management_ip, vm2_inv.uuid)

    test_util.test_pass('ZStack install management nodes installation Test Success')