Commit 3ec8f1a6 authored by Mike Hibler's avatar Mike Hibler
Browse files

Change syntax for adding/removing elabinelab attributes.

Made set-elabinelab-attribute set the attribute for all roles (nodes).
Added a net command set-elabinelab-role-attribute to set it for a single role.
Ditto for unset.

The common case was setting a "global" attribute and it was tedious to give
individual commands for boss, ops, fs, etc.
parent 3d2619e8
......@@ -80,8 +80,10 @@ proc tb-elab-in-elab-topology {topo} {}
proc tb-set-inner-elab-eid {eid} {}
proc tb-set-elabinelab-cvstag {cvstag} {}
proc tb-elabinelab-singlenet {} {}
proc tb-set-elabinelab-attribute {role key val {order 0}} {}
proc tb-unset-elabinelab-attribute {role key} {}
proc tb-set-elabinelab-attribute {key val {order 0}} {}
proc tb-unset-elabinelab-attribute {key} {}
proc tb-set-elabinelab-role-attribute {role key val {order 0}} {}
proc tb-unset-elabinelab-role-attribute {role key} {}
proc tb-set-node-inner-elab-role {node role} {}
proc tb-set-node-id {vnode myid} {}
proc tb-set-link-est-bandwidth {srclink args} {}
......
......@@ -133,7 +133,7 @@ namespace eval TBCOMPAT {
# Elabinelab attribute stuff.
variable elabinelab_attributes
set elabinelab_attributes {}
variable EINEROLE {^(boss|ops|fs|router|node)$}
variable EINEROLE {^(all|boss|ops|fs|router|node)$}
variable EINEKEY {^([-\w\.]+)$}
variable EINEVALUE {^([-\w\.\+\,\s\/]+)$}
variable EINEORDER {^\d+$}
......@@ -1756,10 +1756,20 @@ proc tb-elabinelab-singlenet {args} {
#
# Set/clear elabinelab attributes:
# tb-set-elabinelab-attribute <role> <key> <value> [<order>]
# tb-unset-elabinelab-attribute <role> <key>
# tb-set-elabinelab-attribute <key> <value> [<order>]
# tb-unset-elabinelab-attribute <key>
# tb-set-elabinelab-role-attribute <role> <key> <value> [<order>]
# tb-unset-elabinelab-role-attribute <role> <key>
#
proc tb-set-elabinelab-attribute {role key value {order 0}} {
proc tb-set-elabinelab-attribute {key value {order 0}} {
tb-set-elabinelab-role-attribute "all" $key $value $order
}
proc tb-unset-elabinelab-attribute {key} {
tb-unset-elabinelab-role-attribute "all" $key
}
proc tb-set-elabinelab-role-attribute {role key value {order 0}} {
var_import ::TBCOMPAT::EINEROLE;
var_import ::TBCOMPAT::EINEKEY;
var_import ::TBCOMPAT::EINEVALUE;
......@@ -1783,18 +1793,26 @@ proc tb-set-elabinelab-attribute {role key value {order 0}} {
return
}
#
# If role/key/ordering exactly matches an existing value, replace it
# otherwise just add it.
#
set i [lsearch -glob $elabinelab_attributes "$role,$key,*,$order"]
if {$i > -1} {
set elabinelab_attributes [lreplace $elabinelab_attributes $i $i]
if {$role == "all"} {
set roles {"boss" "ops" "fs" "router" "node"}
} else {
set roles $role
}
foreach r $roles {
#
# If role/key/ordering exactly matches an existing value,
# replace it to preserve uniqueness, otherwise just add it.
#
set i [lsearch -glob $elabinelab_attributes "$r,$key,*,$order"]
if {$i > -1} {
set elabinelab_attributes [lreplace $elabinelab_attributes $i $i]
}
lappend elabinelab_attributes "$r,$key,$value,$order"
}
lappend elabinelab_attributes "$role,$key,$value,$order"
}
proc tb-unset-elabinelab-attribute {role key} {
proc tb-unset-elabinelab-role-attribute {role key} {
var_import ::TBCOMPAT::EINEROLE;
var_import ::TBCOMPAT::EINEKEY;
var_import ::TBCOMPAT::elabinelab_attributes;
......@@ -1807,9 +1825,17 @@ proc tb-unset-elabinelab-attribute {role key} {
perror "\[tb-unset-elabinelab-attribute] - \"$key\" is not a valid elabinelab key"
return
}
while {[lsearch -glob $elabinelab_attributes "$role,$key,*"] > -1} {
set i [lsearch -glob $elabinelab_attributes "$role,$key,*"]
set elabinelab_attributes [lreplace $elabinelab_attributes $i $i]
if {$role == "all"} {
set roles {"boss" "ops" "fs" "router" "node"}
} else {
set roles $role
}
foreach r $roles {
while {[lsearch -glob $elabinelab_attributes "$r,$key,*"] > -1} {
set i [lsearch -glob $elabinelab_attributes "$r,$key,*"]
set elabinelab_attributes [lreplace $elabinelab_attributes $i $i]
}
}
}
......
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