Issue 640:add login port to byon format

This commit is contained in:
Adrian Cole 2011-07-27 02:33:43 -07:00
parent 5243790801
commit 9c67e6b63c
5 changed files with 28 additions and 9 deletions

View File

@ -72,6 +72,7 @@ Here are the properties:
ex. rhel, ubuntu, centos, debian, amzn-linux ex. rhel, ubuntu, centos, debian, amzn-linux
* os_description - long description of the os ex. Ubuntu with lamp stack * os_description - long description of the os ex. Ubuntu with lamp stack
* os_version - normalized to numbers when possible. ex. for centos: 5.3, ubuntu: 10.10 * os_version - normalized to numbers when possible. ex. for centos: 5.3, ubuntu: 10.10
* login_port - optional; alternate port for ssh access
* group - primary group of the machine. ex. hadoop * group - primary group of the machine. ex. hadoop
* tags - optional; list of arbitrary tags. * tags - optional; list of arbitrary tags.
* note this list is not yet in jclouds NodeMetadata * note this list is not yet in jclouds NodeMetadata

View File

@ -45,6 +45,7 @@ public class Node {
private String osDescription; private String osDescription;
private String osVersion; private String osVersion;
private boolean os64Bit; private boolean os64Bit;
private int loginPort = 22;
private String group; private String group;
private Set<String> tags = ImmutableSet.of(); private Set<String> tags = ImmutableSet.of();
private String username; private String username;
@ -72,6 +73,11 @@ public class Node {
return this; return this;
} }
public Builder loginPort(int loginPort) {
this.loginPort = loginPort;
return this;
}
public Builder locationId(String locationId) { public Builder locationId(String locationId) {
this.locationId = locationId; this.locationId = locationId;
return this; return this;
@ -134,12 +140,12 @@ public class Node {
public Node build() { public Node build() {
return new Node(id, name, description, hostname, locationId, osArch, osFamily, osDescription, osVersion, return new Node(id, name, description, hostname, locationId, osArch, osFamily, osDescription, osVersion,
os64Bit, group, tags, username, credential, credentialUrl, sudoPassword); os64Bit, loginPort, group, tags, username, credential, credentialUrl, sudoPassword);
} }
} }
public Node(String id, String name, String description, String hostname, String locationId, String osArch, public Node(String id, String name, String description, String hostname, String locationId, String osArch,
String osFamily, String osDescription, String osVersion, boolean os64Bit, String group, String osFamily, String osDescription, String osVersion, boolean os64Bit, int loginPort, String group,
Iterable<String> tags, String username, String credential, URI credentialUrl, String sudoPassword) { Iterable<String> tags, String username, String credential, URI credentialUrl, String sudoPassword) {
this.id = id; this.id = id;
this.name = name; this.name = name;
@ -151,6 +157,7 @@ public class Node {
this.osDescription = osDescription; this.osDescription = osDescription;
this.osVersion = osVersion; this.osVersion = osVersion;
this.os64Bit = os64Bit; this.os64Bit = os64Bit;
this.loginPort = loginPort;
this.group = group; this.group = group;
this.tags = ImmutableSet.copyOf(tags); this.tags = ImmutableSet.copyOf(tags);
this.username = username; this.username = username;
@ -168,6 +175,7 @@ public class Node {
private final String osFamily; private final String osFamily;
private final String osDescription; private final String osDescription;
private final String osVersion; private final String osVersion;
private final int loginPort;
private final boolean os64Bit; private final boolean os64Bit;
private final String group; private final String group;
private final Set<String> tags; private final Set<String> tags;
@ -220,6 +228,10 @@ public class Node {
return os64Bit; return os64Bit;
} }
public int getLoginPort() {
return loginPort;
}
public Set<String> getTags() { public Set<String> getTags() {
Set<String> tagSet = new HashSet<String>(); Set<String> tagSet = new HashSet<String>();
for (String tag : tags) for (String tag : tags)
@ -260,7 +272,7 @@ public class Node {
return Objects.toStringHelper(this).add("id", id).add("name", name).add("description", description).add( return Objects.toStringHelper(this).add("id", id).add("name", name).add("description", description).add(
"locationId", locationId).add("hostname", hostname).add("osArch", osArch).add("osFamily", osFamily).add( "locationId", locationId).add("hostname", hostname).add("osArch", osArch).add("osFamily", osFamily).add(
"osDescription", osDescription).add("osVersion", osVersion).add("os64Bit", os64Bit).add("group", group) "osDescription", osDescription).add("osVersion", osVersion).add("os64Bit", os64Bit).add("group", group)
.add("tags", tags).add("username", username).add("hasCredential", .add("loginPort", loginPort).add("tags", tags).add("username", username).add("hasCredential",
credential != null || credentialUrl != null).add("hasSudoPassword", sudoPassword != null) credential != null || credentialUrl != null).add("hasSudoPassword", sudoPassword != null)
.toString(); .toString();
} }

View File

@ -32,8 +32,8 @@ import org.yaml.snakeyaml.constructor.Constructor;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Lists;
import com.google.common.io.Closeables; import com.google.common.io.Closeables;
/** /**
@ -50,6 +50,7 @@ import com.google.common.io.Closeables;
* os_description: redhat * os_description: redhat
* os_version: 5.3 * os_version: 5.3
* os_64bit: 5.3 * os_64bit: 5.3
* login_port: 2022
* group: hadoop * group: hadoop
* tags: * tags:
* - vanilla * - vanilla
@ -73,6 +74,7 @@ public class YamlNode {
public String os_family; public String os_family;
public String os_description; public String os_description;
public String os_version; public String os_version;
public int login_port = 22;
public boolean os_64bit; public boolean os_64bit;
public String group; public String group;
public List<String> tags = Lists.newArrayList(); public List<String> tags = Lists.newArrayList();
@ -89,7 +91,7 @@ public class YamlNode {
return Node.builder().id(arg0.id).name(arg0.name).description(arg0.description).locationId(arg0.location_id) return Node.builder().id(arg0.id).name(arg0.name).description(arg0.description).locationId(arg0.location_id)
.hostname(arg0.hostname).osArch(arg0.os_arch).osFamily(arg0.os_family).osDescription( .hostname(arg0.hostname).osArch(arg0.os_arch).osFamily(arg0.os_family).osDescription(
arg0.os_description).osVersion(arg0.os_version).os64Bit(arg0.os_64bit).group(arg0.group) arg0.os_description).osVersion(arg0.os_version).os64Bit(arg0.os_64bit).group(arg0.group)
.tags(arg0.tags).username(arg0.username).credential(arg0.credential).credentialUrl( .loginPort(arg0.login_port).tags(arg0.tags).username(arg0.username).credential(arg0.credential).credentialUrl(
arg0.credential_url != null ? URI.create(arg0.credential_url) : null).sudoPassword( arg0.credential_url != null ? URI.create(arg0.credential_url) : null).sudoPassword(
arg0.sudo_password).build(); arg0.sudo_password).build();
} }
@ -144,6 +146,8 @@ public class YamlNode {
prettier.put("os_version", in.os_version); prettier.put("os_version", in.os_version);
if (in.os_64bit) if (in.os_64bit)
prettier.put("os_64bit", in.os_64bit); prettier.put("os_64bit", in.os_64bit);
if (in.login_port != 22)
prettier.put("login_port", in.login_port);
if (in.group != null) if (in.group != null)
prettier.put("group", in.group); prettier.put("group", in.group);
if (in.tags.size() != 0) if (in.tags.size() != 0)
@ -186,6 +190,7 @@ public class YamlNode {
yaml.os_description = arg0.getOsDescription(); yaml.os_description = arg0.getOsDescription();
yaml.os_version = arg0.getOsVersion(); yaml.os_version = arg0.getOsVersion();
yaml.os_64bit = arg0.isOs64Bit(); yaml.os_64bit = arg0.isOs64Bit();
yaml.login_port = arg0.getLoginPort();
yaml.group = arg0.getGroup(); yaml.group = arg0.getGroup();
yaml.tags = ImmutableList.copyOf(arg0.getTags()); yaml.tags = ImmutableList.copyOf(arg0.getTags());
yaml.username = arg0.getUsername(); yaml.username = arg0.getUsername();

View File

@ -41,15 +41,15 @@ public class NodesFromYamlTest {
.toString(); .toString();
public static final Node TEST1 = new Node("cluster-1", "cluster-1", "accounting analytics cluster", public static final Node TEST1 = new Node("cluster-1", "cluster-1", "accounting analytics cluster",
"cluster-1.mydomain.com", null, "x86", "rhel", "redhat", "5.3", false, "hadoop", ImmutableList.of("vanilla"), "cluster-1.mydomain.com", null, "x86", "rhel", "redhat", "5.3", false, 22, "hadoop", ImmutableList.of("vanilla"),
"myUser", key, null, "happy bear"); "myUser", key, null, "happy bear");
public static final Node TEST2 = new Node("cluster-1", "cluster-1", "accounting analytics cluster", public static final Node TEST2 = new Node("cluster-1", "cluster-1", "accounting analytics cluster",
"cluster-1.mydomain.com", "virginia", "x86", "rhel", "redhat", "5.3", false, "hadoop", "cluster-1.mydomain.com", "virginia", "x86", "rhel", "redhat", "5.3", false, 22, "hadoop",
ImmutableList.of("vanilla"), "myUser", key, null, "happy bear"); ImmutableList.of("vanilla"), "myUser", key, null, "happy bear");
public static final Node TEST3 = new Node("cluster-2", "cluster-2", "accounting analytics cluster", public static final Node TEST3 = new Node("cluster-2", "cluster-2", "accounting analytics cluster",
"cluster-2.mydomain.com", "maryland", "x86", "rhel", "redhat", "5.3", false, "hadoop", "cluster-2.mydomain.com", "maryland", "x86", "rhel", "redhat", "5.3", false, 2022, "hadoop",
ImmutableList.of("vanilla"), "myUser", key, null, "happy bear"); ImmutableList.of("vanilla"), "myUser", key, null, "happy bear");
@Test @Test

View File

@ -29,6 +29,7 @@ nodes:
os_family: rhel os_family: rhel
os_description: redhat os_description: redhat
os_version: 5.3 os_version: 5.3
login_port: 2022
group: hadoop group: hadoop
tags: tags:
- vanilla - vanilla