Authored by jack

set region

... ... @@ -2,9 +2,11 @@ package com.monitor.awstools.job;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.*;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.*;
import com.amazonaws.services.ec2.model.Region;
import com.monitor.awstools.constant.Constants;
import com.monitor.awstools.constant.TaskType;
import org.apache.commons.lang.StringUtils;
... ... @@ -33,6 +35,10 @@ public class AwsJobImpl implements InterruptableJob {
AmazonEC2 amazonEC2 = new AmazonEC2Client(awsCredentials);
com.amazonaws.regions.Region region = com.amazonaws.regions.Region.getRegion(Regions.CN_NORTH_1);
amazonEC2.setRegion(region);
if (StringUtils.equals(aciton, TaskType.CREATESNAPSHOT.name())) {
String volumeId = (String) jobExecutionContext.getJobDetail().getJobDataMap().get(Constants.VOLUME);
... ...
... ... @@ -6,6 +6,8 @@ import com.monitor.awstools.model.M_Instance;
import com.monitor.awstools.model.M_SnapShot;
import com.monitor.awstools.model.M_Volume;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -18,7 +20,7 @@ import java.util.List;
*/
@Service
public class AwsQueryService {
public static final Logger DEBUG = LoggerFactory.getLogger(AwsQueryService.class);
@Autowired
AWSClientComp awsClientComp = new AWSClientComp();
... ... @@ -153,6 +155,8 @@ public class AwsQueryService {
DescribeSnapshotsResult result = awsClientComp.getClient().describeSnapshots(request);
DEBUG.info("Query snapshot result {}", result);
List<Snapshot> snapshotList = result.getSnapshots();
List<M_SnapShot> m_snapShotList = new ArrayList<>();
... ... @@ -165,10 +169,10 @@ public class AwsQueryService {
return m_snapShotList;
}
public static void main(String[] args) {
/* public static void main(String[] args) {
AwsQueryService queryService = new AwsQueryService();
/* M_Volume m_volume = queryService.queryVolumeInfo("vol-4c808589");
*//* M_Volume m_volume = queryService.queryVolumeInfo("vol-4c808589");
if (null == m_volume) {
return;
... ... @@ -177,7 +181,7 @@ public class AwsQueryService {
M_Instance m_instance = queryService.queryInstanceInfo(m_volume.getInstanceId());
System.out.println(m_volume);
System.out.println(m_instance);*/
System.out.println(m_instance);*//*
List<M_SnapShot> snapShotList = queryService.querySnapShotList("vol-4c808589");
... ... @@ -186,7 +190,7 @@ public class AwsQueryService {
}
}
}*/
private M_SnapShot convertSnapShot(Snapshot snapshot) {
... ...