It would seem its an issue in the logic for _folder_paths.py
def prepend_datacenter_and_folder_type(folder_path=None, datacenter_name=None, folder_type=None):
"""
Formats a folder path so it is absolute, meaning it includes the datacenter name and
type (vm, host, etc) at the start of the path. If path already starts with
the datacenter name, nothing is added.
Eg: rest/of/path -> datacenter name/type/rest/of/path
"""
if not folder_path:
folder_path = ''
folder_path = folder_path.strip('/')
if not datacenter_name:
folder_parts = folder_path.split('/')
if len(folder_parts) > 1 and folder_parts[1] in FOLDER_TYPES:
# this fits the format of a fully qualified path and even though datacenter name was passed in,
# we can attempt to treat it as a fq path and the user will just get an error later on
return folder_path
# the path is too vague to complete without the datacenter name
raise RequiredIfError("Datacenter is a required parameter when using a relative folder path, %s" % folder_path)
if folder_path.startswith(datacenter_name):
return folder_path
if folder_type not in FOLDER_TYPES:
raise ValueError("folder_type %s not in acceptable " % folder_type +
"folder type values %s" % ', '.join(FOLDER_TYPES))
return '/'.join([datacenter_name, folder_type, folder_path]).rstrip('/')
def format_folder_path_as_vm_fq_path(folder_path, datacenter_name):
"""
Formats a VM folder path so it is absolute, meaning it prepends
'datacenter name/vm/' to the path if needed. If path already starts with
the datacenter name, nothing is added.
Eg: rest/of/path -> datacenter name/vm/rest/of/path
"""
return prepend_datacenter_and_folder_type(folder_path, datacenter_name, folder_type='vm')
It seems like it always prepends the expected datacenter name and vm folder unless the provided file path starts with the datacenter.