예제 #1
0
def test_config_data():
    server_conf = Config_data()
    data = server_conf.get_hyp_config('xenserver')
    print(data['IP'])
    print(data['PASS'])
    data2 = server_conf.get_cloud_config('Project_Name')
    print(data2['AUTH_URI'])
예제 #2
0
def test_hyp_cmd():
    config = Config_data()
    x = Cloud_client()
    vms = vm_service(x.get_client())
    hyper_service = hypervisor_service(x.get_client())
    hyp = hyper_service.getvmhypervisorinfo(vms.getvms[0])
    print(hyper_service.get_hyp_name(hyp))
    hyp_config = config.get_hyp_config(hyper_service.get_hyp_name(hyp))
    ssh = ssh_client(ip=hyp_config['IP'], passwd=hyp_config['PASS'])
    print(hyp_config['LOCAL_SCRIPT'])
    ssh.send_file(hyp_config['LOCAL_SCRIPT'],hyp_config['LOCAL_SCRIPT'])
    data = hyper_service.get_hyp_cmd(hyp)
    vm_hyp_name = vms.get_vm_hyp_name(vms.getvms[0])
    d = ''
    output = ''
    for key in data:
        cmd = data[key].replace('[script]',hyp_config['LOCAL_SCRIPT']).replace('[vm_name]',vm_hyp_name)
        ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_cmd(cmd=cmd)
        output = str(ssh_stdout.readlines())[3:-4]
    if(output <> '' ):
        getsnapshot(ssh=ssh,filename=output)
        ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_cmd(cmd="rm -f *.xva xen_snap.sh")
    ssh.ssh_close()
예제 #3
0
 def __init__(self):
     server_conf = Config_data()
     self.data = server_conf.get_cloud_config('Project_Name')
     self.client_type = self.data['TYPE']