Skip to content
Permalink
Browse files

Add 'om node updateclumgr' command

This new command updates the cluster manager application on the node.
It only updates the javascript web application served by the listener.
It can be safely executed at any time, as soon as nobody is submitting
cluster actions through it.

It depends on a node.repo or node.repopkg node.conf parameter, pointing
to a ftp or http repository hosting cluster manager bundles.
The target package must be defined as 'current'.

The repo file tree must comply to the following organization:

opensvc@node:/path/to/wwwroot $ tree cluster-manager
cluster-manager
├── 1
│   ├── 1.0.0
│   │   └── bundle
│   └── current -> 1.0.0/bundle
├── 2
│   ├── 2.0.0
│   │   └── bundle
│   └── current -> 2.0.0/bundle
└── current -> 2/current

1st level : cluster-manager is the root directory
2nd level : opensvc agent api version
3rd level : cluster manager version, and a 'current' link pointing to
            the latest version
4th level : 'bundle' file is a tar.gz archive containing web application

The simplest option to maintain a working repository is to mirror
opensvc official repository located at https://repo.opensvc.com/
  • Loading branch information...
arnaudveron committed Jul 31, 2019
1 parent be88647 commit 2f881db6cc5910f9e87a6742485b5213e83c4e96
Showing with 90 additions and 2 deletions.
  1. +81 −0 lib/node.py
  2. +7 −1 lib/nodemgr_parser.py
  3. +2 −1 usr/share/bash_completion.d/opensvc.sh
@@ -109,6 +109,7 @@
"reboot",
"shutdown",
"updatepkg",
"updateclumgr",
"updatecomp",
)
ACTIONS_NO_PARALLEL = [
@@ -2164,6 +2165,86 @@ def updatepkg(self):
os.system("%s pushasset" % rcEnv.paths.nodemgr)
return 0

def updateclumgr(self):
"""
Downloads and installs the cluster manager bundle archive from the url
specified as node.repopkg or node.repo in node.conf.
"""
import osvcd_shared as shared
api_version = str(shared.API_VERSION)
repopkg = self.oget("node", "repopkg")
repo = self.oget("node", "repo")
if repopkg:
bundle_basename = repopkg.strip('/')
elif repo:
bundle_basename = repo.strip('/')
else:
if self.options.cron:
return 0
print("node.repo or node.repopkg must be set in node.conf",
file=sys.stderr)
return 1
bundle_name = bundle_basename + "/cluster-manager/" + api_version + '/current'
import tempfile
tmpf = tempfile.NamedTemporaryFile()
fpath = tmpf.name
tmpf.close()
try:
ret = self._updateclumgr(bundle_name, fpath)
finally:
if os.path.exists(fpath):
os.unlink(fpath)
return ret

def _updateclumgr(self, bundle_name, fpath):
"""
Downloads and installs the cluster manager bundle archive from the url
specified by the bundle_name argument. The download destination file
is specified by fpath. The caller is responsible for its deletion.
"""
print("get %s (%s)"%(bundle_name, fpath))
try:
self.urlretrieve(bundle_name, fpath)
except IOError as exc:
print("download failed", ":", exc, file=sys.stderr)
if self.options.cron:
return 0
return 1
tmpp = os.path.join(rcEnv.paths.pathtmp, 'html')
backp = os.path.join(rcEnv.paths.pathsvc, 'html.bck')
htmlp = os.path.join(rcEnv.paths.pathsvc, 'html')
makedirs(htmlp)
makedirs(tmpp)

print("extract cluster manager in", tmpp)
import tarfile
tar = tarfile.open(fpath)
os.chdir(tmpp)
try:
tar.extractall()
tar.close()
except (OSError, IOError):
print("failed to unpack", file=sys.stderr)
return 1
os.chdir("/")

print("install new cluster manager in %s"%htmlp)
for root, dirs, files in os.walk(tmpp):
for fpath in dirs:
os.chown(os.path.join(root, fpath), 0, 0)
for fpath in files:
os.chown(os.path.join(root, fpath), 0, 0)

import shutil
try:
shutil.rmtree(backp)
except (OSError, IOError):
pass

shutil.move(htmlp, backp)
shutil.move(tmpp, htmlp)
return 0

def array(self):
"""
Execute a array command, passing extra_argv to the array driver.
@@ -432,7 +432,13 @@
},
"updatepkg": {
"msg": "Upgrade the opensvc agent version. the packages must be "
"available behind the node.repo/packages url.",
"available behind the node.repo/packages url, or behind "
"a mirrored node.repopkg url.",
},
"updateclumgr": {
"msg": "Upgrade the opensvc cluster manager version. the bundles "
"must be available behind the node.repo/cluster-manager "
"url, or behind a mirrored node.repopkg url.",
},
"updatecomp": {
"msg": "Upgrade the opensvc compliance modules. The modules must "
@@ -139,7 +139,7 @@ svcmgr_switch="--color --debug --disable-rollback --env --interval --local --nam
svcmgr_disable="--color --debug --env --local --namespace --node --rid --status --subsets --tags --waitlock -h --help -p --parallel -s --service"
svcmgr_print_schedule="--color --debug --env --filter --format --local --namespace --node --status --verbose --waitlock -h --help -p --parallel -s --service"
svcmgr_docker="--color --debug --env --local --namespace --node --status --waitlock -h --help -p --parallel -s --service"
nodemgr="array auto checks collect collector compliance daemon delete dequeue dns edit eval events freeze frozen get logs ls network ping pool print prkey pushasset pushbrocade pushcentera pushdisks pushemcvnx pusheva pushfreenas pushgcedisks pushhds pushhp3par pushibmds pushibmsvc pushnecism pushnetapp pushnsr pushpatch pushpkg pushstats pushsym pushvioserver pushxtremio reboot register rotate scanscsi schedule set shutdown snooze stonith sysreport thaw unschedule unset unsnooze updatecomp updatepkg validate wait wol"
nodemgr="array auto checks collect collector compliance daemon delete dequeue dns edit eval events freeze frozen get logs ls network ping pool print prkey pushasset pushbrocade pushcentera pushdisks pushemcvnx pusheva pushfreenas pushgcedisks pushhds pushhp3par pushibmds pushibmsvc pushnecism pushnetapp pushnsr pushpatch pushpkg pushstats pushsym pushvioserver pushxtremio reboot register rotate scanscsi schedule set shutdown snooze stonith sysreport thaw unschedule unset unsnooze updatecomp updatepkg updateclumgr validate wait wol"
nodemgr_auto="reboot"
nodemgr_collect="stats"
nodemgr_collector="ack alerts asset checks cli create disks events list log networks search show tag untag"
@@ -238,6 +238,7 @@ nodemgr_dequeue_actions="--color --cron --debug --filter --format --local --node
nodemgr_snooze="--color --debug --duration --filter --format --local --node --server -h --help"
nodemgr_wait="--color --debug --duration --filter --format --local --node --server -h --help"
nodemgr_updatepkg="--color --debug --filter --format --local --node --server -h --help"
nodemgr_updateclumgr="--color --debug --filter --format --local --node --server -h --help"
nodemgr_frozen="--color --debug --filter --format --local --node --server -h --help"
nodemgr_stonith="--color --debug --filter --format --local --node --server -h --help"
nodemgr_rotate_root_pw="--color --cron --debug --filter --format --local --node --server -h --help"

0 comments on commit 2f881db

Please sign in to comment.
You can’t perform that action at this time.