Commit 317654ce authored by Leigh Stoller's avatar Leigh Stoller

Support for node attributes.

parent 56eb48f6
...@@ -835,6 +835,7 @@ sub new($$$$$) ...@@ -835,6 +835,7 @@ sub new($$$$$)
"services" => [], "services" => [],
"statements" => [], "statements" => [],
"desires" => {}, "desires" => {},
"attributes" => {},
"ifaces" => {}, "ifaces" => {},
"ifacelist" => [], "ifacelist" => [],
"blockstores" => {}, "blockstores" => {},
...@@ -858,6 +859,8 @@ sub blockstores($) { return $_[0]->{'blockstores'}; } ...@@ -858,6 +859,8 @@ sub blockstores($) { return $_[0]->{'blockstores'}; }
sub ifaces($) { return $_[0]->{'ifaces'}; } sub ifaces($) { return $_[0]->{'ifaces'}; }
sub ifacelist($) { return $_[0]->{'ifacelist'}; } sub ifacelist($) { return $_[0]->{'ifacelist'}; }
sub services($) { return $_[0]->{'services'}; } sub services($) { return $_[0]->{'services'}; }
sub desires($) { return $_[0]->{'services'}; }
sub attributes($) { return $_[0]->{'attributes'}; }
sub pipes($) { return $_[0]->{'pipes'}; } sub pipes($) { return $_[0]->{'pipes'}; }
sub firewall_style($) { return $_[0]->{'firewall_style'}; } sub firewall_style($) { return $_[0]->{'firewall_style'}; }
sub firewall_rules($) { return $_[0]->{'firewall_rules'}; } sub firewall_rules($) { return $_[0]->{'firewall_rules'}; }
...@@ -1220,6 +1223,12 @@ sub addNode($$$) ...@@ -1220,6 +1223,12 @@ sub addNode($$$)
$node->{"desires"}->{$desire} = $weight; $node->{"desires"}->{$desire} = $weight;
last SWITCH; last SWITCH;
}; };
/^node_attribute$/i && do {
my $key = GetTextOrFail("key", $child);
my $value = GetTextOrFail("value", $child);
$node->{"attributes"}->{$key} = $value;
last SWITCH;
};
/^moonshot_chassis$/i && do { /^moonshot_chassis$/i && do {
# Convert to a desire # Convert to a desire
my $chassis = GetTextOrFail("chassis", $child); my $chassis = GetTextOrFail("chassis", $child);
...@@ -1295,7 +1304,7 @@ sub Compare($$) ...@@ -1295,7 +1304,7 @@ sub Compare($$)
# Handled up above in CompareNodes. # Handled up above in CompareNodes.
last SWITCH; last SWITCH;
}; };
/^(xen_settings|desires|pipes|blockstores)$/i && do { /^(xen_settings|desires|pipes|blockstores|attributes)$/i && do {
return 1 return 1
if (APT_Rspec::CompareHashes("Node: $client_id: $key", if (APT_Rspec::CompareHashes("Node: $client_id: $key",
$val1, $val2)); $val1, $val2));
......
...@@ -774,11 +774,31 @@ for child in tree.getroot(): ...@@ -774,11 +774,31 @@ for child in tree.getroot():
vname = row.find("vname").text vname = row.find("vname").text
key = row.find("attrkey").text key = row.find("attrkey").text
val = row.find("attrvalue").text val = row.find("attrvalue").text
raw = etree.Element("{%s}node_attribute" % node = nodes[vname]
(RSpec.Namespaces.EMULAB.name))
raw.attrib["attrkey"] = key #
raw.attrib["attrvalue"] = val # Many node attributes, we have to translate some, the rest
nodes[vname].addRawElement(raw) # are passed through.
#
if key == "routable_control_ip":
if val.lower() == "true":
node.routable_control_ip = True
pass
elif ((key == "MEMORY_SIZE" or key == "XEN_MEMSIZE") and
node.type == "emulab-xen"):
node.ram = int(val) / 1024
elif ((key == "XEN_CORES" or key == "VM_CPUS") and
node.type == "emulab-xen"):
node.cores = int(val)
elif key == "XEN_EXTRAFS" and node.type == "emulab-xen":
node.disk = int(val)
else:
raw = etree.Element("{%s}node_attribute" %
(RSpec.Namespaces.EMULAB.name))
raw.attrib["key"] = key
raw.attrib["value"] = val
node.addRawElement(raw)
pass
pass pass
if child.tag == "firewall_rules": if child.tag == "firewall_rules":
# #
......
...@@ -363,6 +363,14 @@ sub GenerateNodeStatements($) ...@@ -363,6 +363,14 @@ sub GenerateNodeStatements($)
$node->addTagStatement("Desire('$desire','$weight')"); $node->addTagStatement("Desire('$desire','$weight')");
} }
#
# Node Attributes.
#
foreach my $key (sort(keys(%{ $node->attributes() }))) {
my $value = $node->attributes()->{$key};
$node->addTagStatement("Attribute('$key','$value')");
}
# #
# Interfaces. # Interfaces.
# #
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment