Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update show maps to use an initiator view return object instead … #53

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions api/mc-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/hosts-viewObject'
$ref: '#/components/schemas/initiator-viewObject'
'401':
description: Unauthorized
content:
Expand Down Expand Up @@ -3908,7 +3908,7 @@ components:
volume-serial:
type: string
description: Unique serial number for the volume
hosts-viewResource:
initiator-viewResource:
type: array
minItems: 1
maxItems: 1024
Expand All @@ -3919,11 +3919,14 @@ components:
type: string
meta:
type: string
durable-id:
hba-nickname:
type: string
host-name:
host-profile:
type: string
serial-number:
host-profile-numeric:
type: integer
format: int64
id:
type: string
host-view-mappings:
$ref: '#/components/schemas/host-view-mappingsResource'
Expand Down Expand Up @@ -4164,13 +4167,13 @@ components:
$ref: '#/components/schemas/volume-group-viewResource'
volume-view:
$ref: '#/components/schemas/volume-viewResource'
hosts-viewObject:
initiator-viewObject:
type: object
properties:
status:
$ref: '#/components/schemas/statusResource'
hosts-view:
$ref: '#/components/schemas/hosts-viewResource'
initiator-view:
$ref: '#/components/schemas/initiator-viewResource'
initiatorObject:
type: object
properties:
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/mc-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ commands:
description: A comma-separated list of the names or serial numbers of the volumes. A name that includes a space must be enclosed in double quotes.

- command: /show/maps/initiator
meta: hosts-view
meta: initiator-view
include:
- status
nested:
Expand Down
8 changes: 6 additions & 2 deletions pkg/api/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ func (client *Client) ShowHostMaps(host string) ([]Volume, *common.ResponseStatu

mappings := make([]Volume, 0)

for _, hv := range response.GetHostsView() {
for _, hv := range response.GetInitiatorView() {
if host != "" {
if hv.GetHostName() != host {
if hv.GetHbaNickname() != host && hv.GetId() != host {
continue
}
}
Expand All @@ -273,6 +273,7 @@ func (client *Client) chooseLUN(initiators []string) (int, error) {

var allvolumes []Volume
for _, initiatorName := range initiators {
logger.V(5).Info("Searching for maps for initiator", "intitiatorName", initiatorName)
volumes, responseStatus, err := client.ShowHostMaps(initiatorName)
if err != nil {
logger.Error(err, "error looking for host maps", "initiator", initiatorName)
Expand Down Expand Up @@ -366,6 +367,8 @@ func (client *Client) mapVolumeProcess(volumeName, initiatorName string, lun int
}
} else if metadata.ReturnCode == common.VolumeNotFoundErrorCode {
return status.Errorf(codes.NotFound, "volume %s not found", volumeName)
} else if metadata.ReturnCode == common.LUNOverlapErrorCode {
return status.Errorf(codes.AlreadyExists, "lun overlap for lun: %d", lun)
David-T-White marked this conversation as resolved.
Show resolved Hide resolved
} else if err != nil {
return status.Error(codes.Internal, err.Error())
}
Expand Down Expand Up @@ -422,6 +425,7 @@ func (client *Client) PublishVolume(volumeId string, initiators []string) (strin
logger := klog.FromContext(client.Ctx)

hostNames, apistatus, err := client.GetVolumeMapsHostNames(volumeId)
klog.InfoS("Get Volume Maps Host Names", "hostnames", hostNames, "apistatus", apistatus)
if err != nil {
if apistatus != nil && apistatus.ReturnCode == common.VolumeNotFoundErrorCode {
return "", status.Errorf(codes.NotFound, "The specified volume (%s) was not found.", volumeId)
Expand Down
8 changes: 4 additions & 4 deletions pkg/client/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ docs/HostGroupObject.md
docs/HostGroupResourceInner.md
docs/HostResourceInner.md
docs/HostViewMappingsResourceInner.md
docs/HostsViewObject.md
docs/HostsViewResourceInner.md
docs/InitiatorObject.md
docs/InitiatorResourceInner.md
docs/InitiatorViewObject.md
docs/InitiatorViewResourceInner.md
docs/IscsiPortResourceInner.md
docs/NetworkParametersResourceInner.md
docs/PoolsObject.md
Expand Down Expand Up @@ -84,10 +84,10 @@ model_host_group_object.go
model_host_group_resource_inner.go
model_host_resource_inner.go
model_host_view_mappings_resource_inner.go
model_hosts_view_object.go
model_hosts_view_resource_inner.go
model_initiator_object.go
model_initiator_resource_inner.go
model_initiator_view_object.go
model_initiator_view_resource_inner.go
model_iscsi_port_resource_inner.go
model_network_parameters_resource_inner.go
model_pools_object.go
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ Class | Method | HTTP request | Description
- [HostGroupResourceInner](docs/HostGroupResourceInner.md)
- [HostResourceInner](docs/HostResourceInner.md)
- [HostViewMappingsResourceInner](docs/HostViewMappingsResourceInner.md)
- [HostsViewObject](docs/HostsViewObject.md)
- [HostsViewResourceInner](docs/HostsViewResourceInner.md)
- [InitiatorObject](docs/InitiatorObject.md)
- [InitiatorResourceInner](docs/InitiatorResourceInner.md)
- [InitiatorViewObject](docs/InitiatorViewObject.md)
- [InitiatorViewResourceInner](docs/InitiatorViewResourceInner.md)
- [IscsiPortResourceInner](docs/IscsiPortResourceInner.md)
- [NetworkParametersResourceInner](docs/NetworkParametersResourceInner.md)
- [PoolsObject](docs/PoolsObject.md)
Expand Down
Loading