Пример #1
0
 def cred_depot(self):
     if not self._cred_depot and self._cred_depot_connection_info.get('hostname'):
         try:
             self._cred_depot = Machine(**self._cred_depot_connection_info)
         except Exception as E:
             self.log.error('{0}\nError connecting to cred depot machine:"{1}"'
                            .format(get_traceback(), E))
             raise E
     return self._cred_depot
Пример #2
0
 def connect_to_creds_machine(self, connect_kwargs=None):
     """
     Attempts to create a Machine by connecting to the remote host, usually the CLC.
     :params connect_kwargs: Dictionary set of arguments to be provided to Machine().__init__()
     returns machine obj upon success
     """
     connect_kwargs = connect_kwargs or self._clc_connect_kwargs
     machine = Machine(**connect_kwargs)
     self.creds_machine = machine
     return machine
Пример #3
0
 def machine(self):
     if not self._machine:
         try:
             if self.host:
                 self._machine = Machine(hostname=self.host,
                                         password=self.password,
                                         keypath=self.keypath)
         except Exception as E:
             self.log.warning(
                 '{0}\nFailed to create machine object to host:"{1}", error:"{2}"'
                 .format(get_traceback(), self.host, E))
     return self._machine
Пример #4
0
 def clc_machine(self):
     if not self._clc_machine:
         hostname = self.machine_connect_kwargs['hostname']
         if hostname:
             #  See if a host exists matching the provided hostname
             if hostname in self.eucahosts:
                 self._clc_machine = self.eucahosts[hostname]
             #  See if this is a localhost connection
             elif self._get_clc_eucahost_for_localhost():
                 self._clc_machine = self._get_clc_eucahost_for_localhost()
             else:
                 self._clc_machine = Machine(**self.machine_connect_kwargs)
                 self.eucahosts[self.machine_connect_kwargs['hostname']] = self._clc_machine
     return self._clc_machine
Пример #5
0
    def __init__(self,
                 host=None,
                 password=None,
                 keypath=None,
                 sshconnection=None,
                 machine=None,
                 eucalyptus_run_path='/var/run/eucalyptus',
                 log_level='INFO'):
        if (machine and (sshconnection or host)) or sshconnection and host:
            warning = 'Duplicate and or possibly conflicting machine connection info provided:' \
                      'host:{0}, sshconnection:{1}, machine:{2}'.format(host, sshconnection,
                                                                        machine)
        else:
            warning = ""
        if machine:
            sshconnection = machine.ssh

        if sshconnection:
            host = host or sshconnection.host
            password = password or sshconnection.password
            keypath = sshconnection or sshconnection.keypair
        if host:
            if not machine:
                machine = Machine(hostname=host,
                                  password=password,
                                  keypath=keypath,
                                  sshconnection=sshconnection)
        host = host or "unknown"
        self.log = Eulogger("{0}.{1}".format(self.__class__.__name__, host))
        self.log.set_stdout_loglevel(log_level)
        if not host:
            self.log.warning(
                'Connection info not provided for: {0}.init()'.format(
                    self.__class__.__name__))

        self.host = host
        self.password = password
        self.keypath = keypath
        self._machine = machine
        self._global_xml_path = None
        self._global_xml = None
        self.eucalyptus_run_path = eucalyptus_run_path or ""
        self.eucanetd_pid_file = path.join(self.eucalyptus_run_path,
                                           'eucanetd.pid')
        self.global_xml_version = path.join(self.eucalyptus_run_path,
                                            'global_network_info.version')
Пример #6
0
    def worker_machine(self):
        '''
        Attempts to verify the worker passed is a Machine() class else assume
        it's a host name of the machine work should be performed on and
        attempt to return a Machine() created from the hostname

        param: worker Machine() or 'hostname' to be used to perform image utils
        work on.
        returns Machine obj
        '''
        if not self._worker_machine:     
            if self.worker_hostname:
                self.log.debug('Attempting to connect to machine: "{0}" for image utility work...'
                               .format(self.worker_hostname))
                self._worker_machine = Machine(hostname=self.worker_hostname,
                                               username=self.worker_username,
                                               password=self.worker_password,
                                               keypath=self.worker_keypath)
        return self._worker_machine
Пример #7
0
 def cred_depot(self):
     if not self._cred_depot and self._cred_depot_connection_info.get(
             'hostname'):
         self._cred_depot = Machine(**self._cred_depot_connection_info)
     return self._cred_depot