Permalink
Browse files

Allow instance type network selection for both networks

The feature added to select different networks for each instance type
was only allowing one network.  Make it possible to configure both the
public and the private network.
  • Loading branch information...
1 parent db0f833 commit 02e22b24a77665fb2eab634322ed84dc4b41f9dd @priteau priteau committed Aug 30, 2012
View
18 messaging/gt4.0-elastic/java/msgbridge/etc/elastic/elastic.conf
@@ -19,21 +19,29 @@ cpus.large=2
cpus.xlarge=4
cpus.custom=1
-network.small=
-network.large=
-network.xlarge=
-network.custom=private
-
# There is a concept of "public" and "private" networks built into the elastic
# interface. You need to map these to the real networks to request from the
# underlying resource manager (workspace service).
#
# They can be the same value which will trigger one real NIC request. If they
# are different network names, two real NIC requests will be made.
+# The following two settings are the default for all instances
+
net.public=public
net.private=private
+# The following settings allow to override default setting per instance
+# The defaults are used if left blank
+
+network.public.small=
+network.private.small=
+network.public.large=
+network.private.large=
+network.public.xlarge=
+network.private.xlarge=
+network.public.custom=private
+network.private.custom=private
# The default VMM to request from the underlying manager is x86+Xen3, see the
# "elastic/other/other-elastic.conf" to change this.
View
12 messaging/gt4.0-elastic/java/msgbridge/etc/elastic/other/main.xml
@@ -142,10 +142,14 @@
<constructor-arg ref="nimbus-elastic.rm.modulelocator" />
- <property name="smallNetwork" value="$ELASTIC{network.small}" />
- <property name="largeNetwork" value="$ELASTIC{network.large}" />
- <property name="xlargeNetwork" value="$ELASTIC{network.xlarge}" />
- <property name="customNetwork" value="$ELASTIC{network.custom}" />
+ <property name="smallPublicNetwork" value="$ELASTIC{network.public.small}" />
+ <property name="smallPrivateNetwork" value="$ELASTIC{network.private.small}" />
+ <property name="largePublicNetwork" value="$ELASTIC{network.public.large}" />
+ <property name="largePrivateNetwork" value="$ELASTIC{network.private.large}" />
+ <property name="xlargePublicNetwork" value="$ELASTIC{network.public.xlarge}" />
+ <property name="xlargePrivateNetwork" value="$ELASTIC{network.private.xlarge}" />
+ <property name="customPublicNetwork" value="$ELASTIC{network.public.custom}" />
+ <property name="customPrivateNetwork" value="$ELASTIC{network.private.custom}" />
<property name="smallMemory" value="$ELASTIC{memory.small}" />
<property name="largeMemory" value="$ELASTIC{memory.large}" />
View
129 ...ools/messaging/gt4_0_elastic/v2008_05_05/general/defaults/DefaultResourceAllocations.java
@@ -62,10 +62,14 @@
protected String xlargeName;
protected String customName;
- protected String smallNetwork = null;
- protected String largeNetwork = null;
- protected String xlargeNetwork = null;
- protected String customNetwork = null;
+ protected String smallPublicNetwork = null;
+ protected String smallPrivateNetwork = null;
+ protected String largePublicNetwork = null;
+ protected String largePrivateNetwork = null;
+ protected String xlargePublicNetwork = null;
+ protected String xlargePrivateNetwork = null;
+ protected String customPublicNetwork = null;
+ protected String customPrivateNetwork = null;
protected String unknownString;
@@ -165,20 +169,36 @@ void validate() throws Exception {
// -------------------------------------------------------------------------
// SET
// -------------------------------------------------------------------------
- public void setSmallNetwork(String smallNetwork) {
- this.smallNetwork = smallNetwork;
+ public void setSmallPublicNetwork(String smallPublicNetwork) {
+ this.smallPublicNetwork = smallPublicNetwork;
}
- public void setCustomNetwork(String customNetwork) {
- this.customNetwork = customNetwork;
+ public void setSmallPrivateNetwork(String smallPrivateNetwork) {
+ this.smallPrivateNetwork = smallPrivateNetwork;
}
- public void setLargeNetwork(String largeNetwork) {
- this.largeNetwork = largeNetwork;
+ public void setCustomPublicNetwork(String customPublicNetwork) {
+ this.customPublicNetwork = customPublicNetwork;
}
- public void setXlargeNetwork(String xlargeNetwork) {
- this.xlargeNetwork = xlargeNetwork;
+ public void setCustomPrivateNetwork(String customPrivateNetwork) {
+ this.customPrivateNetwork = customPrivateNetwork;
+ }
+
+ public void setLargePublicNetwork(String largePublicNetwork) {
+ this.largePublicNetwork = largePublicNetwork;
+ }
+
+ public void setLargePrivateNetwork(String largePrivateNetwork) {
+ this.largePrivateNetwork = largePrivateNetwork;
+ }
+
+ public void setXlargePublicNetwork(String xlargePublicNetwork) {
+ this.xlargePublicNetwork = xlargePublicNetwork;
+ }
+
+ public void setXlargePrivateNetwork(String xlargePrivateNetwork) {
+ this.xlargePrivateNetwork = xlargePrivateNetwork;
}
public void setCustomMemory(int customMemory) {
@@ -263,20 +283,36 @@ public void setSiType(String siType) throws Exception {
// -------------------------------------------------------------------------
// implements ResourceAllocations
// -------------------------------------------------------------------------
- public String getSmallNetwork() {
- return this.smallNetwork;
+ public String getSmallPublicNetwork() {
+ return this.smallPublicNetwork;
+ }
+
+ public String getSmallPrivateNetwork() {
+ return this.smallPrivateNetwork;
+ }
+
+ public String getCustomPublicNetwork() {
+ return this.customPublicNetwork;
+ }
+
+ public String getCustomPrivateNetwork() {
+ return this.customPrivateNetwork;
}
- public String getCustomNetwork() {
- return this.customNetwork;
+ public String getLargePublicNetwork() {
+ return this.largePublicNetwork;
}
- public String getLargeNetwork() {
- return this.largeNetwork;
+ public String getLargePrivateNetwork() {
+ return this.largePrivateNetwork;
}
- public String getXlargeNetwork() {
- return this.xlargeNetwork;
+ public String getXlargePublicNetwork() {
+ return this.xlargePublicNetwork;
+ }
+
+ public String getXlargePrivateNetwork() {
+ return this.xlargePrivateNetwork;
}
public String getSpotInstanceType(){
@@ -311,14 +347,14 @@ public String getVmmVersion() {
return this.vmmVersion;
}
- protected String getMatchingName(int memory, int cpus, String network) {
- if (this.smallMemory == memory && this.smallCPUs == cpus && this.smallNetwork.equals(network)) {
+ protected String getMatchingName(int memory, int cpus, String publicNetwork, String privateNetwork) {
+ if (this.smallMemory == memory && this.smallCPUs == cpus && this.smallPublicNetwork.equals(publicNetwork) && this.smallPrivateNetwork.equals(privateNetwork)) {
return this.getSmallName();
- } else if (this.largeMemory == memory && this.largeCPUs == cpus && this.largeNetwork.equals(network)) {
+ } else if (this.largeMemory == memory && this.largeCPUs == cpus && this.largePublicNetwork.equals(publicNetwork) && this.largePrivateNetwork.equals(privateNetwork)) {
return this.getLargeName();
- } else if (this.xlargeMemory == memory && this.xlargeCPUs == cpus && this.xlargeNetwork.equals(network)) {
+ } else if (this.xlargeMemory == memory && this.xlargeCPUs == cpus && this.xlargePublicNetwork.equals(publicNetwork) && this.xlargePrivateNetwork.equals(privateNetwork)) {
return this.getXlargeName();
- } else if (this.customMemory == memory && this.customCPUs == cpus && this.customNetwork.equals(network)) {
+ } else if (this.customMemory == memory && this.customCPUs == cpus && this.customPublicNetwork.equals(publicNetwork) && this.customPrivateNetwork.equals(privateNetwork)) {
return this.getCustomName();
} else {
return this.unknownString;
@@ -333,12 +369,16 @@ public String getMatchingName(ResourceAllocation ra)
}
// Undefined networks in elastic.conf are declared with empty strings
- String network = ra.getNetwork();
- if (network == null) {
- network = "";
+ String publicNetwork = ra.getPublicNetwork();
+ if (publicNetwork == null) {
+ publicNetwork = "";
+ }
+ String privateNetwork = ra.getPrivateNetwork();
+ if (privateNetwork == null) {
+ privateNetwork = "";
}
- return this.getMatchingName(ra.getMemory(), ra.getIndCpuCount(), network);
+ return this.getMatchingName(ra.getMemory(), ra.getIndCpuCount(), publicNetwork, privateNetwork);
}
public ResourceAllocation getMatchingRA(String name,
@@ -370,15 +410,17 @@ public ResourceAllocation getMatchingRA(String name,
Integer cpus = getInstanceCPUs(cmpName);
- String network = getInstanceNetwork(cmpName);
+ String publicNetwork = getInstancePublicNetwork(cmpName);
+ String privateNetwork = getInstancePrivateNetwork(cmpName);
ra.setIndCpuCount(cpus);
ra.setSpotInstance(spot);
ra.setArchitecture(this.cpuArch);
- ra.setNetwork(network);
+ ra.setPublicNetwork(publicNetwork);
+ ra.setPrivateNetwork(privateNetwork);
return ra;
}
@@ -415,22 +457,37 @@ protected Integer getInstanceCPUs(final String cmpName)
}
}
- protected String getInstanceNetwork(final String cmpName)
+ protected String getInstancePublicNetwork(final String cmpName)
throws CannotTranslateException {
if (cmpName.equals(this.getSmallName())) {
- return this.smallNetwork;
+ return this.smallPublicNetwork;
} else if (cmpName.equals(this.getLargeName())) {
- return this.largeNetwork;
+ return this.largePublicNetwork;
} else if (cmpName.equals(this.getXlargeName())) {
- return this.xlargeNetwork;
+ return this.xlargePublicNetwork;
} else if (cmpName.equals(this.getCustomName())) {
- return this.customNetwork;
+ return this.customPublicNetwork;
} else {
throw new CannotTranslateException(
"Unknown instance type '" + cmpName + "'");
}
}
+ protected String getInstancePrivateNetwork(final String cmpName)
+ throws CannotTranslateException {
+ if (cmpName.equals(this.getSmallName())) {
+ return this.smallPrivateNetwork;
+ } else if (cmpName.equals(this.getLargeName())) {
+ return this.largePrivateNetwork;
+ } else if (cmpName.equals(this.getXlargeName())) {
+ return this.xlargePrivateNetwork;
+ } else if (cmpName.equals(this.getCustomName())) {
+ return this.customPrivateNetwork;
+ } else {
+ throw new CannotTranslateException(
+ "Unknown instance type '" + cmpName + "'");
+ }
+ }
public RequiredVMM getRequiredVMM() {
return this.requestThisVMM;
View
2 ...src/org/nimbustools/messaging/gt4_0_elastic/v2008_05_05/rm/defaults/DefaultRequestSI.java
@@ -199,7 +199,7 @@ public SpotCreateRequest translateReqSpotInstances(
req.getInstanceCount().intValue(),
req.getInstanceCount().intValue(),
true);
- final NIC[] nics = this.getNICs(ra.getNetwork());
+ final NIC[] nics = this.getNICs(ra.getPublicNetwork(), ra.getPrivateNetwork());
final RequiredVMM reqVMM = this.RAs.getRequiredVMM();
View
44 ...ridge/src/org/nimbustools/messaging/gt4_0_elastic/v2008_05_05/rm/defaults/DefaultRun.java
@@ -188,7 +188,7 @@ public CreateRequest translateRunInstances(RunInstancesType req,
req.getMinCount(),
req.getMaxCount(),
false);
- final NIC[] nics = this.getNICs(ra.getNetwork());
+ final NIC[] nics = this.getNICs(ra.getPublicNetwork(), ra.getPrivateNetwork());
final RequiredVMM reqVMM = this.RAs.getRequiredVMM();
String userData = null;
@@ -351,7 +351,7 @@ public RunInstancesResponseType translateCreateResult(CreateResult result,
// NETWORK REQUEST
// -------------------------------------------------------------------------
- protected NIC[] getNICs(String networkName) throws CannotTranslateException {
+ protected NIC[] getNICs(String publicNetworkName, String privateNetworkName) throws CannotTranslateException {
// if the network mappings are the same value, that currently means
// only make one real NIC request
@@ -365,11 +365,35 @@ public RunInstancesResponseType translateCreateResult(CreateResult result,
}
final NIC[] nics;
- if (networkName != null && !networkName.trim().equals("")) {
- nics = new NIC[1];
- networkName = networkName.trim();
- logger.info("Using network name " + networkName);
- nics[0] = this.oneRequestedNIC(networkName, "autoeth0");
+
+ /* Check that when one of public and private is set, they are both set */
+ if (publicNetworkName != null && !publicNetworkName.trim().equals("")) {
+ if (privateNetworkName == null || privateNetworkName.trim().equals("")) {
+ throw new CannotTranslateException("Illegal Networks " +
+ "implementation, public network set but null private network mapping");
+ }
+ }
+ if (privateNetworkName != null && !privateNetworkName.trim().equals("")) {
+ if (publicNetworkName == null || publicNetworkName.trim().equals("")) {
+ throw new CannotTranslateException("Illegal Networks " +
+ "implementation, private network set but null public network mapping");
+ }
+ }
+
+ if (publicNetworkName != null && !publicNetworkName.trim().equals("")) {
+ if (publicNetworkName.trim().equals(privateNetworkName.trim())) {
+ nics = new NIC[1];
+ publicNetworkName = publicNetworkName.trim();
+ logger.info("Using network name " + publicNetworkName);
+ nics[0] = this.oneRequestedNIC(publicNetworkName, "autoeth0");
+ } else {
+ nics = new NIC[2];
+ publicNetworkName = publicNetworkName.trim();
+ privateNetworkName = privateNetworkName.trim();
+ logger.info("Using public network name " + publicNetworkName + " and private network name " + privateNetworkName);
+ nics[0] = this.oneRequestedNIC(publicNetworkName, "autoeth0");
+ nics[1] = this.oneRequestedNIC(privateNetworkName, "autoeth1");
+ }
}
else if (pubNet.equals(privNet)) {
nics = new NIC[1];
@@ -541,7 +565,11 @@ protected void handleNetworking(VM vm,
String privateAssignedIp = null;
String publicAssignedIp = null;
- logger.info("Using network " + netName);
+ if (netName2 != null) {
+ logger.info("Using networks " + netName + " and " + netName2);
+ } else {
+ logger.info("Using network " + netName);
+ }
if (this.networks.isPrivateNetwork(netName)) {
riit.setPrivateDnsName(hostname);
riit.setPrivateIpAddress(ipAddress);
View
12 messaging/query/java/source/etc/query/other/main.xml
@@ -223,10 +223,14 @@ http://cxf.apache.org/schemas/jaxrs.xsd">
<constructor-arg ref="nimbus-query.rm.modulelocator" />
- <property name="smallNetwork" value="$ELASTIC{network.small}" />
- <property name="largeNetwork" value="$ELASTIC{network.large}" />
- <property name="xlargeNetwork" value="$ELASTIC{network.xlarge}" />
- <property name="customNetwork" value="$ELASTIC{network.custom}" />
+ <property name="smallPublicNetwork" value="$ELASTIC{network.public.small}" />
+ <property name="smallPrivateNetwork" value="$ELASTIC{network.private.small}" />
+ <property name="largePublicNetwork" value="$ELASTIC{network.public.large}" />
+ <property name="largePrivateNetwork" value="$ELASTIC{network.private.large}" />
+ <property name="xlargePublicNetwork" value="$ELASTIC{network.public.xlarge}" />
+ <property name="xlargePrivateNetwork" value="$ELASTIC{network.private.xlarge}" />
+ <property name="customPublicNetwork" value="$ELASTIC{network.public.custom}" />
+ <property name="customPrivateNetwork" value="$ELASTIC{network.private.custom}" />
<property name="smallMemory" value="$ELASTIC{memory.small}" />
<property name="largeMemory" value="$ELASTIC{memory.large}" />
View
3 service-api/java/source/src/org/nimbustools/api/_repr/vm/_ResourceAllocation.java
@@ -27,5 +27,6 @@
public void setMemory(int memory);
public void setNodeNumber(int nodeNumber);
public void setSpotInstance(boolean spot);
- public void setNetwork(String network);
+ public void setPublicNetwork(String network);
+ public void setPrivateNetwork(String network);
}
View
18 ...e-api/java/source/src/org/nimbustools/api/defaults/repr/vm/DefaultResourceAllocation.java
@@ -31,7 +31,8 @@
private int memory;
private int nodeNumber;
private boolean spotInstance;
- private String network;
+ private String publicNetwork;
+ private String privateNetwork;
// -------------------------------------------------------------------------
// implements org.nimbustools.api.repr.vm.ResourceAllocation
@@ -49,10 +50,13 @@ public int getIndCpuCount() {
return this.indCpuCount;
}
- public String getNetwork() {
- return this.network;
+ public String getPublicNetwork() {
+ return this.publicNetwork;
}
+ public String getPrivateNetwork() {
+ return this.privateNetwork;
+ }
public int getCpuPercentage() {
return this.cpuPercentage;
@@ -94,8 +98,12 @@ public void setMemory(int memory) {
this.memory = memory;
}
- public void setNetwork(String network) {
- this.network = network;
+ public void setPublicNetwork(String publicNetwork) {
+ this.publicNetwork = publicNetwork;
+ }
+
+ public void setPrivateNetwork(String privateNetwork) {
+ this.privateNetwork = privateNetwork;
}
public void setNodeNumber(int nodeNumber) {
View
3 service-api/java/source/src/org/nimbustools/api/repr/vm/ResourceAllocation.java
@@ -36,5 +36,6 @@
public int getMemory();
public int getNodeNumber();
public boolean isSpotInstance();
- public String getNetwork();
+ public String getPublicNetwork();
+ public String getPrivateNetwork();
}

0 comments on commit 02e22b2

Please sign in to comment.