From 9ea754665b7db206f19524d3ecf377d616d4ad66 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Tue, 10 May 2011 19:40:38 -0400 Subject: [PATCH] Add deployment mechanism for hotfixes to nodes in chosen nodegroups. --- PlanetLabConf/hotfixes.php | 72 +++++++++++++++++++++++++++++ PlanetLabConf/hotfixes/build.sh | 10 ++++ db-config.d/030-conf_files_hotfixes | 20 ++++++++ 3 files changed, 102 insertions(+) create mode 100644 PlanetLabConf/hotfixes.php create mode 100755 PlanetLabConf/hotfixes/build.sh create mode 100644 db-config.d/030-conf_files_hotfixes diff --git a/PlanetLabConf/hotfixes.php b/PlanetLabConf/hotfixes.php new file mode 100644 index 0000000..8fdbb7d --- /dev/null +++ b/PlanetLabConf/hotfixes.php @@ -0,0 +1,72 @@ +GetNodes(array(intval($_REQUEST['node_id']))); + if (!empty($nodes)) { + $node = $nodes[0]; + } else { + exit(1); + } + if ( count($node['nodegroup_ids']) > 0 ) + { + // collect a list of all nodegroup names for this node. + foreach ( $node['nodegroup_ids'] as $ng_id ) { + $ngs = $adm->GetNodeGroups(array('nodegroup_id' => $ng_id)); + if (!empty($ngs)) { + logit($ngs[0]['groupname']); + $ng_names[] = $ngs[0]['groupname']; + } + } + } else { + $ng_names[] = "default"; + } +} + +foreach ( $ng_names as $name ) +{ + logit("name: " . $name); + // check that directory exists + $file= "hotfixes/$name.tar"; + $stat = stat($file); + if ( !empty ($stat) ) + { + // send to client + readfile($file); + // stop after the first match. + exit(1); + } +} + +?> diff --git a/PlanetLabConf/hotfixes/build.sh b/PlanetLabConf/hotfixes/build.sh new file mode 100755 index 0000000..238ef2e --- /dev/null +++ b/PlanetLabConf/hotfixes/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Look for all directories in the PlanetLabConf/hotfixes directory and +# create tar files for hotfixes on nodegroups with the same name. + +for dir in `find . -maxdepth 1 -type d | grep -vE "^.$"` ; do + b=$dir.tar + d=$dir + tar -C $d --create --file $b . +done diff --git a/db-config.d/030-conf_files_hotfixes b/db-config.d/030-conf_files_hotfixes new file mode 100644 index 0000000..69b237b --- /dev/null +++ b/db-config.d/030-conf_files_hotfixes @@ -0,0 +1,20 @@ +#/usr/bin/env plcsh + +conf_files = [ + { 'source': 'PlanetLabConf/hotfixes.php', + 'dest': '/tmp/hotfixes.tar', + 'file_owner': 'root', + 'file_group': 'root' + 'file_permissions': '644', + 'enabled': True, + 'preinstall_cmd': '', + 'postinstall_cmd': 'tar -C / -xf /tmp/hotfixes.tar', + 'error_cmd': '', + 'ignore_cmd_errors': False, + 'always_update': False}, + ] + +for conf_file in conf_files: + SetConfFile(conf_file) + + -- 2.43.0