List of usage examples for com.amazonaws.services.rds AmazonRDSClient describeDBInstances
@Override
public DescribeDBInstancesResult describeDBInstances()
From source file:com.hangum.tadpole.aws.rds.commons.core.utils.AmazonRDSUtsils.java
License:Open Source License
/** * Get RDS to Tadpole UserDB data./* w w w. j av a 2 s . com*/ * * @param accessKey * @param secretKey * @param regionName * @return * @throws Exception */ public static List<AWSRDSUserDBDAO> getDBList(String accessKey, String secretKey, String regionName) throws Exception { List<AWSRDSUserDBDAO> returnDBList = new ArrayList<AWSRDSUserDBDAO>(); try { BasicAWSCredentials awsCredential = new BasicAWSCredentials(accessKey, secretKey); AmazonRDSClient rdsClient = new AmazonRDSClient(awsCredential); rdsClient.setRegion(RegionUtils.getRegion(regionName)); DescribeDBInstancesResult describeDBInstance = rdsClient.describeDBInstances(); List<DBInstance> listDBInstance = describeDBInstance.getDBInstances(); for (DBInstance rdsDbInstance : listDBInstance) { AWSRDSUserDBDAO rdsUserDB = new AWSRDSUserDBDAO(); // rds information rdsUserDB.setAccessKey(accessKey); rdsUserDB.setSecretKey(secretKey); rdsUserDB.setEndPoint(regionName); // ext information rdsUserDB.setExt1(rdsDbInstance.getDBInstanceClass()); rdsUserDB.setExt2(rdsDbInstance.getAvailabilityZone()); // db information String strDBMStype = rdsDbInstance.getEngine(); if (strDBMStype.startsWith("sqlserver")) { String strEngVer = rdsDbInstance.getEngineVersion(); // if(strEngVer.startsWith("11")) // else strDBMStype = "MSSQL_8_LE"; strDBMStype = DBDefine.MSSQL_DEFAULT.getDBToString(); } else if (strDBMStype.startsWith("oracle")) { strDBMStype = DBDefine.ORACLE_DEFAULT.getDBToString(); } rdsUserDB.setDbms_types(DBDefine.getDBDefine(strDBMStype).getDBToString()); rdsUserDB.setDisplay_name( rdsDbInstance.getDBInstanceIdentifier() + "." + rdsDbInstance.getAvailabilityZone()); rdsUserDB.setOperation_type(DBOperationType.DEVELOP.toString()); rdsUserDB.setDb(rdsDbInstance.getDBInstanceIdentifier());//getDBName()); rdsUserDB.setHost(rdsDbInstance.getEndpoint().getAddress()); rdsUserDB.setPort("" + rdsDbInstance.getEndpoint().getPort()); rdsUserDB.setLocale( rdsDbInstance.getCharacterSetName() == null ? "" : rdsDbInstance.getCharacterSetName()); rdsUserDB.setUsers(rdsDbInstance.getMasterUsername()); rdsUserDB.setPasswd(""); returnDBList.add(rdsUserDB); } } catch (Exception e) { throw e; } return returnDBList; }
From source file:com.jaspersoft.jasperserver.war.amazon.client.AwsDataSourceServiceImpl.java
License:Open Source License
protected List<DBInstance> getRdsInstances(AmazonRDSClient rdsClient) { return rdsClient.describeDBInstances().getDBInstances(); }
From source file:com.optimalbi.AmazonAccount.java
License:Apache License
private void populateRDS() throws AmazonClientException { for (Region region : getRegions()) { try {//from w ww.j a v a 2 s . c o m if (region.isServiceSupported(ServiceAbbreviations.RDS)) { AmazonRDSClient rds = new AmazonRDSClient(getCredentials().getCredentials()); rds.setRegion(region); DescribeDBInstancesResult result = rds.describeDBInstances(); List<DBInstance> instances = result.getDBInstances(); getLogger().info("RDS, Adding " + instances.size() + " instances from " + region.getName()); for (DBInstance i : instances) { LocalRDSService temp; if (i.getDBName() != null) { temp = new LocalRDSService(i.getDBName(), getCredentials(), region, i, getLogger()); } else { temp = new LocalRDSService(i.getDBInstanceIdentifier(), getCredentials(), region, i, getLogger()); } if (servicePricings != null && servicePricings.size() > 0) { if (servicePricings.get(region).getRDSPricing() != null) { temp.attachPricing(servicePricings.get(region).getRDSPricing()); } } services.add(temp); } } else { getLogger().info("RDS, NOPE from " + region.getName()); } } catch (AmazonClientException e) { throw new AmazonClientException(region.getName() + " " + e.getMessage()); } completed.set(completed.get() + 1); } }
From source file:com.optimalbi.Controller.AmazonAccount.java
License:Apache License
private void populateRDS() throws AmazonClientException { for (Region region : getRegions()) { try {// ww w . jav a2s . c o m if (region.isServiceSupported(ServiceAbbreviations.RDS)) { // services.addAll(RDSService.populateServices(region, getCredentials(), getLogger())); AmazonRDSClient rds = new AmazonRDSClient(getCredentials().getCredentials()); rds.setRegion(region); DescribeDBInstancesResult result = rds.describeDBInstances(); List<DBInstance> instances = result.getDBInstances(); getLogger().info("RDS, Adding " + instances.size() + " instances from " + region.getName()); services.addAll( instances .stream().map(i -> new LocalRDSService(i.getDBInstanceIdentifier(), getCredentials(), region, i, getLogger())) .collect(Collectors.toList())); } else { getLogger().info("RDS, NOPE from " + region.getName()); } } catch (AmazonClientException e) { throw new AmazonClientException(region.getName() + " " + e.getMessage()); } completed.set(completed.get() + 1); } }
From source file:com.optimalbi.Services.LocalRDSService.java
License:Apache License
public void refreshInstance() { AmazonRDSClient rds = new AmazonRDSClient(getCredentials().getCredentials()); rds.setRegion(region);/*from w w w . jav a 2s . co m*/ DescribeDBInstancesResult result = rds.describeDBInstances(); List<DBInstance> instances = result.getDBInstances(); DBInstance tempInstance = null; for (DBInstance d : instances) { if (d.getDBInstanceIdentifier().equalsIgnoreCase(thisService.getDBInstanceIdentifier())) { tempInstance = d; } } if (tempInstance != null) { thisService = tempInstance; } else { getLogger().error("Failed to refresh " + this.serviceName()); } }
From source file:io.macgyver.plugin.cloud.aws.scanner.RDSInstanceScanner.java
License:Apache License
private void forEachInstance(Region region, Consumer<DBInstance> consumer) { AmazonRDSClient client = new AmazonRDSClient(getAWSServiceClient().getCredentialsProvider()) .withRegion(region);/*from w w w. j a v a2s. c om*/ DescribeDBInstancesResult result = client.describeDBInstances(); String marker = result.getMarker(); result.getDBInstances().forEach(consumer); while (!Strings.isNullOrEmpty(marker) && !marker.equals("null")) { result = client.describeDBInstances().withMarker(marker); marker = result.getMarker(); result.getDBInstances().forEach(consumer); } }
From source file:rollsPOC2.util.AWSHelper.java
public static DBInstance findRDSInstance(String instanceName) { AmazonRDSClient rds = AppServices.getRDSClient(); DescribeDBInstancesResult result = rds.describeDBInstances(); for (DBInstance instance : result.getDBInstances()) { if (instance.getDBName().equals(instanceName)) { return instance; }/*ww w .jav a 2 s . com*/ } return null; }