Skip to content

Commit

Permalink
Merge pull request #121 from 45Drives/AutoAddRBDs_MinorFixes
Browse files Browse the repository at this point in the history
Auto add RBDs/ Minor Fixes
  • Loading branch information
joshuaboud authored Nov 26, 2024
2 parents 56cab52 + 8b28844 commit 111b7fe
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 31 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Cockpit File Sharing 4.2.7-1
## Cockpit File Sharing 4.2.8-1

* Fix missing global configuration when [global] missing from net conf registry
* Merge AutoAddRBDs_MinorFixes
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
PLUGIN_SRCS=file-sharing

# For installing to a remote machine for testing with `make install-remote`
REMOTE_TEST_HOST=192.168.45.23
REMOTE_TEST_HOST=192.168.45.21
REMOTE_TEST_USER=root

# Restarts cockpit after install
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ sudo apt install cockpit-file-sharing
### Direct from .deb
Installing this way may work for other versions of Ubuntu and Debian, but it is unsupported. You won't get automatic updates this way.
```bash
curl -LO https://github.com/45Drives/cockpit-file-sharing/releases/download/v4.2.7/cockpit-file-sharing_4.2.7-1focal_all.deb
sudo apt install ./cockpit-file-sharing_4.2.7-1focal_all.deb
curl -LO https://github.com/45Drives/cockpit-file-sharing/releases/download/v4.2.8/cockpit-file-sharing_4.2.8-1focal_all.deb
sudo apt install ./cockpit-file-sharing_4.2.8-1focal_all.deb
```
## Rocky 8
### From 45Drives Repo (Recommended, Rocky 8 only)
Expand All @@ -51,7 +51,7 @@ sudo dnf install cockpit-file-sharing
Installing this way may work for other versions of Rocky/Centos/RHEL/Fedora/etc, but it is unsupported. You won't get automatic updates this way.
```bash
# dnf or yum
sudo dnf install https://github.com/45Drives/cockpit-file-sharing/releases/download/v4.2.7/cockpit-file-sharing-4.2.7-1.el8.noarch.rpm
sudo dnf install https://github.com/45Drives/cockpit-file-sharing/releases/download/v4.2.8/cockpit-file-sharing-4.2.8-1.el8.noarch.rpm
```
## Generic Installation
1. Install Dependencies
Expand Down Expand Up @@ -81,9 +81,9 @@ samba-common-tools
```
2. Download pre-built archive and install
```bash
curl -LO https://github.com/45Drives/cockpit-file-sharing/releases/download/v4.2.7/cockpit-file-sharing_4.2.7_generic.zip
unzip cockpit-file-sharing_4.2.7_generic.zip
cd cockpit-file-sharing_4.2.7_generic
curl -LO https://github.com/45Drives/cockpit-file-sharing/releases/download/v4.2.8/cockpit-file-sharing_4.2.8_generic.zip
unzip cockpit-file-sharing_4.2.8_generic.zip
cd cockpit-file-sharing_4.2.8_generic
# no need to run `make` first, the plugin is pre-built
sudo make install
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{ _("Unit Number") }}
</template>

<InputField type="number" v-model="tempLun.unitNumber" />
<InputField type="number" v-model="unitNumberInput" />
<ValidationResultView v-bind="numberValidationResult" />
</InputLabelWrapper>

Expand Down Expand Up @@ -40,35 +40,36 @@
</template>

<script setup lang="ts">
import { ProcessError, StringToIntCaster } from "@45drives/houston-common-lib";
import {
CardContainer,
InputField,
InputLabelWrapper,
SelectMenu,
useTempObjectStaging,
validationError,
validationSuccess,
ValidationResultView,
wrapActions,
type SelectMenuOption,
ValidationScope,
ToggleSwitchGroup,
ToggleSwitch,
validationSuccess,
wrapActions,
type SelectMenuOption
} from "@45drives/houston-common-ui";
import type { ResultAsync } from "neverthrow";
import { computed, inject, ref, type ComputedRef, type Ref } from "vue";
import { ProcessError } from "@45drives/houston-common-lib";
import type { ISCSIDriver } from "../../../types/drivers/ISCSIDriver";
import type { InitiatorGroup } from "../../../types/InitiatorGroup";
import { LogicalUnitNumber } from "../../../types/LogicalUnitNumber";
import { VirtualDevice } from "../../../types/VirtualDevice";
import { Maybe } from "monet";
const _ = cockpit.gettext;
const props = defineProps<{ initiatorGroup: InitiatorGroup }>();
const emit = defineEmits(["closeEditor"]);
defineExpose({populateNextNumber})
const driver = inject<ResultAsync<ISCSIDriver, ProcessError>>("iSCSIDriver")!;
const devices = inject<Ref<VirtualDevice[]>>("virtualDevices")!;
Expand All @@ -80,6 +81,23 @@ const deviceOptions: ComputedRef<SelectMenuOption<string>[]> = computed(() =>
const newLun = ref<LogicalUnitNumber>(LogicalUnitNumber.empty());
const { tempObject: tempLun, modified: lunModified, resetChanges: resetChangesLun } = useTempObjectStaging(newLun);
populateNextNumber();
const unitNumberInput = computed<string>({
get: () =>
Maybe.fromUndefined(tempLun.value.unitNumber)
.cata(
() => "",
(unitNumberInput) => unitNumberInput.toString()
),
set: (newUnitNumber) =>
Maybe.fromEmpty(newUnitNumber)
.flatMap(StringToIntCaster())
.cata(
() => tempLun.value.unitNumber = 0,
(value) => tempLun.value.unitNumber = value,
)
});
const handleClose = () => {
emit("closeEditor");
Expand All @@ -100,6 +118,18 @@ const createLun = () => {
);
};
function populateNextNumber() {
let nextNumber = 0;
const existingNumbers = props.initiatorGroup.logicalUnitNumbers.map((lun) => lun.unitNumber);
while (existingNumbers.includes(nextNumber)) {
nextNumber += 1;
}
tempLun.value.unitNumber = nextNumber;
}
const validationScope = new ValidationScope();
const { validationResult: numberValidationResult } = validationScope.useValidator(() => {
Expand All @@ -111,7 +141,9 @@ const { validationResult: numberValidationResult } = validationScope.useValidato
return validationError("The Logical Unit Number to be a positive number.");
}
if (props.initiatorGroup.logicalUnitNumbers.find((lun) => lun.unitNumber === tempLun.value.unitNumber) !== undefined) {
const existingNumbers = props.initiatorGroup.logicalUnitNumbers.map((lun) => lun.unitNumber);
if (existingNumbers.includes(tempLun.value.unitNumber as number)) {
return validationError("This Unit Number is already assigned.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
>
<div class="card">
<LogicalUnitNumberEditor
ref="logicalUnitNumberEditor"
:initiatorGroup="initiatorGroup"
@close-editor="
() => {
Expand All @@ -33,7 +34,7 @@
<th scope="col">Number</th>
<th scope="col" class="flex flex-row justify-end">
<span class="sr-only">Delete</span>
<button @click="showEditor = !showEditor">
<button @click="toggleEditor">
<PlusIcon class="size-icon icon-default" />
</button>
</th>
Expand Down Expand Up @@ -74,6 +75,8 @@ const driver = inject<ResultAsync<ISCSIDriver, ProcessError>>("iSCSIDriver")!;
const devices = inject<Ref<VirtualDevice[]>>("virtualDevices");
const logicalUnitNumberEditor = ref<InstanceType<typeof LogicalUnitNumberEditor>>();
if (devices === undefined) {
throw new Error("Virtual Device list is null");
}
Expand All @@ -90,6 +93,13 @@ const refreshTable = () => {
});
};
const toggleEditor = () => {
showEditor.value = !showEditor.value;
if (logicalUnitNumberEditor.value !== undefined)
logicalUnitNumberEditor.value.populateNextNumber();
}
const actions = wrapActions({ refreshTable: refreshTable });
actions.refreshTable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<script setup lang="ts">
import { Pool } from "@/tabs/iSCSI/types/cluster/Pool";
import type { ISCSIDriverClusteredServer } from "@/tabs/iSCSI/types/drivers/ISCSIDriverClusteredServer";
import { VirtualDevice } from "@/tabs/iSCSI/types/VirtualDevice";
import type { ProcessError } from "@45drives/houston-common-lib";
import {
CardContainer,
Expand All @@ -99,7 +100,7 @@ const _ = cockpit.gettext;
const emit = defineEmits<{
(e: "close"): void;
(e: "update"): void;
(e: "created", value: VirtualDevice): void;
}>();
const driver = inject<ResultAsync<ISCSIDriverClusteredServer, ProcessError>>("iSCSIDriver")!;
Expand Down Expand Up @@ -157,8 +158,8 @@ const createDevice = () => {
return ok(yield * rbdManager.createLogicalVolumeFromRadosBlockDevices(tempDeviceOptions.value.name!, `${tempDeviceOptions.value.name!}_VG`, createdRBDs).safeUnwrap());
}))
.map(() => {
emit('update');
.map((logicalVolume) => {
emit('created', logicalVolume);
resetChanges();
});
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
>
<div class="card">
<RBDDeviceCreationScreen
@update="() => {
showAddRBD = false;
actions.fetchDevices();
}"
@created="selectVirtualDevice"
@close="showAddRBD = false"/>
</div>
</div>
Expand Down Expand Up @@ -111,6 +108,7 @@ const fetchDevices = () => {
}
const selectVirtualDevice = (device: VirtualDevice) => {
showAddRBD.value = false;
emit('selectDevice', device)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@
const addFromRBDManager = (device: VirtualDevice) => {
showRBDManager.value = false;
return driver.andThen((driver) => driver.addVirtualDevice(device))
.map(() => handleClose())
if (virtualDevices.value.find((existingDevice) => (existingDevice.deviceName === device.deviceName)) === undefined) {
return driver.andThen((driver) => driver.addVirtualDevice(device))
.map(() => handleClose())
}
return okAsync(undefined);
}
const handleClose = () => {
Expand Down
11 changes: 11 additions & 0 deletions file-sharing/src/tabs/nfs/nfs-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface INFSManager {
removeExport(nfsExport: NFSExport): ResultAsync<NFSExport, ProcessError | ParsingError>;
exportConfig(): ResultAsync<string, ProcessError>;
importConfig(config: string): ResultAsync<this, ProcessError>;
onExportsFileChanged(callback: () => void): { remove: () => void };
}

export class NFSManagerSingleServer implements INFSManager {
Expand Down Expand Up @@ -94,6 +95,12 @@ export class NFSManagerSingleServer implements INFSManager {
)
.map(() => this);
}

onExportsFileChanged(callback: () => void) {
return cockpit
.file(this.exportsFile.path, { host: this.server.host })
.watch((_1, _2) => callback(), { read: false });
}
}

export class NFSManagerClustered implements INFSManager {
Expand Down Expand Up @@ -136,6 +143,10 @@ export class NFSManagerClustered implements INFSManager {
importConfig(config: string): ResultAsync<this, ProcessError> {
return ResultAsync.combine(this.managers.map((m) => m.importConfig(config))).map(() => this);
}

onExportsFileChanged(callback: () => void): { remove: () => void } {
return this.getterManager.onExportsFileChanged(callback);
}
}

export function getNFSManager(
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "cockpit-file-sharing",
"title": "Cockpit File Sharing",
"prerelease": false,
"version": "4.2.7",
"version": "4.2.8",
"buildVersion": "1",
"author": "Josh Boudreau <jboudreau@45drives.com>",
"url": "https://github.com/45Drives/cockpit-file-sharing",
Expand Down Expand Up @@ -65,7 +65,7 @@
],
"changelog": {
"urgency": "medium",
"version": "4.2.7",
"version": "4.2.8",
"buildVersion": "1",
"ignore": [],
"date": null,
Expand Down
5 changes: 4 additions & 1 deletion packaging/el8/main.spec
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ make DESTDIR=%{buildroot} install
/usr/share/cockpit/file-sharing/*

%changelog
* Tue Nov 26 2024 Joshua Boudreau <jboudreau@45drives.com> 4.2.8-1
- Merge AutoAddRBDs_MinorFixes
* Mon Nov 25 2024 Joshua Boudreau <jboudreau@45drives.com> 4.2.7-1
- Fix missing global configuration when [global] missing from net conf registry
* Fri Nov 15 2024 Joshua Boudreau <jboudreau@45drives.com> 4.2.6-1
- Fix bug where only first instance of was inspected while looking for
- Fix bug where only first instance of "include = " was inspected while looking for "include = registry"
- Harden getting list of clustered servers
* Thu Oct 31 2024 Josh Boudreau <jboudreau@45drives.com> 4.2.5-2
- iscsi release
* Mon Oct 28 2024 Brandon Kelly <brkelly@45drives.com> 4.2.5-1
Expand Down
9 changes: 8 additions & 1 deletion packaging/focal/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
cockpit-file-sharing (4.2.8-1focal) focal; urgency=medium

* Merge AutoAddRBDs_MinorFixes

-- Joshua Boudreau <jboudreau@45drives.com> Tue, 26 Nov 2024 08:11:58 -0400

cockpit-file-sharing (4.2.7-1focal) focal; urgency=medium

* Fix missing global configuration when [global] missing from net conf registry
Expand All @@ -6,7 +12,8 @@ cockpit-file-sharing (4.2.7-1focal) focal; urgency=medium

cockpit-file-sharing (4.2.6-1focal) focal; urgency=medium

* Fix bug where only first instance of was inspected while looking for
* Fix bug where only first instance of "include = " was inspected while looking for "include = registry"
* Harden getting list of clustered servers

-- Joshua Boudreau <jboudreau@45drives.com> Fri, 15 Nov 2024 12:22:25 -0400

Expand Down

0 comments on commit 111b7fe

Please sign in to comment.