def get_folder(service_instance, datacenter, placement, base_vm_name=None):
    '''
    Returns a Folder Object

    service_instance
        Service instance object

    datacenter
        Name of the datacenter

    placement
        Placement dictionary

    base_vm_name
        Existing virtual machine name (for cloning)
    '''
    log.trace('Retrieving folder information')
    if base_vm_name:
        vm_object = get_vm_by_property(service_instance, base_vm_name, vm_properties=['name'])
        vm_props = salt.utils.vmware.get_properties_of_managed_object(vm_object, properties=['parent'])
        if 'parent' in vm_props:
            folder_object = vm_props['parent']
        else:
            raise salt.exceptions.VMwareObjectRetrievalError(' '.join([
                'The virtual machine parent',
                'object is not defined']))
    elif 'folder' in placement:
        folder_objects = salt.utils.vmware.get_folders(service_instance, [placement['folder']], datacenter)
        if len(folder_objects) > 1:
            raise salt.exceptions.VMwareMultipleObjectsError(' '.join([
                'Multiple instances are available of the',
                'specified folder {0}'.format(placement['folder'])]))
        folder_object = folder_objects[0]
    elif datacenter:
        datacenter_object = salt.utils.vmware.get_datacenter(service_instance, datacenter)
        dc_props = salt.utils.vmware.get_properties_of_managed_object(datacenter_object, properties=['vmFolder'])
        if 'vmFolder' in dc_props:
            folder_object = dc_props['vmFolder']
        else:
            raise salt.exceptions.VMwareObjectRetrievalError('The datacenter vm folder object is not defined')
    return folder_object
def get_folder ( service_instance , datacenter , placement , base_vm_name = None ) : log . trace ( 'Retrieving folder information' ) if base_vm_name : vm_object = get_vm_by_property ( service_instance , base_vm_name , vm_properties = [ 'name' ] ) vm_props = salt . utils . vmware . get_properties_of_managed_object ( vm_object , properties = [ 'parent' ] ) if 'parent' in vm_props : folder_object = vm_props [ 'parent' ] else : raise salt . exceptions . VMwareObjectRetrievalError ( ' ' . join ( [ 'The virtual machine parent' , 'object is not defined' ] ) ) elif 'folder' in placement : folder_objects = salt . utils . vmware . get_folders ( service_instance , [ placement [ 'folder' ] ] , datacenter ) if len ( folder_objects ) > 1 : raise salt . exceptions . VMwareMultipleObjectsError ( ' ' . join ( [ 'Multiple instances are available of the' , 'specified folder {0}' . format ( placement [ 'folder' ] ) ] ) ) folder_object = folder_objects [ 0 ] elif datacenter : datacenter_object = salt . utils . vmware . get_datacenter ( service_instance , datacenter ) dc_props = salt . utils . vmware . get_properties_of_managed_object ( datacenter_object , properties = [ 'vmFolder' ] ) if 'vmFolder' in dc_props : folder_object = dc_props [ 'vmFolder' ] else : raise salt . exceptions . VMwareObjectRetrievalError ( 'The datacenter vm folder object is not defined' ) return folder_object
Returns a Folder Object

    service_instance
        Service instance object

    datacenter
        Name of the datacenter

    placement
        Placement dictionary

    base_vm_name
        Existing virtual machine name (for cloning)