コード例 #1
0
ファイル: session.py プロジェクト: abelboldu/kahuna
 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
コード例 #2
0
 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
コード例 #3
0
 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
コード例 #4
0
ファイル: session.py プロジェクト: nacx/kahuna
 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
コード例 #5
0
def buildApi(provider, endpoint, identity, credential, classname):
    return ContextBuilder.newBuilder(provider).endpoint(endpoint).credentials(identity, credential).buildApi(classname)
コード例 #6
0
def buildApi(provider, endpoint, identity, credential, classname):
    return ContextBuilder.newBuilder(provider).endpoint(endpoint).credentials(
        identity, credential).buildApi(classname)