Ejemplo n.º 1
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([JschSshClientModule(), NullLoggingModule()]) \
             .overrides(props) \
             .build(AbiquoContext)
         # Close context automatically when exiting
         atexit.register(self.__del__)
         return self.__context
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 4
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
Ejemplo n.º 5
0
def buildApi(provider, endpoint, identity, credential, classname):
    return ContextBuilder.newBuilder(provider).endpoint(endpoint).credentials(identity, credential).buildApi(classname)
Ejemplo n.º 6
0
def buildApi(provider, endpoint, identity, credential, classname):
    return ContextBuilder.newBuilder(provider).endpoint(endpoint).credentials(
        identity, credential).buildApi(classname)