Java 类com.amazonaws.services.rds.model.ModifyDBInstanceRequest 实例源码

项目:bluegreen-manager    文件:RdsClient.java   
/**
 * Modifies the instance by applying new security groups and new parameter group.
 * <p/>
 * Caller must wait for status=available afterwards.
 */
public DBInstance modifyInstanceWithSecgrpParamgrp(String instanceName,
                                                   Collection<String> vpcSecurityGroupIds,
                                                   String paramGroupName)
{
  LOGGER.debug("modifyDBInstance(instanceName: " + instanceName + ", vpcSecurityGroupIds: ("
      + StringUtils.join(vpcSecurityGroupIds, ", ") + "), paramGroupName: " + paramGroupName + ")");
  StopWatch stopWatch = new StopWatch();
  try
  {
    stopWatch.start();
    ModifyDBInstanceRequest request = new ModifyDBInstanceRequest(instanceName);
    request.setVpcSecurityGroupIds(vpcSecurityGroupIds);
    request.setDBParameterGroupName(paramGroupName);
    return awsRdsClient.modifyDBInstance(request);
  }
  finally
  {
    stopWatch.stop();
    LOGGER.debug("modifyDBInstance time elapsed: " + stopWatch);
  }
}
项目:cloudml    文件:BeanstalkConnector.java   
/**
 * Not used yet!
 *
 * @param dbInstanceIdentifier
 * @param group
 * @param owner
 */
public void setSecuretGroup(String dbInstanceIdentifier, String group, String owner) {

    String groupName = dbInstanceIdentifier + "-security-group";
    CreateDBSecurityGroupRequest csg = new CreateDBSecurityGroupRequest();
    csg.setDBSecurityGroupName(groupName);
    csg.setDBSecurityGroupDescription(groupName);
    rdsClient.createDBSecurityGroup(csg);

    RevokeDBSecurityGroupIngressRequest rsgi = new RevokeDBSecurityGroupIngressRequest();
    rsgi.setDBSecurityGroupName(groupName);
    rsgi.setEC2SecurityGroupId(group);
    rsgi.setEC2SecurityGroupOwnerId(owner);
    rsgi.setRequestCredentials(awsCredentials);
    //rsgi.set
    rdsClient.revokeDBSecurityGroupIngress(rsgi);

    ModifyDBInstanceRequest request = new ModifyDBInstanceRequest();
    Collection<String> groups = new ArrayList();
    groups.add(groupName);
    request.setDBSecurityGroups(groups);
    request.setDBInstanceIdentifier(dbInstanceIdentifier);
    rdsClient.modifyDBInstance(request);

}
项目:bluegreen-manager    文件:RdsClientTest.java   
/**
 * Tests that modifyInstanceWithSecgrpParamgrp returns its rds result object.
 */
@Test
public void testModifyInstanceWithSecgrpParamgrp()
{
  DBInstance mockInstance = mock(DBInstance.class);
  when(mockRdsClient.modifyDBInstance(any(ModifyDBInstanceRequest.class))).thenReturn(mockInstance);
  Collection<String> securityGroups = new ArrayList<String>();
  securityGroups.add(SECURITY_GROUP);

  assertEquals(mockInstance, rdsClient.modifyInstanceWithSecgrpParamgrp(INSTANCE_NAME, securityGroups, PARAM_GROUP));
}
项目:cloudml    文件:BeanstalkConnector.java   
public void openDBForIps(String dbInstanceIdentifier, Collection<String> ips, int timeout) {
    String groupName = dbInstanceIdentifier + "-security-group";
    for (String ip : ips) {
        AuthorizeDBSecurityGroupIngressRequest audbgi = new AuthorizeDBSecurityGroupIngressRequest()
                .withCIDRIP(ip + "/32")
                .withDBSecurityGroupName(groupName);
        audbgi.setRequestCredentials(awsCredentials);
        rdsClient.authorizeDBSecurityGroupIngress(audbgi);

    }
    rdsClient.authorizeDBSecurityGroupIngress(new AuthorizeDBSecurityGroupIngressRequest()
            .withCIDRIP("0.0.0.0/0")
            .withDBSecurityGroupName(groupName)
    );
    ModifyDBInstanceRequest request = new ModifyDBInstanceRequest();
    Collection<String> groups = new ArrayList();
    groups.add(groupName);
    request.setDBSecurityGroups(groups);
    request.setDBInstanceIdentifier(dbInstanceIdentifier);
    System.out.print("Modifying security group");
    while(timeout-->0){
        System.out.print("-");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
            Logger.getLogger(BeanstalkConnector.class.getName()).log(Level.SEVERE, null, ex);
        }

        try{
            rdsClient.modifyDBInstance(request);
            break;
        }catch(Exception e){
            continue;
        }


    }

}