def create_logical_volume(self, params): """Create a logical volume.""" # Only admin users can perform delete. if not reload_object(self.user).is_superuser: raise HandlerPermissionError() node = self.get_object(params) volume_group = VolumeGroup.objects.get(id=params['volume_group_id']) if volume_group.get_node() != node: raise VolumeGroup.DoesNotExist() form = CreateLogicalVolumeForm(volume_group, { 'name': params['name'], 'size': params['size'], }) if not form.is_valid(): raise HandlerError(form.errors) else: logical_volume = form.save() self._update_obj_tags(logical_volume, params) if 'fstype' in params: self.update_blockdevice_filesystem(logical_volume, params.get("fstype"), params.get("mount_point"), params.get("mount_options"))
def delete_volume_group(self, params): node = self._get_node_or_permission_error(params) volume_group_id = params.get('volume_group_id') if volume_group_id is not None: volume_group = VolumeGroup.objects.get(id=volume_group_id) if volume_group.get_node() != node: raise VolumeGroup.DoesNotExist() volume_group.delete()
def delete_volume_group(self, params): # Only admin users can perform delete. if not reload_object(self.user).is_superuser: raise HandlerPermissionError() node = self.get_object(params) volume_group_id = params.get('volume_group_id') if volume_group_id is not None: volume_group = VolumeGroup.objects.get(id=volume_group_id) if volume_group.get_node() != node: raise VolumeGroup.DoesNotExist() volume_group.delete()
def create_logical_volume(self, params): """Create a logical volume.""" node = self._get_node_or_permission_error( params, permission=self._meta.edit_permission) volume_group = VolumeGroup.objects.get(id=params['volume_group_id']) if volume_group.get_node() != node: raise VolumeGroup.DoesNotExist() form = CreateLogicalVolumeForm( volume_group, { 'name': params['name'], 'size': params['size'], }) if not form.is_valid(): raise HandlerError(form.errors) else: logical_volume = form.save() self._update_obj_tags(logical_volume, params) if 'fstype' in params: self.update_blockdevice_filesystem( logical_volume, params.get("fstype"), params.get("mount_point"), params.get("mount_options"))