mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
v2v: -o rhv-upload: check whether the cluster exists
In the precheck script, check that the target cluster actually exists.
This will avoid errors when creating the VM after the data copying.
(cherry picked from commit 05e559549d)
This commit is contained in:
@@ -70,4 +70,14 @@ if len(vms) > 0:
|
||||
raise RuntimeError("VM already exists with name ‘%s’, id ‘%s’" %
|
||||
(params['output_name'], vm.id))
|
||||
|
||||
# Check whether the specified cluster exists.
|
||||
clusters_service = system_service.clusters_service()
|
||||
clusters = clusters_service.list(
|
||||
search='name=%s' % params['rhv_cluster'],
|
||||
case_sensitive=True,
|
||||
)
|
||||
if len(clusters) == 0:
|
||||
raise RuntimeError("The cluster ‘%s’ does not exist" %
|
||||
(params['rhv_cluster']))
|
||||
|
||||
# Otherwise everything is OK, exit with no error.
|
||||
|
||||
@@ -39,6 +39,9 @@ class Connection(object):
|
||||
return SystemService()
|
||||
|
||||
class SystemService(object):
|
||||
def clusters_service(self):
|
||||
return ClustersService()
|
||||
|
||||
def data_centers_service(self):
|
||||
return DataCentersService()
|
||||
|
||||
@@ -54,6 +57,10 @@ class SystemService(object):
|
||||
def vms_service(self):
|
||||
return VmsService()
|
||||
|
||||
class ClustersService(object):
|
||||
def list(self, search=None, case_sensitive=False):
|
||||
return ["Default"]
|
||||
|
||||
class DataCentersService(object):
|
||||
def list(self, search=None, case_sensitive=False):
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user