diff --git a/backend/newimageid_ez.in b/backend/newimageid_ez.in
index d3494eff0ad440446d5ad8f4d0840252c8af5067..38c9238e4a7db3b5dc9fe91d7ae5c2438c11c89d 100644
--- a/backend/newimageid_ez.in
+++ b/backend/newimageid_ez.in
@@ -55,6 +55,7 @@ my $TBGROUP_DIR = "@GROUPSROOT_DIR@";
my $TBPROJ_DIR = "@PROJROOT_DIR@";
my $CREATEIMAGE = "$TB/bin/create_image";
my $CLONEIMAGE = "$TB/sbin/clone_image";
+my $RUNSONXEN = "$TB/sbin/runsonxen";
#
# Untaint the path
@@ -761,13 +762,7 @@ if (defined($parentos)) {
# Temp hack until we put all mappings into XML file.
#
if ($parentos->osname() =~ /^XEN4/) {
- my $other = ($parentos->osname() =~ /^XEN41/ ?
- "XEN43-64-STD" : "XEN41-64-STD");
-
- my $otheros = OSinfo->LookupByName($other);
- if (defined($otheros)) {
- $new_osinfo->SetRunsOnParent($otheros);
- }
+ system("$RUNSONXEN $imagepid,$imagename");
}
}
diff --git a/utils/GNUmakefile.in b/utils/GNUmakefile.in
index 9e0c487ef47832465bddcf2fe0770cb532c21c25..4103f6c90ce569124eb7377f6e0433ce063d717a 100644
--- a/utils/GNUmakefile.in
+++ b/utils/GNUmakefile.in
@@ -53,7 +53,8 @@ SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \
prereserve_check tcppd addexternalnetwork \
update_sitevars delete_image sitecheckin sitecheckin_client \
mktestbedtest fixrootcert addservers poolmonitor \
- node_exclude managetaint shutdown-shared imagerelease
+ node_exclude managetaint shutdown-shared imagerelease \
+ runsonxen
WEB_SBIN_SCRIPTS= webnewnode webdeletenode webspewconlog webarchive_list \
webwanodecheckin webspewimage webdumpdescriptor \
diff --git a/utils/runsonxen.in b/utils/runsonxen.in
new file mode 100755
index 0000000000000000000000000000000000000000..6efa39d7765ad14a55bfefdc79fb6cf3eac2a33d
--- /dev/null
+++ b/utils/runsonxen.in
@@ -0,0 +1,197 @@
+#!/usr/bin/perl -w
+#
+# Copyright (c) 2010-2014 University of Utah and the Flux Group.
+#
+# {{{EMULAB-LICENSE
+#
+# This file is part of the Emulab network testbed software.
+#
+# This file is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or (at
+# your option) any later version.
+#
+# This file is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this file. If not, see .
+#
+# }}}
+#
+use English;
+use strict;
+use Getopt::Std;
+
+#
+# Mark an image as running on XEN.
+#
+my $DEFAULT_PARENT = "XEN43-64-STD";
+my @OTHER_PARENTS = ("XEN44-64-BIGFS", "XEN41-64-STD");
+
+sub usage()
+{
+ print STDERR "usage: runsonxen [-p ] \n";
+ print STDERR "usage: runsonxen -a [-p ]\n";
+ print STDERR "usage: runsonxen -c \n";
+ print STDERR "Options:\n";
+ print STDERR " -n - Impotent mode\n";
+ print STDERR " -c - Clear XEN parent settings completely\n";
+ print STDERR " -a - Operate on all current XEN capable images\n";
+ print STDERR " -p - Set default parent; currently $DEFAULT_PARENT\n";
+ exit(1);
+}
+my $optlist = "acp:n";
+my $doall = 0;
+my $clear = 0;
+my $impotent = 0;
+my $parent = $DEFAULT_PARENT;
+
+# Protos
+sub fatal($);
+
+#
+# Turn off line buffering on output
+#
+$| = 1;
+
+#
+# Load the Testbed support stuff.
+#
+use lib "/usr/testbed/lib";
+use emdb;
+use Image;
+use OSinfo;
+
+my %options = ();
+if (! getopts($optlist, \%options)) {
+ usage();
+}
+if (defined($options{"c"})) {
+ $clear = 1;
+}
+if (defined($options{"a"})) {
+ $doall = 1;
+}
+if (defined($options{"n"})) {
+ $impotent = 1;
+}
+if (defined($options{"p"})) {
+ $parent = $options{"p"};
+ @OTHER_PARENTS = ($DEFAULT_PARENT, @OTHER_PARENTS);
+}
+usage()
+ if (!$doall && !@ARGV);
+
+#
+# List of images to operate on.
+#
+my @images = ();
+
+if ($doall) {
+ my $query_result =
+ DBQueryFatal("select distinct v.osid from os_info_versions as v ".
+ "left join os_info_versions as v2 on ".
+ " v2.osid=v.def_parentosid ".
+ "where v.deleted is null and ".
+ " v.def_parentosid is not null and ".
+ " FIND_IN_SET('xen-host', v2.osfeatures)");
+
+ while (my ($osid) = $query_result->fetchrow_array()) {
+ my $image = Image->Lookup($osid);
+ push(@images, $image)
+ if (defined($image));
+ }
+}
+else {
+ my $image = Image->Lookup($ARGV[0]);
+ if (!defined($image)) {
+ fatal("No such image");
+ }
+ @images = ($image);
+}
+
+if ($clear) {
+ foreach my $image (@images) {
+ my $osinfo = OSinfo->Lookup($image->imageid());
+ if (!defined($osinfo)) {
+ fatal("Could not find osinfo for $image");
+ }
+ my $imageid = $image->imageid();
+ my $osid = $osinfo->osid();
+ if ($impotent) {
+ print "Would clear parents for $image\n";
+ }
+ else {
+ DBQueryFatal("delete from osidtoimageid ".
+ "where osid='$imageid' and type='pcvm'");
+ DBQueryFatal("delete from os_submap ".
+ "where osid='$imageid'");
+ DBQueryFatal("update os_info set def_parentosid=NULL ".
+ "where osid='$imageid'");
+ }
+ }
+ exit(0);
+}
+
+#
+# Find the "default" parent image and the list of others parents.
+#
+my $parent_image = Image->LookupByName($parent);
+if (!defined($parent_image)) {
+ fatal("No such parent $parent");
+}
+my $parent_osinfo = OSinfo->Lookup($parent_image->imageid());
+if (!defined($parent_osinfo)) {
+ fatal("No osinfo for $parent");
+}
+
+my @other_parents = ();
+foreach my $imagename (@OTHER_PARENTS) {
+ my $osinfo = OSinfo->LookupByName($imagename);
+ push(@other_parents, $osinfo)
+ if (defined($osinfo));
+}
+
+#
+# Loop through all images.
+#
+foreach my $image (@images) {
+ my $osinfo = OSinfo->Lookup($image->imageid());
+ if (!defined($osinfo)) {
+ fatal("Could not find osinfo for $image");
+ }
+ if ($impotent) {
+ print "Would set $image to run on $parent_osinfo (default)\n";
+ }
+ else {
+ $osinfo->SetParentOS($parent_osinfo);
+ $osinfo->SetRunsOnParent($parent_osinfo);
+ }
+ # And the rest of the parents.
+ foreach my $other_parent (@other_parents) {
+ if ($impotent) {
+ print " Would set $image to run on $other_parent\n";
+ }
+ else {
+ $osinfo->SetRunsOnParent($other_parent);
+ }
+ }
+ if ($impotent) {
+ print " Setting $image to run on type pcvm\n";
+ }
+ else {
+ $image->SetRunsOnNodeType("pcvm");
+ }
+}
+exit(0);
+
+sub fatal($) {
+ my ($mesg) = $_[0];
+
+ print STDERR "*** $0:\n".
+ " $mesg\n";
+ exit(-1);
+}