|
|
10436e |
From b37ca67f769749b7b3b5d51e171b7cccfa3b5fd2 Mon Sep 17 00:00:00 2001
|
|
|
10436e |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
10436e |
Date: Mon, 15 Apr 2019 17:24:42 +0200
|
|
|
10436e |
Subject: [PATCH] v2v: -o rhv-upload: check whether the cluster exists
|
|
|
10436e |
|
|
|
10436e |
In the precheck script, check that the target cluster actually exists.
|
|
|
10436e |
This will avoid errors when creating the VM after the data copying.
|
|
|
10436e |
|
|
|
10436e |
(cherry picked from commit 05e559549dab75f17e147f4a4eafbac868a7aa5d)
|
|
|
10436e |
---
|
|
|
10436e |
v2v/rhv-upload-precheck.py | 10 ++++++++++
|
|
|
10436e |
v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py | 7 +++++++
|
|
|
10436e |
2 files changed, 17 insertions(+)
|
|
|
10436e |
|
|
|
10436e |
diff --git a/v2v/rhv-upload-precheck.py b/v2v/rhv-upload-precheck.py
|
|
|
10436e |
index 2798a29dd..b79f91b4a 100644
|
|
|
10436e |
--- a/v2v/rhv-upload-precheck.py
|
|
|
10436e |
+++ b/v2v/rhv-upload-precheck.py
|
|
|
10436e |
@@ -70,4 +70,14 @@ if len(vms) > 0:
|
|
|
10436e |
raise RuntimeError("VM already exists with name ‘%s’, id ‘%s’" %
|
|
|
10436e |
(params['output_name'], vm.id))
|
|
|
10436e |
|
|
|
10436e |
+# Check whether the specified cluster exists.
|
|
|
10436e |
+clusters_service = system_service.clusters_service()
|
|
|
10436e |
+clusters = clusters_service.list(
|
|
|
10436e |
+ search='name=%s' % params['rhv_cluster'],
|
|
|
10436e |
+ case_sensitive=True,
|
|
|
10436e |
+)
|
|
|
10436e |
+if len(clusters) == 0:
|
|
|
10436e |
+ raise RuntimeError("The cluster ‘%s’ does not exist" %
|
|
|
10436e |
+ (params['rhv_cluster']))
|
|
|
10436e |
+
|
|
|
10436e |
# Otherwise everything is OK, exit with no error.
|
|
|
10436e |
diff --git a/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py b/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py
|
|
|
10436e |
index 8d1058d67..cc4224ccd 100644
|
|
|
10436e |
--- a/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py
|
|
|
10436e |
+++ b/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py
|
|
|
10436e |
@@ -39,6 +39,9 @@ class Connection(object):
|
|
|
10436e |
return SystemService()
|
|
|
10436e |
|
|
|
10436e |
class SystemService(object):
|
|
|
10436e |
+ def clusters_service(self):
|
|
|
10436e |
+ return ClustersService()
|
|
|
10436e |
+
|
|
|
10436e |
def data_centers_service(self):
|
|
|
10436e |
return DataCentersService()
|
|
|
10436e |
|
|
|
10436e |
@@ -54,6 +57,10 @@ class SystemService(object):
|
|
|
10436e |
def vms_service(self):
|
|
|
10436e |
return VmsService()
|
|
|
10436e |
|
|
|
10436e |
+class ClustersService(object):
|
|
|
10436e |
+ def list(self, search=None, case_sensitive=False):
|
|
|
10436e |
+ return ["Default"]
|
|
|
10436e |
+
|
|
|
10436e |
class DataCentersService(object):
|
|
|
10436e |
def list(self, search=None, case_sensitive=False):
|
|
|
10436e |
return []
|
|
|
10436e |
--
|
|
|
10436e |
2.26.2
|
|
|
10436e |
|