def connect_rds(): logger.debug('Connecting to the Amazon Relational Database Service (Amazon RDS).') rds = boto.connect_rds2(aws_access_key_id=config['AWS_ACCESS_KEY_ID'], aws_secret_access_key=config['AWS_SECRET_ACCESS_KEY']) logger.debug('Connected to Amazon RDS.') return rds
def connect(self): """Connect to API if not already connected; set self.conn.""" if self.conn is not None: return elif self.region: self.conn = self.connect_via(boto.rds2.connect_to_region) else: self.conn = boto.connect_rds2()
def RDSConn(reg,profile = 'default'): rdsconn = '' endpt = 'rds.' + reg + '.amazonaws.com' reg = boto.regioninfo.RegionInfo(name=reg,endpoint=endpt) try: rdsconn=boto.connect_rds2(profile_name=profile, region=reg) except Exception, e: boto.log.error("Cannot validate provided AWS credentials: %s" % e)
def connect_rds(): """ Connect to the Amazon Relational Database Service (Amazon RDS) service. :rtype: :class:`boto.rds.RDSConnection` :return: An :class:`~boto.rds.RDSConnection` object. """ logger.debug('Connecting to the Amazon Relational Database Service (Amazon RDS).') rds = boto.connect_rds2(aws_access_key_id=config['AWS_ACCESS_KEY_ID'], aws_secret_access_key=config['AWS_SECRET_ACCESS_KEY']) logger.debug('Connected to Amazon RDS.') return rds
def get_db_info(): rds_conn = boto.connect_rds2(profile_name=AWS_PROFILE) if not rds_conn: print(_red('Cannot connect to AWS.RDS')) return instances = rds_conn.describe_db_instances() if not instances: print(_red('No instances found')) return count = len(instances['DescribeDBInstancesResponse'] ['DescribeDBInstancesResult']['DBInstances']) for i in range(0, count): inst = instances['DescribeDBInstancesResponse'][ 'DescribeDBInstancesResult']['DBInstances'][i] #print(str(inst)) dbinfo = {} endpoint = inst['Endpoint'] dbinfo['VPCSecurityGroupId'] = inst['VpcSecurityGroups'][0][ 'VpcSecurityGroupId'] dbinfo['dbSecurityGroupName'] = inst['DBSecurityGroups'][0][ 'DBSecurityGroupName'] dbinfo['host'] = endpoint['Address'] dbinfo['port'] = endpoint['Port'] dbinfo['user'] = inst['MasterUsername'] dbinfo['name'] = inst['DBName'] dbinfo['instanceClass'] = inst['DBInstanceClass'] dbinfo['dbID'] = inst['DBInstanceIdentifier'] dbinfo['Engine'] = inst['Engine'] dbinfo['EngineVersion'] = inst['EngineVersion'] print('') print(_blue('db Info %d ===========>\n' % i)) for item in dbinfo: print(_green('%20s : %s' % (item, dbinfo[item])))
import sys import backends.rds2.models import backends.ec2.models import moto import boto if len(sys.argv) == 1 or (len(sys.argv) > 1 and sys.argv[1] == '1'): with moto.mock_rds2(): conn = boto.connect_rds2('foo', 'bar') conn.create_db_instance('foo', '10', 'db.t1.micro', 'postgres', 'foo', 'bar') db_instances = conn.describe_db_instances() print db_instances raw_input('WAITING...') print conn.delete_db_instance(db_instances['DescribeDBInstancesResponse']['DescribeDBInstancesResult']['DBInstances'][0]['DBInstanceIdentifier']) elif len(sys.argv) > 1 and sys.argv[1] == '2': with moto.mock_ec2(): conn = boto.connect_ec2('foo', 'bar') reservation = conn.run_instances('ami-f00ba4') print reservation raw_input('WAITING...')
def test_connect_rds(self): # Upon release, this did not function correct. Ensure that # args are passed correctly. import boto conn = boto.connect_rds2()
# author vishwanath subramanian import boto import boto.ec2 import boto.rds import boto.emr import boto.redshift from collections import Counter import boto.ec2.cloudwatch import datetime ec2 = boto.connect_ec2() rds = boto.connect_rds2() s3 = boto.connect_s3() emr = boto.connect_emr() rs = boto.connect_redshift() cw = boto.ec2.cloudwatch.connect_to_region('us-west-1') all_running_clusters = [] all_ins_names = [] today = datetime.datetime.now() yesterday = today - datetime.timedelta(days=1) def getKey(item): return item[1] # Get all the EC2 instances running def all_instances(): reservations = ec2.get_all_instances(filters={'instance-state-code': '16'}) print '\nALL RUNNING EC2 INSTANCES'
def connect(self): if self.conn is None: logger.debug("Connecting to %s", self.service_name) # TODO: set this to the correct connection method: self.conn = boto.connect_rds2() logger.info("Connected to %s", self.service_name)