Created
March 1, 2015 04:09
-
-
Save criloz/feddcf853d4de47e5b65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'cristian' | |
from base import * | |
def get_hostmame(server_name, server): | |
""" | |
get hostname of hosts | |
@type param server_name: str | |
@type param server: dict | |
:return: | |
""" | |
client = SSHClient() | |
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
client.connect(server["ip"], username=server["user"], port=server["port"]) | |
server["hostname"] = exec_command(client, "hostname", server.ip) | |
def get_ip(server_name, server): | |
""" | |
get private ip of servers | |
@type param server_name: str | |
@type param server: dict | |
:return: | |
""" | |
client = SSHClient() | |
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
client.connect(server["ip"], username=server["user"], port=server["port"]) | |
server["private_ip"] = exec_command(client, "ifconfig eth1|grep inet|head -1|sed 's/\:/ /'|awk '{print $3}'", | |
server.ip) | |
execute = [get_hostmame, get_ip] | |
if __name__ == "__main__": | |
run_task(execute) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment