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

Support for node attributes.

parent 56eb48f6
......@@ -835,6 +835,7 @@ sub new($$$$$)
"services" => [],
"statements" => [],
"desires" => {},
"attributes" => {},
"ifaces" => {},
"ifacelist" => [],
"blockstores" => {},
......@@ -858,6 +859,8 @@ sub blockstores($) { return $_[0]->{'blockstores'}; }
sub ifaces($) { return $_[0]->{'ifaces'}; }
sub ifacelist($) { return $_[0]->{'ifacelist'}; }
sub services($) { return $_[0]->{'services'}; }
sub desires($) { return $_[0]->{'services'}; }
sub attributes($) { return $_[0]->{'attributes'}; }
sub pipes($) { return $_[0]->{'pipes'}; }
sub firewall_style($) { return $_[0]->{'firewall_style'}; }
sub firewall_rules($) { return $_[0]->{'firewall_rules'}; }
......@@ -1220,6 +1223,12 @@ sub addNode($$$)
$node->{"desires"}->{$desire} = $weight;
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 {
# Convert to a desire
my $chassis = GetTextOrFail("chassis", $child);
......@@ -1295,7 +1304,7 @@ sub Compare($$)
# Handled up above in CompareNodes.
last SWITCH;
};
/^(xen_settings|desires|pipes|blockstores)$/i && do {
/^(xen_settings|desires|pipes|blockstores|attributes)$/i && do {
return 1
if (APT_Rspec::CompareHashes("Node: $client_id: $key",
$val1, $val2));
......
......@@ -774,11 +774,31 @@ for child in tree.getroot():
vname = row.find("vname").text
key = row.find("attrkey").text
val = row.find("attrvalue").text
raw = etree.Element("{%s}node_attribute" %
(RSpec.Namespaces.EMULAB.name))
raw.attrib["attrkey"] = key
raw.attrib["attrvalue"] = val
nodes[vname].addRawElement(raw)
node = nodes[vname]
#
# Many node attributes, we have to translate some, the rest
# 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
if child.tag == "firewall_rules":
#
......
......@@ -363,6 +363,14 @@ sub GenerateNodeStatements($)
$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.
#
......
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