Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Mar 14, 2023
1 parent d2f3678 commit 368eaf9
Show file tree
Hide file tree
Showing 22 changed files with 1,278 additions and 170 deletions.
9 changes: 9 additions & 0 deletions service/lib/dinstaller/dbus/storage/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ def initiator_name=(value)
backend.iscsi.initiator.name = value
end

# Whether the initiator name was set via iBFT
#
# @return [Boolean]
def ibft
backend.iscsi.initiator.ibft_name?
end

# Performs an iSCSI discovery
#
# @param address [String] IP address of the iSCSI server
Expand Down Expand Up @@ -191,6 +198,8 @@ def iscsi_delete(path)
dbus_interface ISCSI_INITIATOR_INTERFACE do
dbus_accessor :initiator_name, "s"

dbus_reader :ibft, "b", dbus_name: "IBFT"

dbus_method :Discover,
"in address:s, in port:u, in options:a{sv}, out result:u" do |address, port, options|
busy_while { iscsi_discover(address, port, options) }
Expand Down
4 changes: 4 additions & 0 deletions web/src/assets/styles/blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ section {
gap: var(--spacer-small);
}

section:not(:last-child) {
margin-block-end: var(--spacer-large);
}

section > svg {
grid-area: icon;
}
Expand Down
11 changes: 11 additions & 0 deletions web/src/assets/styles/patternfly-overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,14 @@ table td > .pf-c-empty-state {
.pf-c-data-list {
--pf-c-data-list--BorderTopWidth: 2px;
}

// Toolbar content aligned to the right (alignment prop seems to be ignored)
.pf-c-toolbar__content-section {
justify-content: flex-end;
}

section .pf-c-toolbar {
--stack-gutter: 0;
--pf-c-toolbar--PaddingBottom: 0;
--pf-c-toolbar--PaddingTop: 0;
}
77 changes: 61 additions & 16 deletions web/src/client/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ class ISCSIManager {
this.proxies = {};
}

async getInitiatorIbft() {
const proxy = await this.iscsiInitiatorProxy();
return proxy.IBFT;
}

/**
* Gets the iSCSI initiator name
*
Expand Down Expand Up @@ -296,23 +301,8 @@ class ISCSIManager {
* @property {string} startup
*/
async getNodes() {
const buildNode = (iscsiProxy) => {
const id = path => path.split("/").slice(-1)[0];

return {
id: id(iscsiProxy.path),
target: iscsiProxy.Target,
address: iscsiProxy.Address,
port: iscsiProxy.Port,
interface: iscsiProxy.Interface,
ibft: iscsiProxy.IBFT,
connected: iscsiProxy.Connected,
startup: iscsiProxy.Startup
};
};

const proxy = await this.iscsiNodesProxy();
return Object.values(proxy).map(p => buildNode(p));
return Object.values(proxy).map(this.buildNode);
}

/**
Expand Down Expand Up @@ -342,6 +332,19 @@ class ISCSIManager {
return proxy.Discover(address, port, auth);
}

/**
* Sets the statup status of the connection
*
* @param {ISCSINode} node
* @param {String} startup
*/
async setStartup(node, startup) {
const path = this.nodePath(node);

const proxy = await this.client.proxy(ISCSI_NODE_IFACE, path);
proxy.Startup = startup;
}

/**
* Deletes the given iSCSI node
*
Expand Down Expand Up @@ -401,6 +404,48 @@ class ISCSIManager {
return proxy.Logout();
}

onInitiatorChanged(handler) {
return this.client.onObjectChanged(STORAGE_OBJECT, ISCSI_INITIATOR_IFACE, (changes) => {
const data = {
name: changes.InitiatorName?.v,
ibft: changes.IBFT?.v
};

const filtered = Object.entries(data).filter(([, v]) => v !== undefined);
return handler(Object.fromEntries(filtered));
});
}

async onNodeAdded(handler) {
const proxy = await this.iscsiNodesProxy();
proxy.addEventListener("added", (_, proxy) => handler(this.buildNode(proxy)));
}

async onNodeChanged(handler) {
const proxy = await this.iscsiNodesProxy();
proxy.addEventListener("changed", (_, proxy) => handler(this.buildNode(proxy)));
}

async onNodeRemoved(handler) {
const proxy = await this.iscsiNodesProxy();
proxy.addEventListener("removed", (_, proxy) => handler(this.buildNode(proxy)));
}

buildNode(proxy) {
const id = path => path.split("/").slice(-1)[0];

return {
id: id(proxy.path),
target: proxy.Target,
address: proxy.Address,
port: proxy.Port,
interface: proxy.Interface,
ibft: proxy.IBFT,
connected: proxy.Connected,
startup: proxy.Startup
};
}

/**
* @private
* Proxy for org.opensuse.DInstaller.Storage1.ISCSI.Initiator iface
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/layout/Icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import React from 'react';

// NOTE: "@icons" is an alias to use a shorter path to real icons location.
// Check the tsconfig.json file to see its value.
import Add from "@icons/add.svg?component";
import Apps from "@icons/apps.svg?component";
import Badge from "@icons/badge.svg?component";
import CheckCircle from "@icons/check_circle.svg?component";
Expand Down Expand Up @@ -61,6 +62,7 @@ import Wifi from "@icons/wifi.svg?component";
import Loading from "./three-dots-loader-icon.svg?component";

const icons = {
add: Add,
apps: Apps,
badge: Badge,
check_circle: CheckCircle,
Expand Down
45 changes: 45 additions & 0 deletions web/src/components/storage/ISCSIPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) [2023] SUSE LLC
*
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, contact SUSE LLC.
*
* To contact SUSE LLC about this file by physical or electronic mail, you may
* find current contact information at www.suse.com.
*/

import React from "react";
import { useNavigate } from "react-router-dom";
import { Button } from "@patternfly/react-core";

import { Title as PageTitle, MainActions } from "~/components/layout";
import { InitiatorSection, TargetsSection } from "~/components/storage/iscsi";

export default function ISCSIPage() {
const navigate = useNavigate();

return (
<>
<PageTitle>Storage iSCSI</PageTitle>
<MainActions>
<Button isLarge variant="secondary" form="storage-config" onClick={() => navigate("/storage")}>
Back
</Button>
</MainActions>

<InitiatorSection />
<TargetsSection />
</>
);
}
126 changes: 0 additions & 126 deletions web/src/components/storage/IscsiPage.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion web/src/components/storage/ProposalPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default function ProposalPage() {
};

return (
<Page title="Storage settings" icon="hard_drive">
<Page title="Storage Settings" icon="hard_drive" actionLabel="Back" actionVariant="secondary">
<PageContent />
</Page>
);
Expand Down
Loading

0 comments on commit 368eaf9

Please sign in to comment.