def _vm_ssh(ip_address, command, tries=None): return ssh.ssh( ip_addr=ip_address, command=command, username=VM_USER_NAME, password=VM_PASSWORD, tries=tries, )
def _vm_ssh(prefix, vm_name, command, tries=None): host = _vm_host(prefix, vm_name) ret = host.ssh(['host', vm_name]) match = re.search(r'\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', ret.out) ip_address = match.group(1) return ssh.ssh( ip_addr=ip_address, command=command, username='******', password='******', tries=tries, )
def _vm_ssh(prefix, vm_name, command, tries=None): host = _vm_host(prefix, vm_name) ret = host.ssh(['host', vm_name]) match = re.search(r'\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', ret.out.decode('utf-8')) ip_address = match.group(1) return ssh.ssh( ip_addr=ip_address, command=command, username=VM_USER_NAME, password=VM_PASSWORD, tries=tries, )
def hotplug_cpu(prefix): api = prefix.virt_env.engine_vm().get_api_v4() engine = api.system_service() vm_service = test_utils.get_vm_service(engine, VM0_NAME) new_cpu = vm_service.get().cpu new_cpu.topology.sockets = 2 vm_service.update(vm=types.Vm(cpu=new_cpu)) nt.assert_true(vm_service.get().cpu.topology.sockets == 2) host = prefix.virt_env.host_vms()[0] ret = host.ssh(['host', VM0_NAME]) match = re.search(r'\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', ret.out) ip_address = match.group(1) ret = ssh.ssh( ip_addr=ip_address, command=['lscpu'], username='******', password='******', ) nt.assert_equals(ret.code, 0) match = re.search(r'CPU\(s\):\s+(?P<cpus>[0-9]+)', ret.out) nt.assert_true(match.group('cpus') == '2')