Skip to content

Commit e6ebaf1

Browse files
authored
Merge pull request ceph#59978 from afreen23/nvme-gateway-fix
mgr/dashboard: Fix adding listener and null issue for groups Reviewed-by: Afreen Misbah <[email protected]>
2 parents d1aed64 + 287ff3b commit e6ebaf1

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

src/pybind/mgr/dashboard/controllers/nvmeof.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def create(
140140
trsvcid: int = 4420,
141141
adrfam: int = 0, # IPv4
142142
):
143-
return NVMeoFClient().stub.create_listener(
143+
return NVMeoFClient(traddr=traddr).stub.create_listener(
144144
NVMeoFClient.pb2.create_listener_req(
145145
nqn=nqn,
146146
host_name=host_name,

src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-gateway/nvmeof-gateway.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class NvmeofGatewayComponent {
5252
prop: 'id'
5353
},
5454
{
55-
name: $localize`Host name`,
55+
name: $localize`Hostname`,
5656
prop: 'hostname'
5757
},
5858
{

src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems/nvmeof-subsystems.component.ts

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,8 @@ export class NvmeofSubsystemsComponent extends ListWithDetails implements OnInit
7979
this.router.navigate([BASE_URL, { outlets: { modal: [URLVerbs.CREATE] } }], {
8080
queryParams: { group: this.group }
8181
}),
82-
canBePrimary: (selection: CdTableSelection) => !selection.hasSelection
83-
},
84-
{
85-
name: this.actionLabels.EDIT,
86-
permission: 'update',
87-
icon: Icons.edit,
88-
click: () =>
89-
this.router.navigate([
90-
BASE_URL,
91-
{
92-
outlets: {
93-
modal: [
94-
URLVerbs.EDIT,
95-
this.selection.first().nqn,
96-
this.selection.first().max_namespaces
97-
]
98-
}
99-
}
100-
])
82+
canBePrimary: (selection: CdTableSelection) => !selection.hasSelection,
83+
disable: () => !this.group
10184
},
10285
{
10386
name: this.actionLabels.DELETE,
@@ -114,12 +97,16 @@ export class NvmeofSubsystemsComponent extends ListWithDetails implements OnInit
11497
}
11598

11699
getSubsystems() {
117-
this.nvmeofService
118-
.listSubsystems(this.group)
119-
.subscribe((subsystems: NvmeofSubsystem[] | NvmeofSubsystem) => {
120-
if (Array.isArray(subsystems)) this.subsystems = subsystems;
121-
else this.subsystems = [subsystems];
122-
});
100+
if (this.group) {
101+
this.nvmeofService
102+
.listSubsystems(this.group)
103+
.subscribe((subsystems: NvmeofSubsystem[] | NvmeofSubsystem) => {
104+
if (Array.isArray(subsystems)) this.subsystems = subsystems;
105+
else this.subsystems = [subsystems];
106+
});
107+
} else {
108+
this.subsystems = [];
109+
}
123110
}
124111

125112
deleteSubsystemModal() {

src/pybind/mgr/dashboard/services/nvmeof_client.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class NVMeoFClient(object):
2323
pb2 = pb2
2424

25-
def __init__(self, gw_group: Optional[str] = None):
25+
def __init__(self, gw_group: Optional[str] = None, traddr: Optional[str] = None):
2626
logger.info("Initiating nvmeof gateway connection...")
2727
try:
2828
if not gw_group:
@@ -36,6 +36,23 @@ def __init__(self, gw_group: Optional[str] = None):
3636
f'Unable to retrieve the gateway info: {e}'
3737
)
3838

39+
# While creating listener need to direct request to the gateway
40+
# address where listener is supposed to be added.
41+
if traddr:
42+
gateways_info = NvmeofGatewaysConfig.get_gateways_config()
43+
matched_gateway = next(
44+
(
45+
gateway
46+
for gateways in gateways_info['gateways'].values()
47+
for gateway in gateways
48+
if traddr in gateway['service_url']
49+
),
50+
None
51+
)
52+
if matched_gateway:
53+
self.gateway_addr = matched_gateway.get('service_url')
54+
logger.debug("Gateway address set to: %s", self.gateway_addr)
55+
3956
root_ca_cert = NvmeofGatewaysConfig.get_root_ca_cert(service_name)
4057
if root_ca_cert:
4158
client_key = NvmeofGatewaysConfig.get_client_key(service_name)

0 commit comments

Comments
 (0)