python类rds2()的实例源码

rds.py 文件源码 项目:DevOps 作者: YoLoveLife 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def await_resource(conn, resource, status, module):
    wait_timeout = module.params.get('wait_timeout') + time.time()
    while wait_timeout > time.time() and resource.status != status:
        time.sleep(5)
        if wait_timeout <= time.time():
            module.fail_json(msg="Timeout waiting for RDS resource %s" % resource.name)
        if module.params.get('command') == 'snapshot':
            # Temporary until all the rds2 commands have their responses parsed
            if resource.name is None:
                module.fail_json(msg="There was a problem waiting for RDS snapshot %s" % resource.snapshot)
            resource = conn.get_db_snapshot(resource.name)
        else:
            # Temporary until all the rds2 commands have their responses parsed
            if resource.name is None:
                module.fail_json(msg="There was a problem waiting for RDS instance %s" % resource.instance)
            resource = conn.get_db_instance(resource.name)
            if resource is None:
                break
    return resource
rds.py 文件源码 项目:ansible_mysql_rds_playbook 作者: codingenesis 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def await_resource(conn, resource, status, module):
    wait_timeout = module.params.get('wait_timeout') + time.time()
    while wait_timeout > time.time() and resource.status != status:
        time.sleep(5)
        if wait_timeout <= time.time():
            module.fail_json(msg="Timeout waiting for RDS resource %s" % resource.name)
        if module.params.get('command') == 'snapshot':
            # Temporary until all the rds2 commands have their responses parsed
            if resource.name is None:
                module.fail_json(msg="There was a problem waiting for RDS snapshot %s" % resource.snapshot)
            resource = conn.get_db_snapshot(resource.name)
        else:
            # Temporary until all the rds2 commands have their responses parsed
            if resource.name is None:
                module.fail_json(msg="There was a problem waiting for RDS instance %s" % resource.instance)
            resource = conn.get_db_instance(resource.name)
            if resource is None:
                break
    return resource
rds.py 文件源码 项目:DevOps 作者: YoLoveLife 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, module, region, **aws_connect_params):
        try:
            self.connection  = connect_to_aws(boto.rds2, region, **aws_connect_params)
        except boto.exception.BotoServerError as e:
             module.fail_json(msg=e.error_message)
rds.py 文件源码 项目:DevOps 作者: YoLoveLife 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_db_instance(self, instancename):
        try:
            dbinstances = self.connection.describe_db_instances(db_instance_identifier=instancename)['DescribeDBInstancesResponse']['DescribeDBInstancesResult']['DBInstances']
            result =  RDS2DBInstance(dbinstances[0])
            return result
        except boto.rds2.exceptions.DBInstanceNotFound as e:
            return None
        except Exception as e:
            raise e
rds.py 文件源码 项目:DevOps 作者: YoLoveLife 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_db_snapshot(self, snapshotid):
        try:
            snapshots = self.connection.describe_db_snapshots(db_snapshot_identifier=snapshotid, snapshot_type='manual')['DescribeDBSnapshotsResponse']['DescribeDBSnapshotsResult']['DBSnapshots']
            result = RDS2Snapshot(snapshots[0])
            return result
        except boto.rds2.exceptions.DBSnapshotNotFound as e:
            return None
rds.py 文件源码 项目:ansible_mysql_rds_playbook 作者: codingenesis 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, module, region, **aws_connect_params):
        try:
            self.connection  = connect_to_aws(boto.rds2, region, **aws_connect_params)
        except boto.exception.BotoServerError, e:
             module.fail_json(msg=e.error_message)
rds.py 文件源码 项目:ansible_mysql_rds_playbook 作者: codingenesis 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_db_instance(self, instancename):
        try:
            dbinstances = self.connection.describe_db_instances(db_instance_identifier=instancename)['DescribeDBInstancesResponse']['DescribeDBInstancesResult']['DBInstances']
            result =  RDS2DBInstance(dbinstances[0])
            return result
        except boto.rds2.exceptions.DBInstanceNotFound, e:
            return None
        except Exception, e:
            raise e
rds.py 文件源码 项目:ansible_mysql_rds_playbook 作者: codingenesis 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_db_snapshot(self, snapshotid):
        try:
            snapshots = self.connection.describe_db_snapshots(db_snapshot_identifier=snapshotid, snapshot_type='manual')['DescribeDBSnapshotsResponse']['DescribeDBSnapshotsResult']['DBSnapshots']
            result = RDS2Snapshot(snapshots[0])
            return result
        except boto.rds2.exceptions.DBSnapshotNotFound, e:
            return None
vpcutil.py 文件源码 项目:edx-configuration 作者: kola-er 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def rds_subnet_group_name_for_stack_name(stack_name, region='us-east-1', aws_id=None, aws_secret=None):
    # Helper function to look up a subnet group name by stack name
    rds = boto.rds2.connect_to_region(region)
    vpc = vpc_for_stack_name(stack_name)
    for group in rds.describe_db_subnet_groups()['DescribeDBSubnetGroupsResponse']['DescribeDBSubnetGroupsResult']['DBSubnetGroups']:
        if group['VpcId'] == vpc:
            return group['DBSubnetGroupName']
    return None


问题


面经


文章

微信
公众号

扫码关注公众号