def cim_method_lmi_deletepartition(self, env, object_name, param_partition=None): """ Implements LMI_DiskPartitionConfigurationService.LMI_DeletePartition() Delete partition. """ self.check_instance(object_name) # remember input parameters for Job input_arguments = { 'Partition' : pywbem.CIMProperty(name='Partition', type='reference', value=param_partition), } # check parameters if not param_partition: raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, "Parameter Partition must be specified.") device = self._parse_partition(param_partition) # Check the device is unused storage.assert_unused(self.storage, [device]) # prepare job job = Job( job_manager=self.job_manager, job_name="DELETE PARTITION %s" % (device.path,), input_arguments=input_arguments, method_name='LMI_DeletePartition', affected_elements=[param_partition], owning_element=self._get_instance_name()) job.set_execute_action(self._delete_partition, job, param_partition) outparams = [ pywbem.CIMParameter( name='job', type='reference', value=job.get_name())] ret = self.Values.LMI_DeletePartition\ .Method_Parameters_Checked___Job_Started # enqueue the job self.job_manager.add_job(job) return (ret, outparams)
def cim_method_lmi_createormodifypartition(self, env, object_name, param_partition=None, param_goal=None, param_extent=None, param_size=None): """ Implements LMI_DiskPartitionConfigurationService.LMI_CreateOrModifyPartition() Create new partition on given extent.Partition modification is not yet supported.The implementation will select the best space to fit the partition, with all alignment rules etc. \nIf no Size parameter is provided, the largest possible partition is created.\nIf no Goal is provided and GPT partition is requested, normal partition is created. If no Goal is provided and MS-DOS partition is requested and there is extended partition already on the device, a logical partition is created. If there is no extended partition on the device and there are at most two primary partitions on the device, primary partition is created. If there is no extended partition and three primary partitions already exist, new extended partition with all remaining space is created and a logical partition with requested size is created. Keyword arguments: env -- Provider Environment (pycimmb.ProviderEnvironment) object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method LMI_CreateOrModifyPartition() should be invoked. param_partition -- The input parameter Partition (type REF (pywbem.CIMInstanceName(classname='CIM_GenericDiskPartition', ...)) A reference an existing partition instance to modify or null to request a new partition. param_goal -- The input parameter Goal (type REF (pywbem.CIMInstanceName(classname='LMI_DiskPartitionConfigurationSetting', ...)) Setting to be applied to created/modified partition. param_extent -- The input parameter extent (type REF (pywbem.CIMInstanceName(classname='CIM_StorageExtent', ...)) A reference to the underlying extent the partition is base on. param_size -- The input parameter Size (type pywbem.Uint64) Requested size of the partition to create. If null when creating a partition, the larges possible partition is created.On output, the achieved size is returned. """ self.check_instance(object_name) # remember input parameters for Job input_arguments = { 'Partition' : pywbem.CIMProperty(name='Partition', type='reference', value=param_partition), 'Goal' : pywbem.CIMProperty(name='Goal', type='reference', value=param_goal), 'Extent': pywbem.CIMProperty(name='Extent', type='reference', value=param_extent), 'Size': pywbem.CIMProperty(name='Size', type='uint64', value=param_size), } # check parameters if not param_partition and not param_extent: raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, "Either Partition or extent parameter must be present.") goal = self._parse_goal(param_goal) (device, _unused) = self._parse_extent(param_extent, goal) partition = self._parse_partition(param_partition, device) if partition: # modify job_name = "MODIFY PARTITION %s" % (partition.path,) affected_elements = [param_partition] else: # create job_name = "CREATE PARTITION ON %s" % (device.path,) affected_elements = [param_extent] # prepare job job = Job( job_manager=self.job_manager, job_name=job_name, input_arguments=input_arguments, method_name='LMI_CreateOrModifyPartition', affected_elements=affected_elements, owning_element=self._get_instance_name()) if partition: # modify job.set_execute_action(self._lmi_modify_partition, job, param_partition, goal, param_size) else: # create job.set_execute_action(self._lmi_create_partition, job, param_extent, goal, param_size) outparams = [ pywbem.CIMParameter( name='job', type='reference', value=job.get_name())] ret = self.Values.LMI_CreateOrModifyPartition\ .Method_Parameters_Checked___Job_Started # enqueue the job self.job_manager.add_job(job) return (ret, outparams)
def cim_method_lmi_createfilesystem( self, env, object_name, param_elementname=None, param_goal=None, param_filesystemtype=None, param_inextents=None ): """Implements LMI_FileSystemConfigurationService.LMI_CreateFileSystem() Start a job to create a FileSystem on StorageExtents. If the operation completes successfully and did not require a long-running ConcreteJob, it will return 0. If 4096/0x1000 is returned, a ConcreteJob will be started to create the element. A Reference to the ConcreteJob will be returned in the output parameter Job. If any other value is returned, the job will not be started, and no action will be taken. \nThe parameter TheElement will contain a Reference to the FileSystem if this operation completed successfully. \nThe StorageExtents to use is specified by the InExtents parameter.\nThe desired settings for the FileSystem are specified by the Goal parameter. Goal is an element of class CIM_FileSystemSetting, or a derived class. Unlike CIM standard CreateFileSystem, the parameter is reference to CIM_FileSystemSetting stored on the CIMOM.\nA ResidesOnExtent association is created between the created FileSystem and the StorageExtents used for it. Keyword arguments: env -- Provider Environment (pycimmb.ProviderEnvironment) object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method LMI_CreateFileSystem() should be invoked. param_elementname -- The input parameter ElementName (type unicode) Label of the filesystem being created. If NULL, a system-supplied default name can be used. The value will be stored in the \'ElementName\' property for the created element. param_goal -- The input parameter Goal (type REF (pywbem.CIMInstanceName(classname='CIM_FileSystemSetting', ...)) The requirements for the FileSystem element to maintain. This is an element of class CIM_FileSystemSetting, or a derived class. This allows the client to specify the properties desired for the file system. If NULL, the FileSystemConfigurationService will create default filesystem. param_filesystemtype -- The input parameter FileSystemType (type pywbem.Uint16 self.Values.LMI_CreateFileSystem.FileSystemType) Type of file system to create. When NULL, file system type is retrieved from Goal parameter, which cannot be NULL. param_inextents -- The input parameter InExtents (type REF (pywbem.CIMInstanceName(classname='CIM_StorageExtent', ...)) The StorageExtents on which the created FileSystem will reside. At least one extent must be provided. If the filesystem being created supports more than one storage extent (e.g. btrfs), more extents can be provided. The filesystem will then reside on all of them. Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.LMI_CreateFileSystem) and a list of CIMParameter objects representing the output parameters Output parameters: Job -- (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...)) Reference to the job (may be null if job completed). TheElement -- (type REF (pywbem.CIMInstanceName(classname='CIM_FileSystem', ...)) The newly created FileSystem. Possible Errors: CIM_ERR_ACCESS_DENIED CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized or otherwise incorrect parameters) CIM_ERR_NOT_FOUND (the target CIM Class or instance does not exist in the specified namespace) CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor the invocation request) CIM_ERR_FAILED (some other unspecified error occurred) """ self.check_instance(object_name) # remember input parameters for Job input_arguments = { "ElementName": pywbem.CIMProperty(name="ElementName", type="string", value=param_elementname), "Goal": pywbem.CIMProperty(name="goal", type="reference", value=param_goal), "FileSystemType": pywbem.CIMProperty(name="FileSystemType", type="uint16", value=param_filesystemtype), "InExtents": pywbem.CIMProperty( name="FileSystemType", type="reference", is_array=True, value=param_inextents ), } if not param_inextents: raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, "Parameter InExtents must be specified.") devices = [] for extent in param_inextents: device = self.provider_manager.get_device_for_name(extent) if not device: raise pywbem.CIMError( pywbem.CIM_ERR_INVALID_PARAMETER, "Cannot find block device for InExtent" + extent["DeviceID"] ) devices.append(device) if len(devices) > 1: if param_filesystemtype != self.Values.LMI_CreateFileSystem.FileSystemType.BTRFS: raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, "Selected filesystem supports only one device.") if len(devices) < 1: raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, "At least one InExtent must be specified") # Check the devices are unused storage.assert_unused(self.storage, devices) # Convert devices to strings, so we can survive if some of them # disappears or is changed while the job is queued. device_strings = [device.path for device in devices] goal = self._parse_goal(param_goal, "LMI_FileSystemSetting") # TODO: check that goal has supported values if not goal and not param_filesystemtype: raise pywbem.CIMError( pywbem.CIM_ERR_INVALID_PARAMETER, "Either Goal or FileSystemType parameter must be specified" ) if not param_filesystemtype: # retrieve fs type from the goal param_filesystemtype = int(goal["ActualFileSystemType"]) # convert fstype to Blivet FS types = self.Values.LMI_CreateFileSystem.FileSystemType fstypes = { types.FAT: "vfat", types.FAT16: "vfat", types.FAT32: "vfat", types.XFS: "xfs", types.EXT2: "ext2", types.EXT3: "ext3", types.EXT4: "ext4", types.BTRFS: "btrfs", types.VFAT: "vfat", } fsname = fstypes.get(param_filesystemtype, "None") if not fsname: raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED, "Creation of requested filesystem is not supported.") # create the format fmt = blivet.formats.getFormat(fsname) if not fmt: raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED, "Creation of requested filesystem is not supported.") # prepare job job = Job( job_manager=self.job_manager, job_name="CREATE FS " + fsname + " ON " + device.path, input_arguments=input_arguments, method_name="LMI_CreateFileSystem", affected_elements=param_inextents, owning_element=self._get_instance_name(), ) job.set_execute_action(self._create_fs, job, device_strings, fmt, param_elementname, goal) # prepare output arguments outparams = [pywbem.CIMParameter(name="job", type="reference", value=job.get_name())] retvals = self.Values.LMI_CreateFileSystem # enqueue the job self.job_manager.add_job(job) return (retvals.Method_Parameters_Checked___Job_Started, outparams)
def cim_method_deletefilesystem( self, env, object_name, param_waittime=None, param_thefilesystem=None, param_inuseoptions=None ): """Implements LMI_FileSystemConfigurationService.DeleteFileSystem() Start a job to delete a FileSystem. If the FileSystem cannot be deleted, no action will be taken, and the Return Value will be 4097/0x1001. If the method completed successfully and did not require a long-running ConcreteJob, it will return 0. If 4096/0x1000 is returned, a ConcreteJob will be started to delete the FileSystem. A Reference to the ConcreteJob will be returned in the output parameter Job. Keyword arguments: env -- Provider Environment (pycimmb.ProviderEnvironment) object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method DeleteFileSystem() should be invoked. param_waittime -- The input parameter WaitTime (type pywbem.Uint32) An integer that indicates the time (in seconds) that the provider must wait before deleting this FileSystem. If WaitTime is not zero, the method will create a job, if supported by the provider, and return immediately. If the provider does not support asynchronous jobs, there is a possibility that the client could time-out before the job is completed. The combination of InUseOptions = '4' and WaitTime ='0' (the default) is interpreted as 'Wait (forever) until Quiescence, then Delete Filesystem' and will be performed asynchronously if possible. param_thefilesystem -- The input parameter TheFileSystem (type REF (pywbem.CIMInstanceName(classname='CIM_ManagedElement', ...)) An element or association that uniquely identifies the FileSystem to be deleted. param_inuseoptions -- The input parameter InUseOptions (type pywbem.Uint16 self.Values.DeleteFileSystem.InUseOptions) An enumerated integer that specifies the action to take if the FileSystem is still in use when this request is made. Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.DeleteFileSystem) and a list of CIMParameter objects representing the output parameters Output parameters: Job -- (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...)) Reference to the job (may be null if job completed). Possible Errors: CIM_ERR_ACCESS_DENIED CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized or otherwise incorrect parameters) CIM_ERR_NOT_FOUND (the target CIM Class or instance does not exist in the specified namespace) CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor the invocation request) CIM_ERR_FAILED (some other unspecified error occurred) """ self.check_instance(object_name) # remember input parameters for Job input_arguments = { "WaitTime": pywbem.CIMProperty(name="WaitTime", type="uint32", value=param_waittime), "TheFileSystem": pywbem.CIMProperty(name="TheFileSystem", type="reference", value=param_thefilesystem), "InUseOptions": pywbem.CIMProperty(name="InUseOptions", type="uint16", value=param_inuseoptions), } if param_waittime is not None: raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED, "Parameter WaitTime is not supported.") if param_inuseoptions is not None: raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED, "Parameter InUseOptions is not supported.") if param_thefilesystem is None: raise pywbem.CIMError(pywbem.CIM_ERR_FAILED, "Parameter TheFileSystem must be specified.") provider = self.provider_manager.get_provider_for_format_name(param_thefilesystem) if not provider: raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND, "Unknown TheFileSystem class.") (device, fmt) = provider.get_format_for_name(param_thefilesystem) if not fmt: raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND, "Unknown TheFileSystem instance.") # Check the device is unused storage.assert_unused(self.storage, [device]) # prepare job job = Job( job_manager=self.job_manager, job_name="DELETE FS " + fmt.type + " ON " + fmt.device, input_arguments=input_arguments, method_name="DeleteFileSystem", affected_elements=param_thefilesystem, owning_element=self._get_instance_name(), ) job.set_execute_action(self._delete_fs, job, param_thefilesystem) # prepare output arguments outparams = [pywbem.CIMParameter(name="job", type="reference", value=job.get_name())] retvals = self.Values.LMI_CreateFileSystem # enqueue the job self.job_manager.add_job(job) return (retvals.Method_Parameters_Checked___Job_Started, outparams)
def cim_method_createmount(self, env, object_name, param_goal=None, param_filesystemtype=None, param_mode=None, param_filesystem=None, param_mountpoint=None, param_filesystemspec=None): """Implements LMI_MountConfigurationService.CreateMount() Mounts the specified filesystem to a mountpoint. Keyword arguments: env -- Provider Environment (pycimmb.ProviderEnvironment) object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method CreateMount() should be invoked. param_goal -- The input parameter Goal (type REF (pywbem.CIMInstanceName(classname='LMI_MountedFileSystemSetting', ...)) Desired mount settings. If NULL, defaults will be used. Default mount options are 'rw, suid, dev, exec, auto, nouser, async'. param_filesystemtype -- The input parameter FileSystemType (type unicode) Filesystem type. If NULL, perform a binding mount. If mounting a local filesystem, this parameter has to be in agreement with the FileSystem. param_mode -- The input parameter Mode (type pywbem.Uint16 self.Values.CreateMount.Mode) The mode in which the configuration is to be applied to the MountedFileSystem. IsNext and IsCurrent are properties of LMI_MountedFileSystemElementSettingData, which will be created. Meaning of IsNext and IsCurrent is: IsCurrent = 1: The filesystem will be mounted. IsCurrent = 2: The filesystem will be unmounted. IsNext = 1: A persistent entry will be created (in /etc/fstab). IsNext = 2: The persistent entry will be removed. Mode 1 - IsNext = 1, IsCurrent = 1. Mode 2 - IsNext = 1, IsCurrent not affected. Mode 4 - IsNext = 2, IsCurrent = 2. Mode 5 - IsNext = 2, IsCurrent not affected. Mode 32768 - IsNext not affected, IsCurrent = 1. Mode 32769 - IsNext not affected, IsCurrent = 2. param_filesystem -- The input parameter FileSystem (type REF (pywbem.CIMInstanceName(classname='CIM_FileSystem', ...)) Existing filesystem that should be mounted. If NULL, mount a remote filesystem, or mount a non-device filesystem (e.g. tmpfs). If not NULL, mount a local filesystem. When mounting a local filesystem, the FileSystemType parameter has to agree with the type of FileSystem. param_mountpoint -- The input parameter MountPoint (type unicode) Directory where the mounted filesystem should be attached at. param_filesystemspec -- The input parameter FileSystemSpec (type unicode) Filesystem specification. Specifies the device that should be mounted. Remote filesystems can be specified in their usual form (e.g. 'hostname:/share' for NFS, or '//hostname/share' for CIFS). Non-device filesystems can also be specified (e.g. 'tmpfs' or 'sysfs'). When performing a bind mount, FileSystemSpec is the path to the source directory. Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.CreateMount) and a list of CIMParameter objects representing the output parameters Output parameters: Mount -- (type REF (pywbem.CIMInstanceName(classname='LMI_MountedFileSystem', ...)) Reference to the created LMI_MountedFileSystem instance. Job -- (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...)) Reference to the created job. Possible Errors: CIM_ERR_ACCESS_DENIED CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized or otherwise incorrect parameters) CIM_ERR_NOT_FOUND (the target CIM Class or instance does not exist in the specified namespace) CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor the invocation request) CIM_ERR_FAILED (some other unspecified error occurred) """ # sanity checks self.check_instance(object_name) args = {'FileSystem':param_filesystem, 'Mode':param_mode, 'MountPoint':param_mountpoint, 'FileSystemSpec':param_filesystemspec} self._check_sane_arguments(**args) if param_mode not in [self.MountMethod.Mode.Mode_1, self.MountMethod.Mode.Mode_2, self.MountMethod.Mode.Mode_32768]: raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, "Mode %d without effect." % param_mode) mountopts = self.get_mountopts_from_goal(param_goal) if param_filesystem: # mount a local filesystem; types and specs have to match (device, fmt) = self.get_device_and_format_from_fs(param_filesystem) if fmt.type != param_filesystemtype: raise pywbem.CIMError(pywbem.CIM_ERR_FAILED, "Filesystem types don't match.") if device.path != param_filesystemspec: raise pywbem.CIMError(pywbem.CIM_ERR_FAILED, "Device paths don't match.") else: # mount remote/non-device filesystem raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED, "Can't mount remote/non-device filesystems. Yet...") # remember input parameters for job input_arguments = { 'Goal' : pywbem.CIMProperty(name='Goal', type='reference', value=param_goal), 'FileSystemType' : pywbem.CIMProperty(name='FileSystemType', type='string', value=param_filesystemtype), 'Mode' : pywbem.CIMProperty(name='Mode', type='uint16', value=param_mode), 'FileSystem' : pywbem.CIMProperty(name='FileSystem', type='reference', value=param_filesystem), 'MountPoint' : pywbem.CIMProperty(name='MountPoint', type='string', value=param_mountpoint), 'FileSystemSpec' : pywbem.CIMProperty(name='FileSystemSpec', type='string', value=param_filesystemspec) } # create Job job = Job(job_manager=self.job_manager, job_name="CREATE MOUNT %s %s (t:%s o:%s)" % (param_filesystemspec, param_mountpoint, param_filesystemtype, ",".join(mountopts)), input_arguments=input_arguments, method_name="CreateMount", affected_elements=[param_filesystem], owning_element=self._get_instance_name()) job.set_execute_action(self._create_mount, job, param_mode, param_filesystemtype, param_filesystemspec, param_mountpoint, mountopts) self.job_manager.add_job(job) rval = self.RequestStateChange.Method_Parameters_Checked___Job_Started outparams = [(pywbem.CIMParameter( name='Job', type='reference', value=job.get_name()))] return (rval, outparams)
def cim_method_modifymount(self, env, object_name, param_mount=None, param_mode=None, param_goal=None): """ Implements LMI_MountConfigurationService.ModifyMount() Modifies (remounts) an existing mount. Keyword arguments: env -- Provider Environment (pycimmb.ProviderEnvironment) object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method ModifyMount() should be invoked. param_mount -- The input parameter Mount (type REF (pywbem.CIMInstanceName(classname='LMI_MountedFileSystem', ...)) Reference to the LMI_Mount instance that is being modified. param_mode -- The input parameter Mode (type pywbem.Uint16 self.Values.ModifyMount.Mode) The mode in which the configuration is to be applied to the MountedFileSystem. Mode 1 - IsNext = 1, IsCurrent = 1. Mode 2 - IsNext = 1, IsCurrent not affected. Mode 4 - IsNext = 2, IsCurrent = 2. Mode 5 - IsNext = 2, IsCurrent not affected. Mode 32768 - IsNext not affected, IsCurrent = 1. Mode 32769 - IsNext not affected, IsCurrent = 2. param_goal -- The input parameter Goal (type REF (pywbem.CIMInstanceName(classname='LMI_MountedFileSystemSetting', ...)) Desired mount settings. If NULL, the mount options are not changed. If mount (or an fstab entry) should be performed (created), the appropriate respective MountedFileSystemSetting will be created. Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.ModifyMount) and a list of CIMParameter objects representing the output parameters Output parameters: Job -- (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...)) Reference to the created job. Mount -- (type REF (pywbem.CIMInstanceName(classname='LMI_MountedFileSystem', ...)) Reference to the LMI_Mount instance that is being modified. Possible Errors: CIM_ERR_ACCESS_DENIED CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized or otherwise incorrect parameters) CIM_ERR_NOT_FOUND (the target CIM Class or instance does not exist in the specified namespace) CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor the invocation request) CIM_ERR_FAILED (some other unspecified error occurred) """ # sanity checks self.check_instance(object_name) args = {'Mount':param_mount, 'Mode':param_mode} self._check_sane_arguments(**args) if param_mode not in [self.MountMethod.Mode.Mode_1, self.MountMethod.Mode.Mode_2, self.MountMethod.Mode.Mode_32768]: raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, "Mode %d without effect." % param_mode) mountopts = self.get_mountopts_from_goal(param_goal) # remember input parameters for job input_arguments = { 'Mount' : pywbem.CIMProperty(name='Mount', type='reference', value=param_mount), 'Mode' : pywbem.CIMProperty(name='Mode', type='uint16', value=param_mode), 'Goal' : pywbem.CIMProperty(name='Goal', type='reference', value=param_goal) } mountpoint = param_mount['MountPointPath'] fsspec = param_mount['FileSystemSpec'] # create Job job = Job(job_manager=self.job_manager, job_name="MODIFY MOUNT %s %s (o:%s)" % (fsspec, mountpoint, ",".join(mountopts)), input_arguments=input_arguments, method_name="ModifyMount", affected_elements=[param_mount], owning_element=self._get_instance_name()) job.set_execute_action(self._modify_mount, job, fsspec, mountpoint, mountopts) self.job_manager.add_job(job) rval = self.RequestStateChange.Method_Parameters_Checked___Job_Started outparams.append(pywbem.CIMParameter( name='Job', type='reference', value=job.get_name())) return (rval, outparams)
def cim_method_deletemount(self, env, object_name, param_mount=None, param_mode=None): """Implements LMI_MountConfigurationService.DeleteMount() Unmounts an existing mount. Keyword arguments: env -- Provider Environment (pycimmb.ProviderEnvironment) object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method DeleteMount() should be invoked. param_mount -- The input parameter Mount (type REF (pywbem.CIMInstanceName(classname='LMI_MountedFileSystem', ...)) An existing mount. param_mode -- The input parameter Mode (type pywbem.Uint16 self.Values.DeleteMount.Mode) The mode in which the configuration is to be applied to the MountedFileSystem. Mode 1 - IsNext = 1, IsCurrent = 1. Mode 2 - IsNext = 1, IsCurrent not affected. Mode 4 - IsNext = 2, IsCurrent = 2. Mode 5 - IsNext = 2, IsCurrent not affected. Mode 32768 - IsNext not affected, IsCurrent = 1. Mode 32769 - IsNext not affected, IsCurrent = 2. Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.DeleteMount) and a list of CIMParameter objects representing the output parameters Output parameters: Job -- (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...)) Reference to the created job. Possible Errors: CIM_ERR_ACCESS_DENIED CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized or otherwise incorrect parameters) CIM_ERR_NOT_FOUND (the target CIM Class or instance does not exist in the specified namespace) CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor the invocation request) CIM_ERR_FAILED (some other unspecified error occurred) """ # sanity checks self.check_instance(object_name) args = {'Mount':param_mount, 'Mode':param_mode} self._check_sane_arguments(**args) if param_mode not in [self.MountMethod.Mode.Mode_4, self.MountMethod.Mode.Mode_5, self.MountMethod.Mode.Mode_32769]: raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, "Mode %d without effect." % param_mode) # remember input parameters for job input_arguments = { 'Mount' : pywbem.CIMProperty(name='Mount', type='reference', value=param_mount), 'Mode' : pywbem.CIMProperty(name='Mode', type='uint16', value=param_mode) } # create Job job = Job(job_manager=self.job_manager, job_name="DELETE MOUNT %s" % param_mount['MountPointPath'], input_arguments=input_arguments, method_name="DeleteMount", affected_elements=[param_mount], owning_element=self._get_instance_name()) job.set_execute_action(self._delete_mount, job, param_mode, param_mount['MountPointPath']) self.job_manager.add_job(job) rval = self.RequestStateChange.Method_Parameters_Checked___Job_Started outparams = [(pywbem.CIMParameter( name='Job', type='reference', value=job.get_name()))] return (rval, outparams)