diff options
Diffstat (limited to 'lib/sunhpc/commands/set/host/boot/__init__.py')
-rw-r--r-- | lib/sunhpc/commands/set/host/boot/__init__.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/sunhpc/commands/set/host/boot/__init__.py b/lib/sunhpc/commands/set/host/boot/__init__.py new file mode 100644 index 0000000..d5fe7a6 --- /dev/null +++ b/lib/sunhpc/commands/set/host/boot/__init__.py @@ -0,0 +1,52 @@ +#coding:utf-8 + +import sunhpc.commands +class Command(sunhpc.commands.set.host.command): + """ + Set a bootaction for a host. A hosts action can be set to 'install' + or to 'os' (also, 'run' is a synonym for 'os'). + + <arg type='string' name='host' repeat='1'> + One or more host names. + </arg> + + <param type='string' name='action'> + The label name for the bootaction. This must be one of: 'os', + 'install', or 'run'. + + If no action is supplied, then only the configuration file for the + list of hosts will be rewritten. + </param> + + <example cmd='set host boot compute-0-0 action=os'> + On the next boot, compute-0-0 will boot the profile based on its + "status". To see the node's "status", execute: + "sunhpc list host compute-0-0" and examine the value in the "status" column. + </example> + """ + + def updateBoot(self, host, action): + + self.db.execute("select id from nodes where name = '%s'" % host) + bootid, = self.db.fetchone() + self.db.execute("update nodes set status = '%s' where id = %s" % (action, bootid)) + + def run(self, params, args): + + (action,) = self.fillParams([('action', )]) + + if not len(args): + self.abort('must supply host') + + if action not in [ 'os', 'install', None ]: + self.abort('invalid action. action must be "os" or "install"') + + for host in self.getHostnames(args): + if action: + self.updateBoot(host, action) + # + # run the plugins + # + self.runPlugins(host) + +RollName = "base" |