Esempio n. 1
0
    def __init__(self, credpath=None):
        """This class is intended to setup boto connections for the various services that the *ops classes will use.
        :param credpath: Path to a valid eucarc file.
        :param aws_access_key_id: Used in conjuction with aws_secret_access_key allows for creation of connections without needing a credpath.
        :param aws_secret_access_key: Used in conjuction with aws_access_key_id allows for creation of connections without needing a credpath.
        :rtype: :class:`eutester.Eutester` or ``None``
        :returns: A Eutester object with all connections that were able to be created. Currently EC2, S3, IAM, and STS.
        """

        ### Default values for configuration
        self.credpath = credpath

        ### Eutester logs
        self.logger = eulogger.Eulogger(identifier="EUTESTER")
        self.debug = self.logger.log.debug
        self.critical = self.logger.log.critical
        self.info = self.logger.log.info

        ### LOGS to keep for printing later
        self.fail_log = []
        self.running_log = self.logger.log

        ### Pull the access and secret keys from the eucarc or use the ones provided to the constructor
        if self.credpath is not None:
            self.debug("Extracting keys from " + self.credpath)
            self.aws_access_key_id = self.get_access_key()
            self.aws_secret_access_key = self.get_secret_key()
            self.account_id = self.get_account_id()
            self.user_id = self.get_user_id()
Esempio n. 2
0
 def __init__(self, hostname, distro, distro_ver, arch, source, components, password=None, keypath=None, username="******", timeout=120,retry=2,debugmethod=None):
     self.hostname = hostname
     self.distro = distro
     self.distro_ver = distro_ver
     self.arch = arch
     self.source = source
     self.components = components
     self.log_threads = {}
     self.log_buffers = {}
     self.log_active = {}
     if debugmethod is None:
         logger = eulogger.Eulogger(identifier= str(hostname) + ":" + str(components))
         self.debugmethod = logger.log.debug
     ### We dont want to login to ESX boxes
     if not re.search("vmware", self.distro, re.IGNORECASE):
         self.ssh = sshconnection.SshConnection(     hostname, 
                                                     keypath=keypath,          
                                                     password=password, 
                                                     username=username, 
                                                     timeout=timeout, 
                                                     retry=retry,
                                                     debugmethod=self.debugmethod,
                                                     verbose=True)
 
         self.sftp = self.ssh.connection.open_sftp()
Esempio n. 3
0
    def __init__(self,
                 hostname,
                 distro="",
                 distro_ver="",
                 arch="",
                 source="",
                 components="",
                 connect=True,
                 password=None,
                 keypath=None,
                 username="******",
                 timeout=120,
                 retry=2,
                 debugmethod=None,
                 verbose=True):

        self.hostname = hostname
        self.distro_ver = distro_ver
        self.distro = self.convert_to_distro(distro, distro_ver)
        if self.distro.package_manager is not None:
            self.repo_utils = RepoUtils(self, self.distro.package_manager)
            self.package_manager = self.repo_utils.package_manager
        self.arch = arch
        self.source = source
        self.components = components
        self.connect = connect
        self.password = password
        self.keypath = keypath
        self.username = username
        self.timeout = timeout
        self.retry = retry
        self.debugmethod = debugmethod
        self.verbose = verbose
        self.log_threads = {}
        self.log_buffers = {}
        self.log_active = {}
        self.wget_last_status = 0
        if self.debugmethod is None:
            logger = eulogger.Eulogger(identifier=str(hostname) + ":" +
                                       str(components))
            self.debugmethod = logger.log.debug
        if self.connect:
            self.ssh = sshconnection.SshConnection(
                hostname,
                keypath=keypath,
                password=password,
                username=username,
                timeout=timeout,
                retry=retry,
                debugmethod=self.debugmethod,
                verbose=True)
            self.sftp = self.ssh.connection.open_sftp()
        # If we were given a conf file, and have an ssh/sftp session, attempt to populate eucalyptus_conf into
        # a euconfig object for this machine...
        self.get_eucalyptus_conf()
Esempio n. 4
0
    def __init__(self,
                 credpath=None,
                 aws_access_key_id=None,
                 aws_secret_access_key=None,
                 region=None,
                 ec2_ip=None,
                 s3_ip=None,
                 boto_debug=0):
        """This class is intended to setup boto connections for the various services that the *ops classes will use.

        :param credpath: Path to a valid eucarc file.
        :param aws_access_key_id: Used in conjuction with aws_secret_access_key allows for creation of connections without needing a credpath.
        :param aws_secret_access_key: Used in conjuction with aws_access_key_id allows for creation of connections without needing a credpath.
        :param region: When connecting to Amazon EC2 allows you to point to a specific region.
        :param ec2_ip: Hostname or IP of the EC2 endpoint to connect to. Can be used in the absence of region.
        :param s3_ip: Hostname or IP of the S3 endpoint to connect to.
        :param boto_debug: Hostname or IP of the S3 endpoint to connect to.
        :rtype: :class:`eutester.Eutester` or ``None``
        :returns: A Eutester object with all connections that were able to be created. Currently EC2, S3, IAM, and STS.
        """
        ### Default values for configuration
        self.boto_debug = boto_debug
        self.credpath = credpath
        self.region = RegionInfo()

        ### Eutester logs
        if self.logger is None:
            self.logger = eulogger.Eulogger(identifier="EUTESTER")
            self.debug = self.logger.log.debug
            self.critical = self.logger.log.critical
            self.info = self.logger.log.info

        ### LOGS to keep for printing later
        self.fail_log = []
        self.running_log = self.logger.log

        ### Pull the access and secret keys from the eucarc or use the ones provided to the constructor
        if self.credpath is not None:
            self.debug("Extracting keys from " + self.credpath)
            self.aws_access_key_id = self.get_access_key()
            self.aws_secret_access_key = self.get_secret_key()
        else:
            self.aws_access_key_id = aws_access_key_id
            self.aws_secret_access_key = aws_secret_access_key

        ### If you have credentials for the boto connections, create them
        if (self.aws_access_key_id
                is not None) and (self.aws_secret_access_key != None):
            if not boto.config.has_section('Boto'):
                boto.config.add_section('Boto')
            boto.config.set('Boto', 'num_retries', '2')
            self.setup_boto_connections(region=region,
                                        ec2_ip=ec2_ip,
                                        s3_ip=s3_ip)
Esempio n. 5
0
    def __init__(self,
                 hostname,
                 distro="",
                 distro_ver="",
                 arch="",
                 source="",
                 components="",
                 connect=True,
                 password=None,
                 keypath=None,
                 username="******",
                 timeout=120,
                 retry=2,
                 debugmethod=None,
                 verbose=True):

        self.hostname = hostname
        self.distro_ver = distro_ver
        self.distro = self.convert_to_distro(distro, distro_ver)
        if self.distro.package_manager is not None:
            self.repo_utils = RepoUtils(self, self.distro.package_manager)
            self.package_manager = self.repo_utils.package_manager
        self.arch = arch
        self.source = source
        self.components = components
        self.connect = connect
        self.password = password
        self.keypath = keypath
        self.username = username
        self.timeout = timeout
        self.retry = retry
        self.debugmethod = debugmethod
        self.verbose = verbose
        self.log_threads = {}
        self.log_buffers = {}
        self.log_active = {}
        self.wget_last_status = 0
        if self.debugmethod is None:
            logger = eulogger.Eulogger(identifier=str(hostname) + ":" +
                                       str(components))
            self.debugmethod = logger.log.debug
        if self.connect:
            self.ssh = sshconnection.SshConnection(
                hostname,
                keypath=keypath,
                password=password,
                username=username,
                timeout=timeout,
                retry=retry,
                debugmethod=self.debugmethod,
                verbose=True)
            self.sftp = self.ssh.connection.open_sftp()
Esempio n. 6
0
    def __init__(self,
                 hostname,
                 distro="",
                 distro_ver="",
                 arch="",
                 source="",
                 components="",
                 connect=True,
                 password=None,
                 keypath=None,
                 username="******",
                 timeout=120,
                 retry=2,
                 debugmethod=None,
                 ssh_proxy_host=None,
                 ssh_proxy_username=None,
                 ssh_proxy_password=None,
                 ssh_proxy_keypath=None,
                 verbose=True):

        self.hostname = hostname
        self.distro_ver = distro_ver
        self.arch = arch
        self.source = source
        self.components = components
        self.connect = connect
        self.password = password
        self.keypath = keypath
        self.username = username
        self.ssh_proxy_host = ssh_proxy_host
        self.ssh_proxy_username = ssh_proxy_username
        self.ssh_proxy_password = ssh_proxy_password
        self.ssh_proxy_keypath = ssh_proxy_keypath
        self.timeout = timeout
        self.retry = retry
        self.debugmethod = debugmethod
        self.verbose = verbose
        self._distroname = distro
        self.log_threads = {}
        self.log_buffers = {}
        self.log_active = {}
        self.wget_last_status = 0
        if self.debugmethod is None:
            logger = eulogger.Eulogger(identifier=str(hostname) + ":" +
                                       str(components))
            self.debugmethod = logger.log.debug
        self._ssh = None
        self._sftp = None
        self._distro = None
        self._repo_utils = None
        self._package_manager = None
        self._config = None
Esempio n. 7
0
    def setUp(self):
        self.gui = Eucaweb(configFile='../input/2b_tested.lst',
                           clcpasswd='foobar')
        self.admin = euwebuser.Euwebuser(user="******",
                                         account="eucalyptus",
                                         passwd="admin")
        self.wg = self.gui.wg

        self.logger = eulogger.Eulogger(name="user_first_time_login")

        self.debug = self.logger.log.debug
        self.critical = self.logger.log.critical
        self.info = self.logger.log.info