def snapshot_status(self, snapshot_id, region): self.client = get_amazon_client(self.kwargs['type'], region) snapshots = self.get_snapshots() for snapshot in snapshots['DBSnapshots']: if snapshot['DBSnapshotIdentifier'] == snapshot_id: status = snapshot['Status'] return status
def create_snapshot(self, region): c = get_amazon_client(self.config()['a_type'], region) response = c.create_db_snapshot( DBSnapshotIdentifier=self.config()['a_snap_id'], DBInstanceIdentifier=self.config()['a_db_identifier']) return response
def snapshot_status(self, DBSnapshotIdentifier, region): # Changing region(source->dest), to be able to copy snapshot from SourceRegion to DestinationRegion self.client = get_amazon_client(self.kwargs['type'], region) snapshots = self.get_snapshots() for snapshot in snapshots['DBSnapshots']: if snapshot['DBSnapshotIdentifier'] == DBSnapshotIdentifier: status = snapshot['Status'] return status
def instance_is_available(self, region): c = get_amazon_client(self.config()['a_type'], region) instance = c.describe_db_instances( DBInstanceIdentifier=self.config()['a_db_identifier']) status = instance['DBInstances'][0]['DBInstanceStatus'] return status
def copy_snapshot(self, resource, region): source_db_snapshot_identifier = resource['DBSnapshot']['DBSnapshotArn'] self.client = get_amazon_client(self.kwargs['type'], region) response = self.client.copy_db_snapshot( SourceDBSnapshotIdentifier=source_db_snapshot_identifier, TargetDBSnapshotIdentifier=self.parameters['DBSnapshotIdentifier'], CopyTags=True, SourceRegion=self.parameters['region']) return response
def copy_snapshot(self, resource, region): SourceDBSnapshotIdentifier = resource['DBSnapshot']['DBSnapshotArn'] c = get_amazon_client(self.config()['a_type'], region) response = c.copy_db_snapshot( SourceDBSnapshotIdentifier=SourceDBSnapshotIdentifier, TargetDBSnapshotIdentifier=self.config()['a_snap_id'], CopyTags=True, SourceRegion=self.config()['a_region']) return response
def copy_snapshot(self, resource, region): SourceDBSnapshotIdentifier = resource['DBSnapshot']['DBSnapshotArn'] # Changing region(source->dest), to be able to copy snapshot from SourceRegion to DestinationRegion self.client = get_amazon_client(self.kwargs['type'], region) response = self.client.copy_db_snapshot( Engine=self.parameters['engine'], SourceDBSnapshotIdentifier=SourceDBSnapshotIdentifier, TargetDBSnapshotIdentifier=self.parameters['snapshotId'], CopyTags=True, SourceRegion=self.parameters['region'] ) return response
def delete_snapshot(self, region, snapshots): c = get_amazon_client(self.config()['a_type'], region) r = [] for i in snapshots: response = c.delete_db_snapshot( DBSnapshotIdentifier=i['DBSnapshotIdentifier']) print( get_msg(self.config()['a_type']) + 'Deleting snapshot {} in {} region...'.format( i['DBSnapshotIdentifier'], region)) r.append(response) return r
def get_snapshots(self, region): c = get_amazon_client(self.config()['a_type'], region) response = c.describe_db_snapshots() return response
def __init__(self, **kwargs): self.kwargs = kwargs self.parameters = self.kwargs['parameters'] self.validate = ValidateElasticache() self.client = get_amazon_client(self.kwargs['type'], self.parameters['region'])
def __init__(self, **kwargs): super().__init__(**kwargs) self.client = get_amazon_client(self.type, self.params['region'])