Change in vdsm[master]: v2v: refactor create command
shavivi at redhat.com
shavivi at redhat.com
Tue Jun 9 07:00:52 UTC 2015
Shahar Havivi has uploaded a new change for review.
Change subject: v2v: refactor create command
......................................................................
v2v: refactor create command
When other inputs will be introduced (such as files and ova) there is
need to create a different input for virt-v2v command.
This patch make _create_command as function variable and each new
factory method will introduce its own _create_command.
Change-Id: I4b9edabb2ec324693432ff71d2a8e682afbe3a35
Signed-off-by: Shahar Havivi <shaharh at redhat.com>
---
M vdsm/v2v.py
1 file changed, 19 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/42066/1
diff --git a/vdsm/v2v.py b/vdsm/v2v.py
index b7008fe..18cc9bc 100644
--- a/vdsm/v2v.py
+++ b/vdsm/v2v.py
@@ -283,12 +283,12 @@
TERM_DELAY = 30
PROC_WAIT_TIMEOUT = 30
- def __init__(self, vminfo, irs):
+ def __init__(self, vminfo, job_id, irs):
'''
- Don't use this constructor for initialization,
- use the factory methods instead.
+ do not use directly, use a factory method instead!
'''
self._vminfo = vminfo
+ self._id = job_id
self._irs = irs
self._status = STATUS.STARTING
@@ -299,14 +299,22 @@
self._aborted = False
self._prepared_volumes = []
+ self._uri = None
+ self._username = None
+ self._password = None
+ self._passwd_file = None
+ self._create_command = None
+
@classmethod
- def from_libvirt(self, uri, username, password, vminfo, job_id, irs):
- self._uri = uri
- self._username = username
- self._password = password
- self._id = job_id
- self._passwd_file = os.path.join(_V2V_DIR, "%s.tmp" % job_id)
- return ImportVm(vminfo, irs)
+ def from_libvirt(cls, uri, username, password, vminfo, job_id, irs):
+ obj = cls(vminfo, job_id, irs)
+
+ obj._uri = uri
+ obj._username = username
+ obj._password = password
+ obj._passwd_file = os.path.join(_V2V_DIR, "%s.tmp" % job_id)
+ obj._create_command = cls._from_libvirt_command
+ return obj
def start(self):
t = threading.Thread(target=self._run)
@@ -406,7 +414,7 @@
raise RuntimeError("Job %r got unexpected parser event: %s" %
(self._id, event))
- def _create_command(self):
+ def _from_libvirt_command(self):
cmd = [_VIRT_V2V.cmd,
'-ic', self._uri,
'-o', 'vdsm',
--
To view, visit https://gerrit.ovirt.org/42066
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4b9edabb2ec324693432ff71d2a8e682afbe3a35
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shahar Havivi <shavivi at redhat.com>
More information about the vdsm-patches
mailing list