def instance_create(args): driver = virtdeploy.get_driver(DRIVER) instance = driver.instance_create(args.id, args.template) print('name: {0}'.format(instance['name'])) print('root password: {0}'.format(instance['password'])) print('mac address: {0}'.format(instance['mac'])) print('hostname: {0}'.format(instance['hostname'])) print('ip address: {0}'.format(instance['ipaddress']))
def instance_start(args): driver = virtdeploy.get_driver(DRIVER) driver.instance_start(args.name) if args.wait: address_found = utils.wait_tcp_access(driver, args.name) if address_found is None: return EXITCODE_TIMEOUT return EXITCODE_SUCCESS
def command_ssh(args): driver = virtdeploy.get_driver(DRIVER) command = [ 'ssh', '-A', '-o', 'StrictHostKeychecking=no', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'LogLevel=QUIET' ] user, _, name = args.name.rpartition('@') if user: command.extend(('-l', user)) command.append(driver.instance_address(name)[0]) command.extend(args.arguments) return subprocess.call(command)
def command_ssh(args): driver = virtdeploy.get_driver(DRIVER) command = ['ssh', '-A', '-o', 'StrictHostKeychecking=no', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'LogLevel=QUIET'] user, _, name = args.name.rpartition('@') if user: command.extend(('-l', user)) command.append(driver.instance_address(name)[0]) command.extend(args.arguments) return subprocess.call(command)
def instance_address(args): driver = virtdeploy.get_driver(DRIVER) print('\n'.join(driver.instance_address(args.name)))
def template_list(args): driver = virtdeploy.get_driver(DRIVER) for template in driver.template_list(): print(u'{0:24}{1:24}'.format(template['id'], template['name']))
def instance_delete(args): driver = virtdeploy.get_driver(DRIVER) return driver.instance_delete(args.name)
def vm_hosts(*hosts): """ specify the instance names instead of hosts """ driver = virtdeploy.get_driver('libvirt') env.hosts.extend((driver.instance_address(x)[0] for x in hosts))