def load(self): """ Creates and configures the context """ if not self.__context: # Avoid loading the same context twice props = self._load_config() endpoint = "http://" + self.__config.address + "/api" log.debug("Connecting to %s as %s" % (endpoint, self.__config.user)) self.__context = ContextBuilder.newBuilder(AbiquoApiMetadata()) \ .endpoint(endpoint) \ .credentials(self.__config.user, self.__config.password) \ .modules([JschSshClientModule(), NullLoggingModule()]) \ .overrides(props) \ .build(AbiquoContext) # Close context automatically when exiting atexit.register(self.__del__) return self.__context
def load(self): """ Creates and configures the context """ if not self.__context: # Avoid loading the same context twice props = self._load_config() endpoint = "http://" + self.__config.address + "/api" log.debug("Connecting to %s as %s" % (endpoint, self.__config.user)) self.__context = ContextBuilder.newBuilder(AbiquoApiMetadata()) \ .endpoint(endpoint) \ .credentials(self.__config.user, self.__config.password) \ .modules([SshjSshClientModule(), SLF4JLoggingModule()]) \ .overrides(props) \ .buildView(AbiquoContext) # Close context automatically when exiting atexit.register(self.__del__) return self.__context
def load(self): """ Creates and configures the context """ if not self.__context: # Avoid loading the same context twice props = self._load_config() log.debug("Connecting to %s as %s" % (self.__endpoint, self.__config.user)) self.__context = ContextBuilder.newBuilder(AbiquoApiMetadata()) \ .endpoint(self.__endpoint) \ .credentials(self.__config.user, self.__config.password) \ .modules([SshjSshClientModule(), SLF4JLoggingModule()]) \ .overrides(props) \ .buildView(AbiquoContext) api_version = self.__context.getApiContext() \ .getProviderMetadata().getApiMetadata().getVersion() log.debug("Using Abiquo version: %s" % api_version) # Close context automatically when exiting atexit.register(self.__del__) return self.__context
def buildApi(provider, endpoint, identity, credential, classname): return ContextBuilder.newBuilder(provider).endpoint(endpoint).credentials(identity, credential).buildApi(classname)
def buildApi(provider, endpoint, identity, credential, classname): return ContextBuilder.newBuilder(provider).endpoint(endpoint).credentials( identity, credential).buildApi(classname)