modify code to parse yaml

This commit is contained in:
Kelvin Kakugawa 2011-01-25 13:19:45 -08:00
parent ceaddcc57f
commit 0c9a70ca84
3 changed files with 27 additions and 14 deletions

View File

@ -19,6 +19,8 @@
package org.jclouds.byon;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.google.common.base.Objects;
@ -29,16 +31,16 @@ import com.google.common.base.Objects;
* @author Adrian Cole
*/
public class Node {
private String id;
private String description;
private String hostname;
private String osArch;
private String osFamily;
private String osName;
private String osVersion;
private Set<String> tags;
private String username;
private String credential;
public String id;
public String description;
public String hostname;
public String osArch;
public String osFamily;
public String osName;
public String osVersion;
public List<String> tags;
public String username;
public String credential;
public String getId() {
return id;
@ -69,7 +71,10 @@ public class Node {
}
public Set<String> getTags() {
return tags;
Set<String> tagSet = new HashSet<String>();
for (String tag : tags)
tagSet.add(tag);
return tagSet;
}
public String getUsername() {

View File

@ -69,6 +69,10 @@ public class BYONComputeServiceContextModule extends
public Map<String, Node> get() {
Constructor constructor = new Constructor(Config.class);
TypeDescription nodeDesc = new TypeDescription(Node.class);
nodeDesc.putListPropertyType("tags", String.class);
constructor.addTypeDescription(nodeDesc);
TypeDescription configDesc = new TypeDescription(Config.class);
configDesc.putMapPropertyType("nodes", String.class, Node.class);
constructor.addTypeDescription(configDesc);

View File

@ -62,8 +62,12 @@ public class NodeToNodeMetadata implements Function<Node, NodeMetadata> {
builder.location(location.get());
builder.tag(Iterables.get(from.getTags(), 0));
builder
.operatingSystem(new OperatingSystemBuilder().arch(from.getOsArch())
.family(OsFamily.fromValue(from.getOsFamily())).name(from.getOsName()).version(from.getOsVersion())
.operatingSystem(new OperatingSystemBuilder()
.arch(from.getOsArch())
.family(OsFamily.fromValue(from.getOsFamily()))
.name(from.getOsName())
.version(from.getOsVersion())
.description(from.getDescription())
.build());
builder.state(NodeState.RUNNING);
builder.publicAddresses(ImmutableSet.<String> of(from.getHostname()));