Created
October 17, 2011 14:38
-
-
Save HarryR/1292747 to your computer and use it in GitHub Desktop.
Retrieve IP of a server from ServerDensity
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
#!/usr/bin/env python2.7 | |
import sys | |
import user | |
from serverdensity.api import SDApi, SDServiceError | |
api = SDApi(getattr(user, 'serverdensity_domain'), | |
getattr(user, 'serverdensity_username'), | |
getattr(user, 'serverdensity_password'), | |
getattr(user, 'serverdensity_api_key')) | |
def main(argv): | |
if len(argv) < 2: | |
return "Usage: sd-ip <hostname>" | |
y = api.devices.getByName({'name':argv[1]}) | |
if not y: | |
return argv[1] | |
return y['data']['device']['ip'] | |
if __name__ == '__main__': | |
print main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment