Skip to content

Commit

Permalink
try to get ceph layout pools with ceph.client.samba.keyring first
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaboud committed Jun 27, 2022
1 parent e8a8ab8 commit 5c6ee93
Showing 1 changed file with 69 additions and 17 deletions.
86 changes: 69 additions & 17 deletions file-sharing/src/components/SambaManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,61 @@ If not, see <https://www.gnu.org/licenses/>.
-->

<template>
<div class="centered-column p-well space-y-well" :class="{'cursor-wait': processing}">
<SambaGlobalManagement :globalConfig="globalConfig" :processing="processing" @startProcessing="processing++"
@stopProcessing="processing--" />
<SambaShareManagement :shares="shares" @refreshShares="refresh" :groups="groups" :users="users"
:cephLayoutPools="cephLayoutPools" :ctdbHosts="ctdbHosts" :parentProcessing="processing"
<div
class="centered-column p-well space-y-well"
:class="{ 'cursor-wait': processing }"
>
<SambaGlobalManagement
:globalConfig="globalConfig"
:processing="processing"
@startProcessing="processing++"
@stopProcessing="processing--"
/>
<SambaShareManagement
:shares="shares"
@refreshShares="refresh"
:groups="groups"
:users="users"
:cephLayoutPools="cephLayoutPools"
:ctdbHosts="ctdbHosts"
:parentProcessing="processing"
@appendShareToList="share => shares = [...shares, share].sort((a, b) => a.name.localeCompare(b.name))"
@removeShareFromList="share => shares = shares.filter((a) => a !== share)" />
@removeShareFromList="share => shares = shares.filter((a) => a !== share)"
/>
<div class="card">
<div class="card-header flex flex-row space-x-2 items-center">
<div class="text-header">Import/Export Config</div>
<LoadingSpinner v-if="processing" class="size-icon" />
<LoadingSpinner
v-if="processing"
class="size-icon"
/>
</div>
<div class="card-body button-group-row">
<input @change="importConfig" type="file" id="file-upload" hidden />
<button @click="uploadConfig" class="btn btn-primary">Import</button>
<button @click="exportConfig" class="btn btn-primary">Export</button>
<input
@change="importConfig"
type="file"
id="file-upload"
hidden
/>
<button
@click="uploadConfig"
class="btn btn-primary"
>Import</button>
<button
@click="exportConfig"
class="btn btn-primary"
>Export</button>
</div>
</div>
</div>
<ModalPopup :showModal="confirmationModal.showModal" @apply="confirmationModal.applyCallback"
@cancel="confirmationModal.cancelCallback" applyDangerous applyText="Yes"
:headerText="confirmationModal.headerText">
<ModalPopup
:showModal="confirmationModal.showModal"
@apply="confirmationModal.applyCallback"
@cancel="confirmationModal.cancelCallback"
applyDangerous
applyText="Yes"
:headerText="confirmationModal.headerText"
>
<template #icon>
<ExclamationCircleIcon class="size-icon-xl icon-danger shrink-0" />
</template>
Expand Down Expand Up @@ -213,9 +246,28 @@ export default {

const getCephLayoutPools = async () => {
try {
const cephFsStatus = JSON.parse((await useSpawn(['ceph', 'fs', 'status', '--format=json'], { superuser: 'try' }).promise()).stdout);
cephLayoutPools.value = cephFsStatus.pools.filter(pool => pool.type === 'data').map(pool => pool.name);
} catch (state) { /* not ceph */ }
const cephFsStatus = JSON.parse((await useSpawn([
'ceph',
'fs',
'status',
'--keyring=/etc/ceph/ceph.client.samba.keyring',
'-n',
'client.samba',
'--format=json',
], { superuser: 'try' }).promise()).stdout);
cephLayoutPools.value = cephFsStatus.pools
.filter(pool => pool.type === 'data')
.map(pool => pool.name);
} catch {
try {
const cephFsStatus = JSON.parse((await useSpawn([
'ceph', 'fs', 'status', '--format=json'
], { superuser: 'try' }).promise()).stdout);
cephLayoutPools.value = cephFsStatus.pools
.filter(pool => pool.type === 'data')
.map(pool => pool.name);
} catch { /* assuming not ceph */ }
}
}

const refresh = async () => {
Expand Down Expand Up @@ -290,7 +342,7 @@ export default {
watchHandles.push(cockpit.file('/etc/group', { superuser: 'try' }).watch(() => getGroupList(), { read: false }));
watchHandles.push(cockpit.file('/etc/passwd', { superuser: 'try' }).watch(() => getUserList(), { read: false }));
watchHandles.push(cockpit.file('/etc/ctdb/nodes', { superuser: 'try' }).watch(() => getCtdbHosts(), { read: false }));

onBeforeUnmount(() => watchHandles.map(handle => handle?.remove?.()));

return {
Expand Down

0 comments on commit 5c6ee93

Please sign in to comment.