OSDN Git Service

implovement of snapshot operations
authorniwa-hideyuki <niwa.hideyuki@jp.fujitsu.com>
Mon, 10 Nov 2014 06:31:38 +0000 (15:31 +0900)
committerniwa-hideyuki <niwa.hideyuki@jp.fujitsu.com>
Mon, 10 Nov 2014 06:31:38 +0000 (15:31 +0900)
lxcf/Makefile
lxcf/cmd/snapshot-pull [moved from lxcf/cmd/pull with 95% similarity]
lxcf/conf/helpfile.txt
lxcf/doc/lxcf.1
lxcf/lib/lxcf-snapshot-list
lxcf/lib/lxcf-snapshot-pull [moved from lxcf/lib/lxcf-pull with 93% similarity]
lxcf/rest-api/lxcfv1/api_common.py
lxcf/rest-api/lxcfv1/lxcf-api

index 305a1de..dbb085d 100644 (file)
@@ -144,7 +144,7 @@ install_lib_lxcf: .prepare
        install -m 755 lib/lxcf-export-docker $(DESTDIR)$(libdir)/lxcf/lxcf-export-docker
        install -m 755 lib/lxcf-distro $(DESTDIR)$(libdir)/lxcf/lxcf-distro
        install -m 755 lib/lxcf-rename $(DESTDIR)$(libdir)/lxcf/lxcf-rename
-       install -m 755 lib/lxcf-pull $(DESTDIR)$(libdir)/lxcf/lxcf-pull
+       install -m 755 lib/lxcf-snapshot-pull $(DESTDIR)$(libdir)/lxcf/lxcf-snapshot-pull
 
 install_sbin_lxcf: .prepare
        install -d -m 755 $(DESTDIR)$(sbindir)
@@ -200,7 +200,7 @@ install_sbin_lxcf: .prepare
        install -m 755 cmd/rename $(DESTDIR)$(libdir)/lxcf/sbin/rename
        install -m 755 cmd/api $(DESTDIR)$(libdir)/lxcf/sbin/api
        install -m 755 cmd/api-passwd $(DESTDIR)$(libdir)/lxcf/sbin/api-passwd
-       install -m 755 cmd/pull $(DESTDIR)$(libdir)/lxcf/sbin/pull
+       install -m 755 cmd/snapshot-pull $(DESTDIR)$(libdir)/lxcf/sbin/snapshot-pull
 
 install_conf: .prepare
        install -m 644 conf/helpfile.txt $(DESTDIR)$(libdir)/lxcf/helpfile.txt
similarity index 95%
rename from lxcf/cmd/pull
rename to lxcf/cmd/snapshot-pull
index 47cc2cf..e3c3c09 100755 (executable)
@@ -22,7 +22,7 @@ if [ ${EUID:-${UID}} != 0 ]; then
     exit 1
 fi
 
-/usr/lib64/lxcf/lxcf-pull $*
+/usr/lib64/lxcf/lxcf-snapshot-pull $*
 
 exit $?
 
index 59bca1f..03206b6 100644 (file)
@@ -69,9 +69,9 @@ LXCF sub-commands:
        snapshot [ -f ] [ -p PATH ] [ -n SNAPSHOT_IMAGE ] (UUID | NAME)...
        restore  [ -f ] [ -s ] [ -p PATH ] SNAPSHOT_IMAGE
 
-       pull [ -f ] [ -s ] [ -p PASSWORD ] [ -n NEW_SNAP_NAME ] SERVER_NAME:PORT SNAPSHOT_NAME 
+       snapshot-pull [ -f ] [ -s ] [ -p PASSWORD ] [ -n NEW_SNAP_NAME ] SERVER_NAME:PORT SNAPSHOT_NAME 
 
-       snapshot-list [ -p PASSWORD ] [ -n SERVERNAME:PORT ] [ SNAPSHOT_IMAGE ... ]
+       snapshot-list [ -p PASSWORD ] [ -i SERVERNAME:PORT ] [ SNAPSHOT_IMAGE ... ]
        snapshot-erase [ -f ] SNAPSHOT_IMAGE ... 
 
 *** REST API ***
index bfc372c..1e7ad85 100644 (file)
@@ -122,9 +122,9 @@ lxcf \- lxcf framework command
 
 .B     lxcf restore    [ -f ] [ -s ] [-p PATH ] SNAPSHOT_IMAGE
 
-.B     lxcf pull [ -f ] [ -s ] [ -p PASSWORD ] [ -n NEW_SNAP_NAME ] SERVER_NAME:PORT SNAPSHOT_NAME 
+.B     lxcf snapshot-pull [ -f ] [ -s ] [ -p PASSWORD ] [ -n NEW_SNAP_NAME ] SERVER_NAME:PORT SNAPSHOT_NAME 
 
-.B     lxcf snapshot-list [ -p PASSWORD ] [ -n SERVERNAME:PORT ] [ SNAPSHOT_IMAGE ... ] 
+.B     lxcf snapshot-list [ -p PASSWORD ] [ -i SERVERNAME:PORT ] [ SNAPSHOT_IMAGE ... ] 
 
 .B     lxcf snapshot-erase [ -f ] SNAPSHOT_IMAGE ...
 
index 716f6c0..84fa723 100755 (executable)
@@ -26,13 +26,13 @@ if [ ${EUID:-${UID}} != 0 ]; then
 fi
 
 # check options
-FLG_N=0 ; HOSTNAME=""
+FLG_I=0 ; HOSTNAME=""
 FLG_P=0 ; PASSWORD=""
 
 
-while getopts n:p: OPT ; do
+while getopts i:p: OPT ; do
   case $OPT in
-  n) FLG_N=1 ; HOSTNAME=$OPTARG ;;
+  n) FLG_I=1 ; HOSTNAME=$OPTARG ;;
   p) FLG_P=1 ; PASSWORD=$OPTARG ;;
   esac
 done
@@ -57,7 +57,7 @@ if [ x$NOPROXY != x"" ]; then
        PROXYARGS=${PROXYARGS}" --noproxy "$NOPROXY
 fi
 
-if [ $FLG_N -eq 1 ]; then
+if [ $FLG_I -eq 1 ]; then
        if [ $# -gt 0 ]; then
                ARG=`echo $* | sed 's% %/%g'`
        fi
similarity index 93%
rename from lxcf/lib/lxcf-pull
rename to lxcf/lib/lxcf-snapshot-pull
index ba2f138..a34662b 100755 (executable)
@@ -44,7 +44,7 @@ shift $((OPTIND - 1))
 
 # check args
 if [ $# -ne 2 ]; then
-       echo "usage lxcf pull [ -f ] [ -s ] [ -p PASSWORD ] [ -n NEW_SNAP_NAME ] SERVER_NAME:PORT SNAPSHOT_NAME"
+       echo "usage lxcf snapshot-pull [ -f ] [ -s ] [ -p PASSWORD ] [ -n NEW_SNAP_NAME ] SERVER_NAME:PORT SNAPSHOT_NAME"
        exit 1
 fi
 
@@ -97,7 +97,7 @@ fi
 pushd  /opt/lxcf_rep >& /dev/null
 
 RESULT=`curl $PROXYARGS -# $SILENT -F "password=\'${PASSWORD}\'" \
-       -o $NEWNAME http://${SERVERNAME}/lxcfv1/pull_data/${SNAPNAME} | \
+       -o $NEWNAME http://${SERVERNAME}/lxcfv1/snapshot-pull-data/${SNAPNAME} | \
   awk 'BEGIN{f=1}{if ($0~/pre/){f=f*(-1)}else if (f == -1) print}'`
 
 RESNO=`echo $RESULT | awk '{print $1}' | awk -F '=' '{print $2}'`
index a31fb9e..9d5cff7 100755 (executable)
@@ -709,8 +709,9 @@ class api_version(api_common):
     def __init__(self, callcmd):
         super(api_version, self).__init__(callcmd)
 
-# API: pull_data from repository
-class api_pull_data(api_common):
+
+# API: snapshot-pull-data from repository
+class api_snapshot_pull_data(api_common):
     def __init__(self):
         self.messages = "no operation"
         self.status = 0
@@ -740,7 +741,7 @@ class api_pull_data(api_common):
             check = (1, "error: argument is mistaken.")
         elif (check_passwd(password)):
             if (sanity_check(cmdline[1])):
-                check = (0, "OK pull_data "+cmdline[1])
+                check = (0, "OK snapshot-pull-data "+cmdline[1])
             else:
                 errorflg = 1
                 check = (255, "error: sanity error ... "+cmdline[1])
@@ -769,7 +770,7 @@ class api_pull_data(api_common):
         try:
            fp = open(file_path,'rb')
            self.status = 0
-           self.messages = "Pull succeeded. "
+           self.messages = "snapshot-pull-data succeeded. "
            start_response('200 OK', [('Content-Disposition', \
                 'inline; filename="' + file_name + '"'), \
                 ('Content-Length', file_size), \
@@ -781,16 +782,15 @@ class api_pull_data(api_common):
            return self.common_response(environ, start_response, errorflg, result)
 
 
-# API: pull
-def call_pull(cmdline):
-    cmdstr = "pull -s "
+# API: snapshot-pull
+def call_snapshot_pull(cmdline):
+    cmdstr = "snapshot-pull"
     for str in cmdline:
         cmdstr = cmdstr + " " + str
     return cmdstr
 
-class api_pull(api_common):
+class api_snapshot_pull(api_common):
     def __init__(self, callcmd):
-        super(api_pull, self).__init__(callcmd)
-
+        super(api_snapshot_pull, self).__init__(callcmd)
 
 
index dd065cd..116bf4d 100755 (executable)
@@ -98,8 +98,8 @@ path_dirs = { \
 '/lxcfv1/sysgen':api_common.api_sysgen(api_common.call_sysgen), \
 '/lxcfv1/sysgen-n':api_common.api_sysgen_n(api_common.call_sysgen_n), \
 '/lxcfv1/version':api_common.api_version(api_common.call_version), \
-'/lxcfv1/pull_data':api_common.api_pull_data(), \
-'/lxcfv1/pull':api_common.api_pull(api_common.call_pull), \
+'/lxcfv1/snapshot-pull-data':api_common.api_snapshot_pull_data(), \
+'/lxcfv1/snapshot-pull':api_common.api_snapshot_pull(api_common.call_snapshot_pull), \
 }
 
 class ThreadingWsgiServer(ThreadingMixIn, WSGIServer):