def hosts(self):
keys = fab.env.key_filename = []
hosts = []
ssh_configs_data = fab.local('vagrant ssh-config', capture=True)
ssh_configs = map(
lambda config: dict(map(
lambda row: row.lstrip().split(' ', 1),
config.strip().splitlines()
)),
re.split('(?ms).(?=Host )', ssh_configs_data),
)
for ssh_config in ssh_configs:
keys.append(ssh_config['IdentityFile'])
host_string = '{User}@{HostName}:{Port}'.format(**ssh_config)
if self.guest_network_interface is not None:
with fab.settings(
host_string=host_string,
# see https://github.com/fabric/fabric/issues/1522
# disable_known_hosts=True,
):
ip = self._get_ip()
host_string = '{User}@{ip}'.format(ip=ip, **ssh_config)
fab.puts('Added host: ' + host_string)
hosts.append(host_string)
return hosts
评论列表
文章目录