当前位置: 首页>>代码示例>>Python>>正文


Python rds.connect_to_region方法代码示例

本文整理汇总了Python中boto.rds.connect_to_region方法的典型用法代码示例。如果您正苦于以下问题:Python rds.connect_to_region方法的具体用法?Python rds.connect_to_region怎么用?Python rds.connect_to_region使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boto.rds的用法示例。


在下文中一共展示了rds.connect_to_region方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_instance

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_instance(self, region, instance_id):
        ''' Gets details about a specific instance '''
        if self.eucalyptus:
            conn = boto.connect_euca(self.eucalyptus_host)
            conn.APIVersion = '2010-08-31'
        else:
            conn = ec2.connect_to_region(region)

        # connect_to_region will fail "silently" by returning None if the region name is wrong or not supported
        if conn is None:
            print("region name: %s likely not supported, or AWS is down.  connection to region failed." % region)
            sys.exit(1)

        reservations = conn.get_all_instances([instance_id])
        for reservation in reservations:
            for instance in reservation.instances:
                return instance 
开发者ID:d1vious,项目名称:splunk-ansible-advance,代码行数:19,代码来源:ec2.py

示例2: get_rds_instances_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_rds_instances_by_region(self, region):
        ''' Makes an AWS API call to the list of RDS instances in a particular
        region '''

        try:
            conn = rds.connect_to_region(region)
            if conn:
                instances = conn.get_all_dbinstances()
                for instance in instances:
                    self.add_rds_instance(instance, region)
        except boto.exception.BotoServerError as e:
            error = e.reason
            
            if e.error_code == 'AuthFailure':
                error = self.get_auth_error_message()
            if not e.reason == "Forbidden":
                error = "Looks like AWS RDS is down:\n%s" % e.message
            self.fail_with_error(error) 
开发者ID:HighOps,项目名称:ansible_ec2_vpc_nat_asg,代码行数:20,代码来源:ec2.py

示例3: get_instance

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_instance(self, region, instance_id):
        ''' Gets details about a specific instance '''
        if self.eucalyptus:
            conn = boto.connect_euca(self.eucalyptus_host)
            conn.APIVersion = '2010-08-31'
        else:
            conn = ec2.connect_to_region(region)
 
        # connect_to_region will fail "silently" by returning None if the region name is wrong or not supported
        if conn is None:
            print("region name: %s likely not supported, or AWS is down.  connection to region failed." % region)
            sys.exit(1)
 
        reservations = conn.get_all_instances([instance_id])
        for reservation in reservations:
            for instance in reservation.instances:
                return instance 
开发者ID:geerlingguy,项目名称:ansible-for-devops,代码行数:19,代码来源:ec2.py

示例4: get_rds_instances_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_rds_instances_by_region(self, region):
        ''' Makes an AWS API call to the list of RDS instances in a particular
        region '''

        try:
            conn = rds.connect_to_region(region)
            if conn:
                instances = conn.get_all_dbinstances()
                for instance in instances:
                    self.add_rds_instance(instance, region)
        except boto.exception.BotoServerError as e:
            error = e.reason

            if e.error_code == 'AuthFailure':
                error = self.get_auth_error_message()
            if not e.reason == "Forbidden":
                error = "Looks like AWS RDS is down:\n%s" % e.message
            self.fail_with_error(error, 'getting RDS instances') 
开发者ID:FairwindsOps,项目名称:pentagon,代码行数:20,代码来源:ec2.py

示例5: get_instances_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_instances_by_region(self, region):
        ''' Makes an AWS EC2 API call to the list of instances in a particular
        region '''

        try:
            if self.eucalyptus:
                conn = boto.connect_euca(host=self.eucalyptus_host)
                conn.APIVersion = '2010-08-31'
            else:
                conn = ec2.connect_to_region(region)

            # connect_to_region will fail "silently" by returning None if the region name is wrong or not supported
            if conn is None:
                print("region name: %s likely not supported, or AWS is down.  connection to region failed." % region)
                sys.exit(1)
 
            reservations = conn.get_all_instances()
            for reservation in reservations:
                for instance in reservation.instances:
                    self.add_instance(instance, region)
        
        except boto.exception.BotoServerError, e:
            if  not self.eucalyptus:
                print "Looks like AWS is down again:"
            print e
            sys.exit(1) 
开发者ID:d1vious,项目名称:splunk-ansible-advance,代码行数:28,代码来源:ec2.py

示例6: get_rds_instances_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_rds_instances_by_region(self, region):
	''' Makes an AWS API call to the list of RDS instances in a particular
        region '''

        try:
            conn = rds.connect_to_region(region)
            if conn:
                instances = conn.get_all_dbinstances()
                for instance in instances:
                    self.add_rds_instance(instance, region)
        except boto.exception.BotoServerError, e:
            if not e.reason == "Forbidden":
                print "Looks like AWS RDS is down: "
                print e
                sys.exit(1) 
开发者ID:d1vious,项目名称:splunk-ansible-advance,代码行数:17,代码来源:ec2.py

示例7: connect

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def connect(self, region):
        ''' create connection to api server'''
        if self.eucalyptus:
            conn = boto.connect_euca(host=self.eucalyptus_host)
            conn.APIVersion = '2010-08-31'
        else:
            conn = ec2.connect_to_region(region)
        # connect_to_region will fail "silently" by returning None if the region name is wrong or not supported
        if conn is None:
            self.fail_with_error("region name: %s likely not supported, or AWS is down.  connection to region failed." % region)
        return conn 
开发者ID:HighOps,项目名称:ansible_ec2_vpc_nat_asg,代码行数:13,代码来源:ec2.py

示例8: get_instances_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_instances_by_region(self, region):
        ''' Makes an AWS EC2 API call to the list of instances in a particular
        region '''
 
        try:
            if self.eucalyptus:
                conn = boto.connect_euca(host=self.eucalyptus_host)
                conn.APIVersion = '2010-08-31'
            else:
                conn = ec2.connect_to_region(region)
 
            # connect_to_region will fail "silently" by returning None if the region name is wrong or not supported
            if conn is None:
                print("region name: %s likely not supported, or AWS is down.  connection to region failed." % region)
                sys.exit(1)
 
            reservations = []
            if self.ec2_instance_filters:
                for filter_key, filter_values in self.ec2_instance_filters.iteritems():
                    reservations.extend(conn.get_all_instances(filters = { filter_key : filter_values }))
            else:
                reservations = conn.get_all_instances()
 
            for reservation in reservations:
                for instance in reservation.instances:
                    self.add_instance(instance, region)
 
        except boto.exception.BotoServerError, e:
            if  not self.eucalyptus:
                print "Looks like AWS is down again:"
            print e
            sys.exit(1) 
开发者ID:geerlingguy,项目名称:ansible-for-devops,代码行数:34,代码来源:ec2.py

示例9: get_rds_instances_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_rds_instances_by_region(self, region):
        ''' Makes an AWS API call to the list of RDS instances in a particular
        region '''
 
        try:
            conn = rds.connect_to_region(region)
            if conn:
                instances = conn.get_all_dbinstances()
                for instance in instances:
                    self.add_rds_instance(instance, region)
        except boto.exception.BotoServerError, e:
            if not e.reason == "Forbidden":
                print "Looks like AWS RDS is down: "
                print e
                sys.exit(1) 
开发者ID:geerlingguy,项目名称:ansible-for-devops,代码行数:17,代码来源:ec2.py

示例10: get_instances_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_instances_by_region(self, region):
        ''' Makes an AWS EC2 API call to the list of instances in a particular
        region '''

        try:
            if self.eucalyptus:
                conn = boto.connect_euca(host=self.eucalyptus_host)
                conn.APIVersion = '2010-08-31'
            else:
                conn = ec2.connect_to_region(region)

            # connect_to_region will fail "silently" by returning None if the region name is wrong or not supported
            if conn is None:
                print("region name: %s likely not supported, or AWS is down.  connection to region failed." % region)
                sys.exit(1)

            reservations = []
            if self.ec2_instance_filters:
                for filter_key, filter_values in self.ec2_instance_filters.iteritems():
                    reservations.extend(conn.get_all_instances(filters = { filter_key : filter_values }))
            else:
                reservations = conn.get_all_instances()

            for reservation in reservations:
                for instance in reservation.instances:
                    self.add_instance(instance, region)

        except boto.exception.BotoServerError, e:
            if  not self.eucalyptus:
                print "Looks like AWS is down again:"
            print e
            sys.exit(1) 
开发者ID:keithadavidson,项目名称:ansible-mezzanine,代码行数:34,代码来源:ec2.py

示例11: get_rds_instances_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_rds_instances_by_region(self, region):
        ''' Makes an AWS API call to the list of RDS instances in a particular
        region '''

        try:
            conn = rds.connect_to_region(region)
            if conn:
                instances = conn.get_all_dbinstances()
                for instance in instances:
                    self.add_rds_instance(instance, region)
        except boto.exception.BotoServerError, e:
            if not e.reason == "Forbidden":
                print "Looks like AWS RDS is down: "
                print e
                sys.exit(1) 
开发者ID:keithadavidson,项目名称:ansible-mezzanine,代码行数:17,代码来源:ec2.py

示例12: get_elasticache_clusters_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_elasticache_clusters_by_region(self, region):
        ''' Makes an AWS API call to the list of ElastiCache clusters (with
        nodes' info) in a particular region.'''

        # ElastiCache boto module doesn't provide a get_all_intances method,
        # that's why we need to call describe directly (it would be called by
        # the shorthand method anyway...)
        try:
            conn = elasticache.connect_to_region(region)
            if conn:
                # show_cache_node_info = True
                # because we also want nodes' information
                response = conn.describe_cache_clusters(None, None, None, True)

        except boto.exception.BotoServerError as e:
            error = e.reason

            if e.error_code == 'AuthFailure':
                error = self.get_auth_error_message()
            if not e.reason == "Forbidden":
                error = "Looks like AWS ElastiCache is down:\n%s" % e.message
            self.fail_with_error(error, 'getting ElastiCache clusters')

        try:
            # Boto also doesn't provide wrapper classes to CacheClusters or
            # CacheNodes. Because of that wo can't make use of the get_list
            # method in the AWSQueryConnection. Let's do the work manually
            clusters = response['DescribeCacheClustersResponse']['DescribeCacheClustersResult']['CacheClusters']

        except KeyError as e:
            error = "ElastiCache query to AWS failed (unexpected format)."
            self.fail_with_error(error, 'getting ElastiCache clusters')

        for cluster in clusters:
            self.add_elasticache_cluster(cluster, region) 
开发者ID:FairwindsOps,项目名称:pentagon,代码行数:37,代码来源:ec2.py

示例13: get_elasticache_replication_groups_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_elasticache_replication_groups_by_region(self, region):
        ''' Makes an AWS API call to the list of ElastiCache replication groups
        in a particular region.'''

        # ElastiCache boto module doesn't provide a get_all_intances method,
        # that's why we need to call describe directly (it would be called by
        # the shorthand method anyway...)
        try:
            conn = elasticache.connect_to_region(region)
            if conn:
                response = conn.describe_replication_groups()

        except boto.exception.BotoServerError as e:
            error = e.reason

            if e.error_code == 'AuthFailure':
                error = self.get_auth_error_message()
            if not e.reason == "Forbidden":
                error = "Looks like AWS ElastiCache [Replication Groups] is down:\n%s" % e.message
            self.fail_with_error(error, 'getting ElastiCache clusters')

        try:
            # Boto also doesn't provide wrapper classes to ReplicationGroups
            # Because of that wo can't make use of the get_list method in the
            # AWSQueryConnection. Let's do the work manually
            replication_groups = response['DescribeReplicationGroupsResponse']['DescribeReplicationGroupsResult']['ReplicationGroups']

        except KeyError as e:
            error = "ElastiCache [Replication Groups] query to AWS failed (unexpected format)."
            self.fail_with_error(error, 'getting ElastiCache clusters')

        for replication_group in replication_groups:
            self.add_elasticache_replication_group(replication_group, region) 
开发者ID:FairwindsOps,项目名称:pentagon,代码行数:35,代码来源:ec2.py

示例14: get_instances_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_instances_by_region(self, region):
        ''' Makes an AWS EC2 API call to the list of instances in a particular
        region '''

        try:
            if self.eucalyptus:
                conn = boto.connect_euca(host=self.eucalyptus_host)
                conn.APIVersion = '2010-08-31'
            else:
                conn = ec2.connect_to_region(region)

            # connect_to_region will fail "silently" by returning None if the region name is wrong or not supported
            if conn is None:
                print("region name: %s likely not supported, or AWS is down.  connection to region failed." % region)
                sys.exit(1)

            reservations = conn.get_all_instances()
            for reservation in reservations:
                instances = sorted(reservation.instances)
                for instance in instances:
                    self.add_instance(instance, region)

        except boto.exception.BotoServerError as e:
            if  not self.eucalyptus:
                print "Looks like AWS is down again:"
            print e
            sys.exit(1) 
开发者ID:edx,项目名称:edx-analytics-pipeline,代码行数:29,代码来源:ec2.py

示例15: get_rds_instances_by_region

# 需要导入模块: from boto import rds [as 别名]
# 或者: from boto.rds import connect_to_region [as 别名]
def get_rds_instances_by_region(self, region):
	''' Makes an AWS API call to the list of RDS instances in a particular
        region '''

        try:
            conn = rds.connect_to_region(region)
            if conn:
                instances = conn.get_all_dbinstances()
                for instance in instances:
                    self.add_rds_instance(instance, region)
        except boto.exception.BotoServerError as e:
            print "Looks like AWS RDS is down: "
            print e
            sys.exit(1) 
开发者ID:edx,项目名称:edx-analytics-pipeline,代码行数:16,代码来源:ec2.py


注:本文中的boto.rds.connect_to_region方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。