[CRIU] [PATCH 5/5] p.haul: reform project to simplify installation

nspiridonov nspiridonov at odin.com
Thu Apr 30 05:10:24 PDT 2015


From: Nikita Spiridonov <nspiridonov at odin.com>

To simplify installation and packaging move all python logic to
phaul subdirectory. Add setup.py and phaul/__init__.py files needed
for packaging. These changes pack greater part of logic into
'phaul' python package that can be installed using setup tools and
used with the help of import directive.

Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
---
 .gitignore                                     |    1 +
 p.haul                                         |   14 +++++++-------
 p.haul-service                                 |    8 ++++----
 criu_api.py => phaul/criu_api.py               |    0
 fs_haul_shared.py => phaul/fs_haul_shared.py   |    0
 fs_haul_subtree.py => phaul/fs_haul_subtree.py |    0
 images.py => phaul/images.py                   |    0
 mstats.py => phaul/mstats.py                   |    0
 p_haul_cgroup.py => phaul/p_haul_cgroup.py     |    0
 p_haul_iters.py => phaul/p_haul_iters.py       |    0
 p_haul_lxc.py => phaul/p_haul_lxc.py           |    0
 p_haul_ovz.py => phaul/p_haul_ovz.py           |    0
 p_haul_pid.py => phaul/p_haul_pid.py           |    0
 p_haul_service.py => phaul/p_haul_service.py   |    0
 p_haul_type.py => phaul/p_haul_type.py         |    0
 p_haul_vz.py => phaul/p_haul_vz.py             |    0
 util.py => phaul/util.py                       |    0
 xem_rpc.py => phaul/xem_rpc.py                 |    0
 setup.py                                       |    8 ++++++++
 19 files changed, 20 insertions(+), 11 deletions(-)
 create mode 100644 phaul/__init__.py
 rename criu_api.py => phaul/criu_api.py (100%)
 rename fs_haul_shared.py => phaul/fs_haul_shared.py (100%)
 rename fs_haul_subtree.py => phaul/fs_haul_subtree.py (100%)
 rename images.py => phaul/images.py (100%)
 rename mstats.py => phaul/mstats.py (100%)
 rename p_haul_cgroup.py => phaul/p_haul_cgroup.py (100%)
 rename p_haul_iters.py => phaul/p_haul_iters.py (100%)
 rename p_haul_lxc.py => phaul/p_haul_lxc.py (100%)
 rename p_haul_ovz.py => phaul/p_haul_ovz.py (100%)
 rename p_haul_pid.py => phaul/p_haul_pid.py (100%)
 rename p_haul_service.py => phaul/p_haul_service.py (100%)
 rename p_haul_type.py => phaul/p_haul_type.py (100%)
 rename p_haul_vz.py => phaul/p_haul_vz.py (100%)
 rename util.py => phaul/util.py (100%)
 rename xem_rpc.py => phaul/xem_rpc.py (100%)
 create mode 100644 setup.py

diff --git a/.gitignore b/.gitignore
index 941b808..739cb45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+build/
 *.pyc
 rpc_pb2.py
 stats_pb2.py
diff --git a/p.haul b/p.haul
index 859ba18..415c591 100755
--- a/p.haul
+++ b/p.haul
@@ -1,10 +1,10 @@
 #!/usr/bin/env python
 import sys
 import argparse
-import p_haul_iters as ph_iters
-import images
-import criu_api
-import xem_rpc
+import phaul.p_haul_iters as ph_iters
+import phaul.images as ph_images
+import phaul.criu_api as ph_criu_api
+import phaul.xem_rpc as ph_xem_rpc
 
 # Usage idea
 # p.haul <type> <id> <destination>
@@ -22,13 +22,13 @@ parser = argparse.ArgumentParser("Process HAULer")
 parser.add_argument("type", help = "Type of hat to haul, e.g. ovz")
 parser.add_argument("id", help = "ID of what to haul")
 parser.add_argument("to", help = "IP where to haul")
-parser.add_argument("-v", help = "Verbosity level", default = criu_api.def_verb, type = int, dest = "verbose")
+parser.add_argument("-v", help = "Verbosity level", default = ph_criu_api.def_verb, type = int, dest = "verbose")
 parser.add_argument("--keep-images", help = "Keep images after migration", default = False, action = 'store_true')
 parser.add_argument("--dst-rpid", help = "Write pidfile on restore", default = None)
-parser.add_argument("--img-path", help = "Dirctory where to put images", default = images.def_path)
+parser.add_argument("--img-path", help = "Dirctory where to put images", default = ph_images.def_path)
 parser.add_argument("--pid-root", help = "Path to tree's FS root")
 parser.add_argument("--force", help = "Don't do any sanity (CPU compat) checks", default = False, action = 'store_true')
-parser.add_argument("--port", help = "Port where to haul", type = int, default = xem_rpc.rpc_port)
+parser.add_argument("--port", help = "Port where to haul", type = int, default = ph_xem_rpc.rpc_port)
 
 args = vars(parser.parse_args())
 
diff --git a/p.haul-service b/p.haul-service
index 0fd52c2..210b7da 100755
--- a/p.haul-service
+++ b/p.haul-service
@@ -1,14 +1,14 @@
 #!/usr/bin/env python
 
 import signal
-import xem_rpc
-import p_haul_service as ph_srv
 import argparse
+import phaul.xem_rpc as ph_xem_rpc
+import phaul.p_haul_service as ph_srv
 
 if __name__ == "__main__":
 	parser = argparse.ArgumentParser("Process HAULer service server")
 	parser.add_argument("--bind-addr", help = "IP to bind to", type = str, default = "0.0.0.0")
-	parser.add_argument("--bind-port", help = "Port to bind to", type = int, default = xem_rpc.rpc_port)
+	parser.add_argument("--bind-port", help = "Port to bind to", type = int, default = ph_xem_rpc.rpc_port)
 
 	args = vars(parser.parse_args())
 
@@ -20,7 +20,7 @@ if __name__ == "__main__":
 		sfd.close()
 
 	print "Starting p.haul rpyc service"
-	t = xem_rpc.rpc_threaded_srv(ph_srv.phaul_service, host)
+	t = ph_xem_rpc.rpc_threaded_srv(ph_srv.phaul_service, host)
 
 	# FIXME: Setup stop handlers
 	sfd = t.get_stop_fd()
diff --git a/phaul/__init__.py b/phaul/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/criu_api.py b/phaul/criu_api.py
similarity index 100%
rename from criu_api.py
rename to phaul/criu_api.py
diff --git a/fs_haul_shared.py b/phaul/fs_haul_shared.py
similarity index 100%
rename from fs_haul_shared.py
rename to phaul/fs_haul_shared.py
diff --git a/fs_haul_subtree.py b/phaul/fs_haul_subtree.py
similarity index 100%
rename from fs_haul_subtree.py
rename to phaul/fs_haul_subtree.py
diff --git a/images.py b/phaul/images.py
similarity index 100%
rename from images.py
rename to phaul/images.py
diff --git a/mstats.py b/phaul/mstats.py
similarity index 100%
rename from mstats.py
rename to phaul/mstats.py
diff --git a/p_haul_cgroup.py b/phaul/p_haul_cgroup.py
similarity index 100%
rename from p_haul_cgroup.py
rename to phaul/p_haul_cgroup.py
diff --git a/p_haul_iters.py b/phaul/p_haul_iters.py
similarity index 100%
rename from p_haul_iters.py
rename to phaul/p_haul_iters.py
diff --git a/p_haul_lxc.py b/phaul/p_haul_lxc.py
similarity index 100%
rename from p_haul_lxc.py
rename to phaul/p_haul_lxc.py
diff --git a/p_haul_ovz.py b/phaul/p_haul_ovz.py
similarity index 100%
rename from p_haul_ovz.py
rename to phaul/p_haul_ovz.py
diff --git a/p_haul_pid.py b/phaul/p_haul_pid.py
similarity index 100%
rename from p_haul_pid.py
rename to phaul/p_haul_pid.py
diff --git a/p_haul_service.py b/phaul/p_haul_service.py
similarity index 100%
rename from p_haul_service.py
rename to phaul/p_haul_service.py
diff --git a/p_haul_type.py b/phaul/p_haul_type.py
similarity index 100%
rename from p_haul_type.py
rename to phaul/p_haul_type.py
diff --git a/p_haul_vz.py b/phaul/p_haul_vz.py
similarity index 100%
rename from p_haul_vz.py
rename to phaul/p_haul_vz.py
diff --git a/util.py b/phaul/util.py
similarity index 100%
rename from util.py
rename to phaul/util.py
diff --git a/xem_rpc.py b/phaul/xem_rpc.py
similarity index 100%
rename from xem_rpc.py
rename to phaul/xem_rpc.py
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..075daf4
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,8 @@
+from distutils.core import setup
+
+
+setup(name='phaul',
+      description='Tool to live-migrate containers and processes',
+      license='GPLv2',
+      packages=['phaul'],
+      )
-- 
1.7.1



More information about the CRIU mailing list