[node-patches] Change in ovirt-node[master]: pythonize scripts/persist and make it use Config.persist

asegurap at redhat.com asegurap at redhat.com
Mon Jun 23 10:58:34 UTC 2014


Antoni Segura Puimedon has uploaded a new change for review.

Change subject: pythonize scripts/persist and make it use Config.persist
......................................................................

pythonize scripts/persist and make it use Config.persist

Change-Id: I118f981ef1b1f1b663a176a4e64850ad97248497
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
---
M scripts/persist
1 file changed, 20 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/56/29056/1

diff --git a/scripts/persist b/scripts/persist
index a6818da..fb486b8 100755
--- a/scripts/persist
+++ b/scripts/persist
@@ -1,7 +1,7 @@
-#!/bin/bash
+#!/usr/bin/env python2
 #
-# Copyright (C) 2009, Red Hat, Inc.
-# Written by Darryl L. Pierce <dpierce at redhat.com>
+# Copyright (C) 2014, Red Hat, Inc.
+# Written by Antoni Segura Puimedon <asegurap at redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,20 +18,25 @@
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
 #
-# Convenience wrapper to give access to the ovirt_store_config
-# function in /usr/libexec/ovirt-functions
+# Convenience wrapper to give access to ovirt/node/utils/fs persistence
+# facilities
+import argparse
+import sys
 
-. /usr/libexec/ovirt-functions
+from ovirt.node.utils import fs
 
-ME=$(basename "$0")
-warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
-help() { printf "Usage: $ME FILE ...\n
-Copies the specified file to /config and then bindmounts it back at it's original location.
-The file is stored with its full path detail.\n\n" >&2; exit 1;
-}
-die() { warn "$*"; help; exit 1; }
 
-if [ $# -eq 0 ]; then die "You need to specify at least one file."; fi
+def persist():
+    parser = argparse.ArgumentParser(
+        description="Copies the specified file to /config and then bindmounts "
+        "it back at it's original location. The file is stored with its full "
+        "path detail.")
+    parser.add_argument('FILE', nargs='+')
+    arguments = parser.parse_args(sys.argv[1:])
 
-ovirt_store_config $*
+    conf = fs.Config()
+    for path in arguments.FILE:
+        conf.persist(path)
 
+if __name__ == '__main__':
+    sys.exit(persist())


-- 
To view, visit http://gerrit.ovirt.org/29056
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I118f981ef1b1f1b663a176a4e64850ad97248497
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>



More information about the node-patches mailing list