def _create_connection(): platform = node.__node__['platform'] try: conn = cloudstack.Client( platform.get_access_data('api_url'), apiKey=platform.get_access_data('api_key'), secretKey=platform.get_access_data('secret_key')) except PlatformError: raise NoCredentialsError(sys.exc_info()[1]) return conn
def _create_connection(self): platform = node.__node__['platform'] http = httplib2.Http() try: email = platform.get_access_data('service_account_name') pk = base64.b64decode(platform.get_access_data('key')) except platform.PlatformError: raise NoCredentialsError(sys.exc_info()[1]) try: cred = SignedJwtAssertionCredentials(email, pk, scope=self.scope) conn = build(self.service_name, self.api_version, http=cred.authorize(http)) except: raise InvalidCredentialsError(sys.exc_info()[1]) return BadStatusLineHandler(conn)
def _create_nova_connection(): try: platform = node.__node__['platform'] kwds = dict(auth_url=platform.get_access_data('keystone_url'), region_name=platform.get_access_data('cloud_location'), service_type='compute') if not bool(platform.get_access_data('ssl_verify_peer')): kwds['insecure'] = True import novaclient # NameError: name 'novaclient' is not defined if hasattr(novaclient, '__version__') and os.environ.get('OS_AUTH_SYSTEM'): try: import novaclient.auth_plugin auth_plugin = novaclient.auth_plugin.load_plugin( os.environ['OS_AUTH_SYSTEM']) kwds['auth_plugin'] = auth_plugin except ImportError: pass conn = nova_client.Client( platform.get_access_data('username'), platform.get_access_data('api_key') or platform.get_access_data('password'), platform.get_access_data('tenant_name'), **kwds) except PlatformError: raise NoCredentialsError(sys.exc_info()[1]) return conn
def _create_nova_connection(): try: platform = node.__node__["platform"] kwds = dict( auth_url=platform.get_access_data("keystone_url"), region_name=platform.get_access_data("cloud_location"), service_type="compute", ) if not bool(platform.get_access_data("ssl_verify_peer")): kwds["insecure"] = True import novaclient # NameError: name 'novaclient' is not defined if hasattr(novaclient, "__version__") and os.environ.get("OS_AUTH_SYSTEM"): try: import novaclient.auth_plugin auth_plugin = novaclient.auth_plugin.load_plugin(os.environ["OS_AUTH_SYSTEM"]) kwds["auth_plugin"] = auth_plugin except ImportError: pass conn = nova_client.Client( platform.get_access_data("username"), platform.get_access_data("api_key") or platform.get_access_data("password"), platform.get_access_data("tenant_name"), **kwds ) except PlatformError: raise NoCredentialsError(sys.exc_info()[1]) return conn
def _create_cinder_connection(): try: platform = node.__node__['platform'] kwds = dict(auth_url=platform.get_access_data('keystone_url'), region_name=platform.get_access_data('cloud_location')) if not bool(platform.get_access_data('ssl_verify_peer')): kwds['insecure'] = True conn = cinder_client.Client( platform.get_access_data('username'), platform.get_access_data('api_key') or platform.get_access_data('password'), platform.get_access_data('tenant_name'), **kwds) except PlatformError: raise NoCredentialsError(sys.exc_info()[1]) return conn
def _create_cinder_connection(): try: platform = node.__node__["platform"] kwds = dict( auth_url=platform.get_access_data("keystone_url"), region_name=platform.get_access_data("cloud_location") ) if not bool(platform.get_access_data("ssl_verify_peer")): kwds["insecure"] = True conn = cinder_client.Client( platform.get_access_data("username"), platform.get_access_data("api_key") or platform.get_access_data("password"), platform.get_access_data("tenant_name"), **kwds ) except PlatformError: raise NoCredentialsError(sys.exc_info()[1]) return conn
def _create_swift_connection(): try: platform = node.__node__["platform"] api_key = platform.get_access_data("api_key") password = platform.get_access_data("password") auth_url = platform.get_access_data("keystone_url") kwds = {} if "rackspacecloud" in auth_url: auth_url = re.sub(r"v2\.\d$", "v1.0", auth_url) kwds["auth_version"] = "1" else: kwds["auth_version"] = "2" kwds["tenant_name"] = platform.get_access_data("tenant_name") if not bool(platform.get_access_data("ssl_verify_peer")): kwds["insecure"] = True conn = swiftclient.Connection( authurl=auth_url, user=platform.get_access_data("username"), key=password or api_key, **kwds ) except PlatformError: raise NoCredentialsError(sys.exc_info()[1]) return conn
def _create_swift_connection(): try: platform = node.__node__['platform'] api_key = platform.get_access_data("api_key") password = platform.get_access_data("password") auth_url = platform.get_access_data("keystone_url") kwds = {} if 'rackspacecloud' in auth_url: auth_url = re.sub(r'v2\.\d$', 'v1.0', auth_url) kwds['auth_version'] = '1' else: kwds['auth_version'] = '2' kwds['tenant_name'] = platform.get_access_data("tenant_name") if not bool(platform.get_access_data('ssl_verify_peer')): kwds['insecure'] = True conn = swiftclient.Connection( authurl=auth_url, user=platform.get_access_data('username'), key=password or api_key, **kwds) except PlatformError: raise NoCredentialsError(sys.exc_info()[1]) return conn