Pass in hostname as a script parameter

Pass the hostname in as the first parameter to both the setup script and
the ready script.

Change-Id: I0de51156b56ae750dd519da0da68b85ac5d41267
This commit is contained in:
K Jonathan Harker 2014-06-06 15:27:08 -07:00
parent 174a5d7f6d
commit 8e254b4994
3 changed files with 41 additions and 26 deletions

View File

@ -121,27 +121,9 @@ communicate directly with each other. In the example above, for each
Precise node added to the target system, two additional nodes will be Precise node added to the target system, two additional nodes will be
created and associated with it. created and associated with it.
The script specified by `ready-script` (which is expected to be in A script specified by `ready-script` can be used to perform any last minute
`/opt/nodepool-scripts` along with the setup script) can be used to changes to a node after it has been launched but before it is put in the READY
perform any last minute changes to a node after it has been launched state to receive jobs. For more information, see :ref:`scripts`.
but before it is put in the READY state to receive jobs. In
particular, it can read the files in /etc/nodepool to perform
multi-node related setup.
Those files include:
**/etc/nodepool/role**
Either the string ``primary`` or ``sub`` indicating whether this
node is the primary (the node added to the target and which will run
the job), or a sub-node.
**/etc/nodepool/primary_node**
The IP address of the primary node.
**/etc/nodepool/sub_nodes**
The IP addresses of the sub nodes, one on each line.
**/etc/nodepool/id_rsa**
An OpenSSH private key generated specifically for this node group.
**/etc/nodepool/id_rsa.pub**
The corresponding public key.
providers providers
--------- ---------
@ -205,7 +187,7 @@ For providers, the `name`, `username`, `password`, `auth-url`,
`name`, `base-image`, and `min-ram` keys are required. The `username` `name`, `base-image`, and `min-ram` keys are required. The `username`
and `private-key` values default to the values indicated. Nodepool and `private-key` values default to the values indicated. Nodepool
expects that user to exist after running the script indicated by expects that user to exist after running the script indicated by
`setup`. `setup`. See :ref:`scripts` for setup script details.
Both `boot-timeout` and `launch-timeout` keys are optional. The Both `boot-timeout` and `launch-timeout` keys are optional. The
`boot-timeout` key defaults to 60 seconds and `launch-timeout` key `boot-timeout` key defaults to 60 seconds and `launch-timeout` key

View File

@ -18,3 +18,36 @@ that begin with ``NODEPOOL_`` will be set in the calling environment
for the script. This is useful during testing to alter script for the script. This is useful during testing to alter script
behavior, for instance, to add a local ssh key that would not behavior, for instance, to add a local ssh key that would not
otherwise be set in production. otherwise be set in production.
Setup script
------------
Each provider can specify a setup script with `setup`, and that script is
expected to exist in `script_dir`. If it is found, it will be run during image
creation. When the script is invoked, the instance hostname will be passed in
as the first parameter.
Ready script
------------
Each label can specify a ready script with `ready-script`. This script can be
used to perform any last minute changes to a node after it has been launched
but before it is put in the READY state to receive jobs. In particular, it
can read the files in /etc/nodepool to perform multi-node related setup.
Those files include:
**/etc/nodepool/role**
Either the string ``primary`` or ``sub`` indicating whether this
node is the primary (the node added to the target and which will run
the job), or a sub-node.
**/etc/nodepool/primary_node**
The IP address of the primary node.
**/etc/nodepool/sub_nodes**
The IP addresses of the sub nodes, one on each line.
**/etc/nodepool/id_rsa**
An OpenSSH private key generated specifically for this node group.
**/etc/nodepool/id_rsa.pub**
The corresponding public key.

View File

@ -527,8 +527,8 @@ class NodeLauncher(threading.Thread):
if k.startswith('NODEPOOL_'): if k.startswith('NODEPOOL_'):
env_vars += ' %s="%s"' % (k, v) env_vars += ' %s="%s"' % (k, v)
host.ssh("run ready script", host.ssh("run ready script",
"cd /opt/nodepool-scripts && %s ./%s" % "cd /opt/nodepool-scripts && %s ./%s %s" %
(env_vars, self.label.ready_script)) (env_vars, self.label.ready_script, n.hostname))
class SubNodeLauncher(threading.Thread): class SubNodeLauncher(threading.Thread):
@ -863,8 +863,8 @@ class ImageUpdater(threading.Thread):
if k.startswith('NODEPOOL_'): if k.startswith('NODEPOOL_'):
env_vars += ' %s="%s"' % (k, v) env_vars += ' %s="%s"' % (k, v)
host.ssh("run setup script", host.ssh("run setup script",
"cd /opt/nodepool-scripts && %s ./%s" % "cd /opt/nodepool-scripts && %s ./%s %s" %
(env_vars, self.image.setup)) (env_vars, self.image.setup, server['name']))
class ConfigValue(object): class ConfigValue(object):