示例#1
0
    def setup_sts_connection(self, endpoint=None, region=None, aws_access_key_id=None, aws_secret_access_key=None, path="/",port=443, is_secure=True, boto_debug=0):
        sts_region = RegionInfo()
        if region:
            self.debug("Check region: " + str(region))
            try:
                if not endpoint:
                    sts_region.endpoint = EC2RegionData[region]
                else:
                    sts_region.endpoint = endpoint
            except KeyError:
                raise Exception( 'Unknown region: %s' % region)
        else:
            sts_region.name = 'eucalyptus'
            if endpoint:
                sts_region.endpoint = endpoint
            else:
                sts_region.endpoint = self.get_ec2_ip()

        try:
            sts_connection_args = { 'aws_access_key_id' : aws_access_key_id,
                                    'aws_secret_access_key': aws_secret_access_key,
                                    'is_secure': is_secure,
                                    'debug':boto_debug,
                                    'port' : port,
                                    'path' : path,
                                    'region' : sts_region}
            self.debug("Attempting to create STS connection to " + self.get_ec2_ip() + str(port) + path)
            self.tokens = boto.connect_sts(**sts_connection_args)
        except Exception, e:
            self.critical("Was unable to create STS connection because of exception: " + str(e))
示例#2
0
    def setup_cfn_connection(self, endpoint=None, region=None, aws_access_key_id=None, aws_secret_access_key=None, path="/",port=443, is_secure=True, boto_debug=0):
        cfn_region = RegionInfo()
        if region:
            self.debug("Check region: " + str(region))
            try:
                if not endpoint:
                    cfn_region.endpoint = "cloudformation.{0}.amazonaws.com".format(region)
                else:
                    cfn_region.endpoint = endpoint
            except KeyError:
                raise Exception( 'Unknown region: %s' % region)
        else:
            cfn_region.name = 'eucalyptus'
            if endpoint:
                cfn_region.endpoint = endpoint
            else:
                cfn_region.endpoint = self.get_cfn_ip()

        try:
            cfn_connection_args = { 'aws_access_key_id' : aws_access_key_id,
                                    'aws_secret_access_key': aws_secret_access_key,
                                    'is_secure': is_secure,
                                    'debug':boto_debug,
                                    'port' : port,
                                    'path' : path,
                                    'region' : cfn_region}
            self.debug("Attempting to create cloudformation connection to " + self.get_cfn_ip() + ':' + str(port) + path)
            self.cloudformation = boto.connect_cloudformation(**cfn_connection_args)
        except Exception, e:
            self.critical("Was unable to create cloudformation connection because of exception: " + str(e))
示例#3
0
文件: stsops.py 项目: gholms/eutester
    def setup_sts_connection(self, endpoint=None, region=None, aws_access_key_id=None, aws_secret_access_key=None, path="/",port=443, is_secure=True, boto_debug=0):
        sts_region = RegionInfo()
        if region:
            self.debug("Check region: " + str(region))
            try:
                if not endpoint:
                    sts_region.endpoint = EC2RegionData[region]
                else:
                    sts_region.endpoint = endpoint
            except KeyError:
                raise Exception( 'Unknown region: %s' % region)
        else:
            sts_region.name = 'eucalyptus'
            if endpoint:
                sts_region.endpoint = endpoint
            else:
                sts_region.endpoint = self.get_ec2_ip()

        try:
            sts_connection_args = { 'aws_access_key_id' : aws_access_key_id,
                                    'aws_secret_access_key': aws_secret_access_key,
                                    'is_secure': is_secure,
                                    'debug':boto_debug,
                                    'port' : port,
                                    'path' : path,
                                    'region' : sts_region}
            self.debug("Attempting to create STS connection to " + self.get_ec2_ip() + ':' + str(port) + path)
            self.tokens = boto.connect_sts(**sts_connection_args)
        except Exception, e:
            self.critical("Was unable to create STS connection because of exception: " + str(e))
示例#4
0
    def get_cw_connection_args(self,
                               endpoint=None,
                               aws_access_key_id=None,
                               aws_secret_access_key=None,
                               is_secure=True,
                               host=None,
                               region=None,
                               path='/',
                               port=443,
                               boto_debug=0):
        '''

        :param endpoint:
        :param aws_access_key_id:
        :param aws_secret_access_key:
        :param is_secure:
        :param host:
        :param region:
        :param path:
        :param port:
        :param boto_debug:
        :raise:
        '''
        cw_region = RegionInfo()
        if region:
            self.log.debug('Check region: ' + str(region))
            try:
                if not endpoint:
                    cw_region.endpoint = CWRegionData[region]
                else:
                    cw_region.endpoint = endpoint
            except KeyError:
                raise Exception('Unknown region: %s' % region)
        else:
            cw_region.name = 'eucalyptus'
            if not host:
                if endpoint:
                    cw_region.endpoint = endpoint
                else:
                    cw_region.endpoint = self.get_cw_ip()
        connection_args = {
            'aws_access_key_id': aws_access_key_id,
            'aws_secret_access_key': aws_secret_access_key,
            'is_secure': is_secure,
            'debug': boto_debug,
            'port': port,
            'path': path,
            'region': cw_region
        }

        if re.search('2.6', boto_version):
            connection_args['validate_certs'] = False
        cw_connection_args = copy.copy(connection_args)
        cw_connection_args['path'] = path
        cw_connection_args['region'] = cw_region
        return cw_connection_args
示例#5
0
文件: elbops.py 项目: gholms/eutester
    def setup_elb_connection(self, endpoint=None, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True,
                             host=None,
                             region=None, path="/", port=443, boto_debug=0):
        """

        :param endpoint:
        :param aws_access_key_id:
        :param aws_secret_access_key:
        :param is_secure:
        :param host:
        :param region:
        :param path:
        :param port:
        :param boto_debug:
        :raise:
        """
        elb_region = RegionInfo()
        if region:
            self.debug("Check region: " + str(region))
            try:
                if not endpoint:
                    elb_region.endpoint = ELBRegionData[region]
                else:
                    elb_region.endpoint = endpoint
            except KeyError:
                raise Exception('Unknown region: %s' % region)
        else:
            elb_region.name = 'eucalyptus'
            if not host:
                if endpoint:
                    elb_region.endpoint = endpoint
                else:
                    elb_region.endpoint = self.get_elb_ip()
        connection_args = {'aws_access_key_id': aws_access_key_id,
                           'aws_secret_access_key': aws_secret_access_key,
                           'is_secure': is_secure,
                           'debug': boto_debug,
                           'port': port,
                           'path': path,
                           'region': elb_region}

        if re.search('2.6', boto.__version__):
            connection_args['validate_certs'] = False

        try:
            elb_connection_args = copy.copy(connection_args)
            elb_connection_args['path'] = path
            elb_connection_args['region'] = elb_region
            self.debug(
                "Attempting to create load balancer connection to " + elb_region.endpoint + ':' + str(port) + path)
            self.elb = boto.connect_elb(**elb_connection_args)
        except Exception, e:
            self.critical("Was unable to create elb connection because of exception: " + str(e))
示例#6
0
    def setup_cw_connection(self, endpoint=None, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True,
                            host=None,
                            region=None, path='/', port=443, boto_debug=0):
        '''

        :param endpoint:
        :param aws_access_key_id:
        :param aws_secret_access_key:
        :param is_secure:
        :param host:
        :param region:
        :param path:
        :param port:
        :param boto_debug:
        :raise:
        '''
        cw_region = RegionInfo()
        if region:
            self.debug('Check region: ' + str(region))
            try:
                if not endpoint:
                    cw_region.endpoint = CWRegionData[region]
                else:
                    cw_region.endpoint = endpoint
            except KeyError:
                raise Exception('Unknown region: %s' % region)
        else:
            cw_region.name = 'eucalyptus'
            if not host:
                if endpoint:
                    cw_region.endpoint = endpoint
                else:
                    cw_region.endpoint = self.get_cw_ip()
        connection_args = {'aws_access_key_id': aws_access_key_id,
                           'aws_secret_access_key': aws_secret_access_key,
                           'is_secure': is_secure,
                           'debug': boto_debug,
                           'port': port,
                           'path': path,
                           'region': cw_region}

        if re.search('2.6', boto.__version__):
            connection_args['validate_certs'] = False

        try:
            cw_connection_args = copy.copy(connection_args)
            cw_connection_args['path'] = path
            cw_connection_args['region'] = cw_region
            self.debug('Attempting to create cloud watch connection to ' + cw_region.endpoint + ':' + str(port) + path)
            self.cw = boto.connect_cloudwatch(**cw_connection_args)
        except Exception, e:
            self.critical('Was unable to create Cloud Watch connection because of exception: ' + str(e))
示例#7
0
文件: cwops.py 项目: gholms/eutester
    def setup_cw_connection(self, endpoint=None, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True,
                            host=None,
                            region=None, path='/', port=443, boto_debug=0):
        '''

        :param endpoint:
        :param aws_access_key_id:
        :param aws_secret_access_key:
        :param is_secure:
        :param host:
        :param region:
        :param path:
        :param port:
        :param boto_debug:
        :raise:
        '''
        cw_region = RegionInfo()
        if region:
            self.debug('Check region: ' + str(region))
            try:
                if not endpoint:
                    cw_region.endpoint = CWRegionData[region]
                else:
                    cw_region.endpoint = endpoint
            except KeyError:
                raise Exception('Unknown region: %s' % region)
        else:
            cw_region.name = 'eucalyptus'
            if not host:
                if endpoint:
                    cw_region.endpoint = endpoint
                else:
                    cw_region.endpoint = self.get_cw_ip()
        connection_args = {'aws_access_key_id': aws_access_key_id,
                           'aws_secret_access_key': aws_secret_access_key,
                           'is_secure': is_secure,
                           'debug': boto_debug,
                           'port': port,
                           'path': path,
                           'region': cw_region}

        if re.search('2.6', boto.__version__):
            connection_args['validate_certs'] = False

        try:
            cw_connection_args = copy.copy(connection_args)
            cw_connection_args['path'] = path
            cw_connection_args['region'] = cw_region
            self.debug('Attempting to create cloud watch connection to ' + cw_region.endpoint + ':' + str(port) + path)
            self.cw = boto.connect_cloudwatch(**cw_connection_args)
        except Exception, e:
            self.critical('Was unable to create Cloud Watch connection because of exception: ' + str(e))
示例#8
0
    def get_cw_connection_args(self, endpoint=None, aws_access_key_id=None,
                               aws_secret_access_key=None, is_secure=True,
                               host=None, region=None, path='/', port=443, boto_debug=0):
        '''

        :param endpoint:
        :param aws_access_key_id:
        :param aws_secret_access_key:
        :param is_secure:
        :param host:
        :param region:
        :param path:
        :param port:
        :param boto_debug:
        :raise:
        '''
        cw_region = RegionInfo()
        if region:
            self.debug('Check region: ' + str(region))
            try:
                if not endpoint:
                    cw_region.endpoint = CWRegionData[region]
                else:
                    cw_region.endpoint = endpoint
            except KeyError:
                raise Exception('Unknown region: %s' % region)
        else:
            cw_region.name = 'eucalyptus'
            if not host:
                if endpoint:
                    cw_region.endpoint = endpoint
                else:
                    cw_region.endpoint = self.get_cw_ip()
        connection_args = {'aws_access_key_id': aws_access_key_id,
                           'aws_secret_access_key': aws_secret_access_key,
                           'is_secure': is_secure,
                           'debug': boto_debug,
                           'port': port,
                           'path': path,
                           'region': cw_region}

        if re.search('2.6', boto_version):
            connection_args['validate_certs'] = False
        cw_connection_args = copy.copy(connection_args)
        cw_connection_args['path'] = path
        cw_connection_args['region'] = cw_region
        return cw_connection_args
示例#9
0
    def setup_cfn_connection(self,
                             endpoint=None,
                             region=None,
                             aws_access_key_id=None,
                             aws_secret_access_key=None,
                             path="/",
                             port=443,
                             is_secure=True,
                             boto_debug=0):
        cfn_region = RegionInfo()
        if region:
            self.debug("Check region: " + str(region))
            try:
                if not endpoint:
                    cfn_region.endpoint = "cloudformation.{0}.amazonaws.com".format(
                        region)
                else:
                    cfn_region.endpoint = endpoint
            except KeyError:
                raise Exception('Unknown region: %s' % region)
        else:
            cfn_region.name = 'eucalyptus'
            if endpoint:
                cfn_region.endpoint = endpoint
            else:
                cfn_region.endpoint = self.get_cfn_ip()

        try:
            cfn_connection_args = {
                'aws_access_key_id': aws_access_key_id,
                'aws_secret_access_key': aws_secret_access_key,
                'is_secure': is_secure,
                'debug': boto_debug,
                'port': port,
                'path': path,
                'region': cfn_region
            }
            self.debug("Attempting to create cloudformation connection to " +
                       self.get_cfn_ip() + ':' + str(port) + path)
            self.cloudformation = boto.connect_cloudformation(
                **cfn_connection_args)
        except Exception, e:
            self.critical(
                "Was unable to create cloudformation connection because of exception: "
                + str(e))
示例#10
0
    def setup_sts_connection(
        self,
        endpoint=None,
        region=None,
        aws_access_key_id=None,
        aws_secret_access_key=None,
        path="/",
        port=443,
        is_secure=True,
        boto_debug=0,
    ):
        sts_region = RegionInfo()
        if region:
            self.debug("Check region: " + str(region))
            try:
                if not endpoint:
                    sts_region.endpoint = EC2RegionData[region]
                else:
                    sts_region.endpoint = endpoint
            except KeyError:
                raise Exception("Unknown region: %s" % region)
        else:
            sts_region.name = "eucalyptus"
            if endpoint:
                sts_region.endpoint = endpoint
            else:
                sts_region.endpoint = self.get_sts_ip()

        try:
            sts_connection_args = {
                "aws_access_key_id": aws_access_key_id,
                "aws_secret_access_key": aws_secret_access_key,
                "is_secure": is_secure,
                "debug": boto_debug,
                "port": port,
                "path": path,
                "region": sts_region,
            }
            self.debug("Attempting to create STS connection to " + sts_region.endpoint + ":" + str(port) + path)
            self.tokens = boto.connect_sts(**sts_connection_args)
        except Exception, e:
            self.critical("Was unable to create STS connection because of exception: " + str(e))
示例#11
0
    def setup_elb_connection(
        self,
        endpoint=None,
        aws_access_key_id=None,
        aws_secret_access_key=None,
        is_secure=True,
        host=None,
        region=None,
        path="/",
        port=443,
        boto_debug=0,
    ):
        """

        :param endpoint:
        :param aws_access_key_id:
        :param aws_secret_access_key:
        :param is_secure:
        :param host:
        :param region:
        :param path:
        :param port:
        :param boto_debug:
        :raise:
        """
        elb_region = RegionInfo()
        if region:
            self.debug("Check region: " + str(region))
            try:
                if not endpoint:
                    elb_region.endpoint = ELBRegionData[region]
                else:
                    elb_region.endpoint = endpoint
            except KeyError:
                raise Exception("Unknown region: %s" % region)
        else:
            elb_region.name = "eucalyptus"
            if not host:
                if endpoint:
                    elb_region.endpoint = endpoint
                else:
                    elb_region.endpoint = self.get_elb_ip()
        connection_args = {
            "aws_access_key_id": aws_access_key_id,
            "aws_secret_access_key": aws_secret_access_key,
            "is_secure": is_secure,
            "debug": boto_debug,
            "port": port,
            "path": path,
            "region": elb_region,
        }

        if re.search("2.6", boto.__version__):
            connection_args["validate_certs"] = False

        try:
            elb_connection_args = copy.copy(connection_args)
            elb_connection_args["path"] = path
            elb_connection_args["region"] = elb_region
            self.debug(
                "Attempting to create load balancer connection to " + elb_region.endpoint + ":" + str(port) + path
            )
            self.elb = boto.connect_elb(**elb_connection_args)
        except Exception, e:
            self.critical("Was unable to create elb connection because of exception: " + str(e))