def decapod_api(): decapod_ip = "http://" + __pillar__.get('decapod', None)['decapod_ip'] + ":9999" decapod_user = __pillar__.get('decapod', None)['decapod_user'] decapod_pass = __pillar__.get('decapod', None)['decapod_pass'] client = decapodlib.Client(decapod_ip, decapod_user, decapod_pass) return client
def cli(ctx, url, login, password, no_verify, ssl_certificate, debug, timeout, no_pager, output_format): """Decapod command line tool. With this CLI it is possible to access all API endpoints of Decapod. To do so, you have to provide some common configuration settings: URL, login and password to access. These settings are possible to setup using commandline parameter, but if you want, you can set environment variables: \b - DECAPOD_URL - this environment variable sets URL to access. - DECAPOD_LOGIN - this environment variable sets login. - DECAPOD_PASSWORD - this environment variable sets password. - DECAPOD_TIMEOUT - this environment variable sets timeout. - DECAPOD_NO_VERIFY - this environment variable removes SSL certificate verification. - DECAPOD_SSL_CERTIFICATE - this environment variable sets a path to SSL client certificate. - DECAPOD_DEBUG - this environment variable sets debug mode. - DECAPOD_NO_PAGER - this environment variable removes pager support. """ if ssl_certificate: ssl_certificate.close() ssl_certificate = ssl_certificate.name ctx.obj = { "url": url, "login": login, "password": password, "debug": debug, "timeout": timeout, "format": output_format, "no_pager": no_pager, "client": decapodlib.Client(url, login, password, timeout=timeout, verify=not no_verify, certificate_file=ssl_certificate) } utils.configure_logging(debug) ctx.call_on_close(ctx.obj["client"].logout)