Skip to content

Commit

Permalink
Merge pull request #652 from zmarois/3.11isolate-instance-metadata
Browse files Browse the repository at this point in the history
Isolating instance metadata calls
  • Loading branch information
arunagrawal-84 authored Feb 26, 2018
2 parents e3588a0 + ea804b2 commit 28715a6
Showing 1 changed file with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ public class PriamConfiguration implements IConfiguration {
private static final String CONFIG_REGION_NAME = PRIAM_PRE + ".az.region";
private static final String SDB_INSTANCE_INDENTITY_REGION_NAME = PRIAM_PRE + ".sdb.instanceIdentity.region";
private static final String CONFIG_ACL_GROUP_NAME = PRIAM_PRE + ".acl.groupname";
private final String LOCAL_IP = SystemUtils.getDataFromUrl("http://169.254.169.254/latest/meta-data/local-ipv4").trim();
private static String ASG_NAME = System.getenv("ASG_NAME");
private static String REGION = System.getenv("EC2_REGION");
private static final String CONFIG_VPC_RING = PRIAM_PRE + ".vpc";
Expand All @@ -186,7 +185,6 @@ public class PriamConfiguration implements IConfiguration {

//Running instance meta data
private String RAC;
private String PUBLIC_IP;

//== vpc specific
private String NETWORK_VPC; //Fetch the vpc id of running instance
Expand Down Expand Up @@ -257,14 +255,6 @@ public class PriamConfiguration implements IConfiguration {

@Inject
public PriamConfiguration(ICredential provider, IConfigSource config, InstanceEnvIdentity insEnvIdentity) {
// public interface meta-data does not exist when Priam runs in AWS VPC (priam.vpc=true)
String p_ip = "";
try {
p_ip = SystemUtils.getDataFromUrl("http://169.254.169.254/latest/meta-data/public-ipv4").trim();
} catch (RuntimeException ex) {
// swallow
}
this.PUBLIC_IP = p_ip;
this.provider = provider;
this.config = config;
this.insEnvIdentity = insEnvIdentity;
Expand All @@ -286,7 +276,6 @@ public void intialize() {
}

RAC = instanceDataRetriever.getRac();
PUBLIC_IP = instanceDataRetriever.getPublicIP();

NETWORK_VPC = instanceDataRetriever.getVpcId();

Expand Down Expand Up @@ -534,7 +523,7 @@ public List<String> getRacs() {

@Override
public String getHostname() {
if (this.isVpcRing()) return LOCAL_IP;
if (this.isVpcRing()) return getInstanceDataRetriever().getPrivateIP();
else return getInstanceDataRetriever().getPublicHostname();
}

Expand Down Expand Up @@ -697,8 +686,8 @@ public boolean isIncrBackup() {

@Override
public String getHostIP() {
if (this.isVpcRing()) return LOCAL_IP;
else return PUBLIC_IP;
if (this.isVpcRing()) return getInstanceDataRetriever().getPrivateIP();
else return getInstanceDataRetriever().getPublicIP();
}

@Override
Expand Down

0 comments on commit 28715a6

Please sign in to comment.