]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
add new cli teuthology-reimage-fog to reimage FOG provisioned nodes without actually
authorVasu Kulkarni <vasu@redhat.com>
Thu, 24 Jan 2019 21:47:58 +0000 (13:47 -0800)
committerVasu Kulkarni <vasu@redhat.com>
Thu, 14 Feb 2019 20:28:12 +0000 (12:28 -0800)
locking the nodes.

Signed-off-by: Vasu Kulkarni <vasu@redhat.com>
scripts/reimage_fog.py [new file with mode: 0644]
setup.py
teuthology/misc.py

diff --git a/scripts/reimage_fog.py b/scripts/reimage_fog.py
new file mode 100644 (file)
index 0000000..0d260f5
--- /dev/null
@@ -0,0 +1,22 @@
+import docopt
+
+from teuthology.misc import reimage_fog
+import sys
+
+doc = """
+usage: teuthology-reimage-fog -h
+       teuthology-reimage-fog --nodes node1,node2 --os-type distro --os-version version
+
+Reimage nodes using FOG without locking the nodes
+
+standard arguments:
+  -h, --help                           Show this help message and exit
+  --nodes node1,node2                  List of nodes to reimage
+  --os-type <os-type>                  Distribution type eg: rhel, ubuntu
+  --os-version <os-version>            OS version eg: 7.6, 16.04 etc
+"""
+
+
+def main(argv=sys.argv[1:]):
+    args = docopt.docopt(doc, argv=argv)
+    reimage_fog(args)
index 2553028b5d4000c8f543ab4caac3471de62d248d..b5dd3170cc3b3190554a6ce7eeb99524ec7766fe 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -116,6 +116,7 @@ setup(
             'teuthology-prune-logs = scripts.prune_logs:main',
             'teuthology-describe-tests = scripts.describe_tests:main',
             'teuthology-gencov = scripts.gencov:main',
+            'teuthology-reimage-fog = scripts.reimage_fog:main'
             ],
         },
 
index 53d453f1f6bf0b282976cdeb451baeefb8129119..f46e387215b3934cea43ea32b47bc18a4ec669a6 100644 (file)
@@ -20,6 +20,8 @@ import yaml
 import json
 import re
 import pprint
+import parallel
+
 
 from netaddr.strategy.ipv4 import valid_str as _is_ipv4
 from netaddr.strategy.ipv6 import valid_str as _is_ipv6
@@ -1387,6 +1389,21 @@ def is_in_dict(searchkey, searchval, d):
         return searchval == val
 
 
+def reimage_fog(args):
+    """
+    Reimage FOG nodes with options specified
+    """
+    machines = args['--nodes']
+    nodes = machines.rstrip(',').split(',')
+    ctx = argparse.Namespace()
+    ctx.os_type = args['--os-type']
+    ctx.os_version = args['--os-version']
+    from teuthology.provision import reimage
+    with parallel() as p:
+        for node in nodes:
+            p.spawn(reimage, ctx, node)
+
+
 def sh(command, log_limit=1024):
     """
     Run the shell command and return the output in ascii (stderr and