Commit 51552904 authored by Leigh Stoller's avatar Leigh Stoller

The rest of the virt_node_attributes table support. You can do this in

your NS file:

	$node0 add-attribute jailip 155.98.36.229
	$node0 add-attribute jailipmask 255.255.252.0

to override the default jail ip assignment. Use this carefully of
course since there is no checking yet.

You can also do something like this:

	$myboss add-attribute XEN_EXTRADISKS "disk1:10G,disk2:10G,disk3:10G"
	$myops  add-attribute XEN_EXTRADISKS "disk1:4G,disk2:10G"

which will add these extra disks to your xen containers. Note that
this requires clientside changes from another commit to be installed
in the XEN image.
parent 86564e95
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005-2011 University of Utah and the Flux Group.
# Copyright (c) 2005-2012 University of Utah and the Flux Group.
# All rights reserved.
#
package Experiment;
......@@ -132,6 +132,7 @@ $EXPT_RESOURCESHOSED = 0;
"virt_routes",
"virt_vtypes",
"virt_programs",
"virt_node_attributes",
"virt_node_desires",
"virt_node_startloc",
"virt_simnode_attributes",
......@@ -4968,5 +4969,30 @@ sub MarkNonlocal($$$$)
return 0;
}
#
# Lookup a key/value pair from the virt_node_attributes table.
#
sub GetVirtNodeAttribute($$$$)
{
my ($self, $vname, $key, $pval) = @_;
$$pval = undef;
my $exptidx = $self->idx();
my $safe_key = DBQuoteSpecial($key);
my $query_result =
DBQueryWarn("select attrvalue from virt_node_attributes ".
"where exptidx='$exptidx' and vname='$vname' and ".
" attrkey=$safe_key");
return -1
if (!defined($query_result));
return 0
if (! $query_result->numrows);
my ($val) = $query_result->fetchrow_array();
$$pval = $val;
return 0;
}
# _Always_ make sure that this 1 is at the end of the file...
1;
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2009-2011 University of Utah and the Flux Group.
# Copyright (c) 2009-2012 University of Utah and the Flux Group.
# All rights reserved.
#
package VirtExperiment;
......@@ -62,6 +62,7 @@ my $debug = 0;
"virt_routes" => [ "vname", "src", "dst" ],
"virt_vtypes" => [ "name" ],
"virt_programs" => [ "vname", "vnode" ],
"virt_node_attributes" => [ "vname", "attrkey" ],
"virt_user_environment" => [ "name", "value" ],
"virt_bridges" => [ "vname", "vlink", "vport"],
"nseconfigs" => [ "vname" ],
......@@ -1150,6 +1151,11 @@ use vars qw(@ISA);
@ISA = "VirtExperiment::VirtTableRow";
use VirtExperiment;
package VirtExperiment::VirtTableRow::virt_node_attributes;
use vars qw(@ISA);
@ISA = "VirtExperiment::VirtTableRow";
use VirtExperiment;
package VirtExperiment::VirtTableRow::virt_user_environment;
use vars qw(@ISA);
@ISA = "VirtExperiment::VirtTableRow";
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -92,6 +92,9 @@ my %virtual_tables =
"virt_programs" => { rows => undef,
tag => "programs",
row => "program"},
"virt_node_attributes" => { rows => undef,
tag => "virt_node_attributes",
row => "virt_node_attribute"},
"virt_user_environment" => { rows => undef,
tag => "user_environments",
row => "user_environment"},
......
# -*- tcl -*-
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -101,6 +101,10 @@ Node instproc init {s} {
$self set sharing_mode ""
$self set role ""
# Arbitrary key/value pairs to pass through to physical nodes.
$self instvar attributes
array set attributes {}
$self set topo ""
$self set X_ ""
......@@ -200,6 +204,7 @@ Node instproc updatedb {DB} {
$self instvar virthost
$self instvar issubnode
$self instvar desirelist
$self instvar attributes
$self instvar nseconfig
$self instvar simulated
$self instvar sharing_mode
......@@ -400,6 +405,12 @@ Node instproc updatedb {DB} {
$sim spitxml_data "virt_node_desires" [list "vname" "desire" "weight"] [list $self $desire $weight]
}
# Put in the attributes, too
foreach key [lsort [array names attributes]] {
set val $attributes($key)
$sim spitxml_data "virt_node_attributes" [list "vname" "attrkey" "attrvalue"] [list $self $key $val]
}
set agentname "$self"
if { $role == "bridge" } {
# XXX Gack. We cannot have two virt_agents with the same name
......@@ -663,6 +674,14 @@ Node instproc add-desire {desire weight} {
set desirelist($desire) $weight
}
#
# Add a key/value pair to the nide.
#
Node instproc add-attribute {key val} {
$self instvar attributes
set attributes($key) $val
}
Node instproc program-agent {args} {
::GLOBALS::named-args $args {
......
......@@ -308,6 +308,7 @@ COMMAND_PROTOTYPE(dodhcpdconf);
COMMAND_PROTOTYPE(dosecurestate);
COMMAND_PROTOTYPE(doquoteprep);
COMMAND_PROTOTYPE(doimagekey);
COMMAND_PROTOTYPE(donodeattributes);
/*
* The fullconfig slot determines what routines get called when pushing
......@@ -416,6 +417,8 @@ struct command {
{ "securestate", FULLCONFIG_NONE, F_REMREQSSL, dosecurestate},
{ "quoteprep", FULLCONFIG_NONE, F_REMREQSSL, doquoteprep},
{ "imagekey", FULLCONFIG_NONE, F_REQTPM, doimagekey},
{ "nodeattributes", FULLCONFIG_ALL, 0, donodeattributes},
};
static int numcommands = sizeof(command_array)/sizeof(struct command);
......@@ -6771,9 +6774,9 @@ COMMAND_PROTOTYPE(dojailconfig)
/*
* Now need the sshdport and jailip for this node.
*/
res = mydb_query("select sshdport,jailip from nodes "
res = mydb_query("select sshdport,jailip,jailipmask from nodes "
"where node_id='%s'",
2, reqp->nodeid);
3, reqp->nodeid);
if (!res) {
error("JAILCONFIG: %s: DB Error getting config!\n",
......@@ -6790,7 +6793,8 @@ COMMAND_PROTOTYPE(dojailconfig)
bzero(buf, sizeof(buf));
if (row[1]) {
bufp += OUTPUT(bufp, ebufp - bufp,
"JAILIP=\"%s,%s\"\n", row[1], JAILIPMASK);
"JAILIP=\"%s,%s\"\n",
row[1], (row[2] ? row[2] : JAILIPMASK));
}
bufp += OUTPUT(bufp, ebufp - bufp,
"PORTRANGE=\"%d,%d\"\n"
......@@ -6803,9 +6807,10 @@ COMMAND_PROTOTYPE(dojailconfig)
"IPDIVERT=1\n"
"ROUTING=%d\n"
"DEVMEM=%d\n"
"ELABINELAB=%d\n"
"EVENTSERVER=\"event-server.%s\"\n",
low, high, atoi(row[0]), reqp->islocal, reqp->islocal,
OURDOMAIN);
reqp->elab_in_elab, OURDOMAIN);
client_writeback(sock, buf, strlen(buf), tcp);
mysql_free_result(res);
......@@ -9811,3 +9816,43 @@ COMMAND_PROTOTYPE(dotpmdummy)
return 0;
}
/*
* Return the virt_node_attributes for a node.
*/
COMMAND_PROTOTYPE(donodeattributes)
{
MYSQL_RES *res;
MYSQL_ROW row;
char buf[MYBUFSIZE];
char *bufp = buf, *ebufp = &buf[sizeof(buf)];
int nrows;
if (! reqp->allocated) {
return 0;
}
bzero(buf, sizeof(buf));
/*
* Get all the *virt* attributes for the node.
*/
res = mydb_query("select attrkey,attrvalue "
" from virt_node_attributes "
"where exptidx=%d and vname='%s'",
2, reqp->exptidx, reqp->nickname);
if (res) {
nrows = (int)mysql_num_rows(res);
while (bufp < ebufp && nrows--) {
row = mysql_fetch_row(res);
if (row[0] && row[0][0] && row[1])
bufp += OUTPUT(bufp, ebufp - bufp,
"%s=\"%s\"\n",
row[0], row[1]);
}
mysql_free_result(res);
client_writeback(sock, buf, strlen(buf), tcp);
}
return 0;
}
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