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