MCPcopy Create free account
hub / github.com/apache/cloudstack / get_host_credentials

Function get_host_credentials

tools/marvin/marvin/lib/utils.py:217–234  ·  view source on GitHub ↗

Get login information for a host `hostip` (ipv4) from marvin's `config` @return the tuple username, password for the host else raise keyerror

(config, hostip)

Source from the content-addressed store, hash-verified

215 )
216
217def get_host_credentials(config, hostip):
218 """Get login information for a host `hostip` (ipv4) from marvin's `config`
219
220 @return the tuple username, password for the host else raise keyerror"""
221 for zone in config.zones:
222 for pod in zone.pods:
223 for cluster in pod.clusters:
224 for host in cluster.hosts:
225 if str(host.url).startswith('http'):
226 hostname = urllib.parse.urlsplit(str(host.url)).netloc
227 else:
228 hostname = str(host.url)
229 try:
230 if socket.getfqdn(hostip) == socket.getfqdn(hostname):
231 return host.username, host.password
232 except socket.error as e:
233 raise Exception("Unresolvable host %s error is %s" % (hostip, e))
234 raise KeyError("Please provide the marvin configuration file with credentials to your hosts")
235
236def execute_command_in_host(hostip, port, username, password, command, hypervisor=None):
237 timeout = _configure_timeout(hypervisor)

Callers 15

get_router_hostMethod · 0.90
setUpClassMethod · 0.90
get_router_hostMethod · 0.90
get_router_hostMethod · 0.90
getRouterProcessStatusFunction · 0.90
get_router_hostMethod · 0.90
verify_network_rulesMethod · 0.90
run_command_in_routerMethod · 0.90

Calls

no outgoing calls

Tested by 15

get_router_hostMethod · 0.72
setUpClassMethod · 0.72
get_router_hostMethod · 0.72
get_router_hostMethod · 0.72
getRouterProcessStatusFunction · 0.72
get_router_hostMethod · 0.72
verify_network_rulesMethod · 0.72
run_command_in_routerMethod · 0.72