Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.feign.client;

import org.apache.cloudstack.storage.feign.model.Igroup;
import org.apache.cloudstack.storage.feign.model.Lun;
import org.apache.cloudstack.storage.feign.FeignConfiguration;
import org.apache.cloudstack.storage.feign.model.LunMap;
import org.apache.cloudstack.storage.feign.model.response.OntapResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestHeader;

import java.net.URI;

@Lazy
@FeignClient(name = "SANClient", url = "", configuration = FeignConfiguration.class )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the URL field empty?

Copy link
Author

@suryag1201 suryag1201 Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feign client has multiple resources like lun, iGroup, LunMap. All have different different URLs. So, kept empty bcz we can use the method level baseURL like below:

OntapResponse getLunResponse(URI baseURL, @RequestHeader("Authorization") String authHeader);

public interface SANFeignClient {

//Lun Operation APIs
@RequestMapping(method = RequestMethod.POST)
OntapResponse<Lun> createLun(URI baseURL, @RequestHeader("Authorization") String authHeader, @RequestHeader("return_records") boolean value,
@RequestBody Lun lun);

//this method to get all luns and also filtered luns based on query params as a part of URL
@RequestMapping(method = RequestMethod.GET)
OntapResponse<Lun> getLunResponse(URI baseURL, @RequestHeader("Authorization") String authHeader);

@RequestMapping(method = RequestMethod.GET, value = "/{uuid}")
Lun getLunByUUID(URI baseURL, @RequestHeader("Authorization") String authHeader, @PathVariable(name="uuid", required=true) String uuid);

@RequestMapping(method = RequestMethod.PATCH, value = "/{uuid}")
void updateLun(URI uri, @RequestHeader("Authorization") String authHeader, @PathVariable(name="uuid", required=true) String uuid,
@RequestBody Lun lun);

@RequestMapping(method = RequestMethod.DELETE, value = "/{uuid}")
void deleteLun(URI baseURL, @RequestHeader("Authorization") String authHeader, @PathVariable(name="uuid", required=true) String uuid);


//iGroup Operation APIs

@RequestMapping(method = RequestMethod.POST)
OntapResponse<Igroup> createIgroup(URI uri, @RequestHeader("Authorization") String header, @RequestHeader("return_records") boolean value,
@RequestBody Igroup igroupRequest);

//this method to get all igroups and also filtered igroups based on query params as a part of URL
@RequestMapping(method = RequestMethod.GET)
OntapResponse<Igroup> getIgroupResponse(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid);
@RequestMapping(method = RequestMethod.GET, value = "/{uuid}")
Igroup getIgroupByUUID(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid);
@RequestMapping(method = RequestMethod.DELETE, value = "/{uuid}")
void deleteIgroup(URI baseUri, @RequestHeader("Authorization") String authHeader, @PathVariable(name = "uuid", required = true) String uuid);

@RequestMapping(method = RequestMethod.POST, value = "/{uuid}/igroups")
OntapResponse<Igroup> addNestedIgroups(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid,
@RequestBody Igroup igroupNestedRequest, @RequestHeader(value="return_records", defaultValue = "true") boolean value);


//Lun Maps Operation APIs

@RequestMapping(method = RequestMethod.POST)
OntapResponse<LunMap> createLunMap(URI baseURL, @RequestHeader("Authorization") String authHeader, @RequestBody LunMap lunMap);

@RequestMapping(method = RequestMethod.GET)
OntapResponse<LunMap> getLunMapResponse(URI baseURL, @RequestHeader("Authorization") String authHeader);

@RequestMapping(method = RequestMethod.GET, value = "/{lun.uuid}/{igroup.uuid}")
void deleteLunMap(URI baseURL, @RequestHeader("Authorization") String authHeader, @PathVariable(name="lun.uuid", required=true) String uuid,
@PathVariable(name="igroup.uuid", required=true) String igroupUUID);

}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash( id, name, rules, svm);
return Objects.hash( id, name);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(bytesUsed, creationTime, fillEnabled, isEmpty, isSnapshot, isVmAligned, modifiedTime, name, overwriteEnabled, path, size, target, type, uniqueBytes, unixPermissions);
return Objects.hash(name, path);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.cloudstack.storage.feign.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;
import java.util.Objects;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class Igroup {
@JsonProperty("delete_on_unmap")
private Boolean deleteOnUnmap = null;
@JsonProperty("initiators")
private List<Initiator> initiators = null;
@JsonProperty("lun_maps")
private List<LunMap> lunMaps = null;
@JsonProperty("os_type")
private OsTypeEnum osType = null;

@JsonProperty("parent_igroups")
private List<Igroup> parentIgroups = null;

@JsonProperty("igroups")
private List<Igroup> igroups = null;

@JsonProperty("name")
private String name = null;

@JsonProperty("protocol")
private ProtocolEnum protocol = ProtocolEnum.mixed;
@JsonProperty("svm")
private Svm svm = null;
@JsonProperty("uuid")
private String uuid = null;

public enum OsTypeEnum {
hyper_v("hyper_v"),

linux("linux"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we map 'kvm' here, to 'linux'? Also, shall we restrict this list to the one's that we would support for first drop?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be linux and also reduced the list


vmware("vmware"),

windows("windows"),

xen("xen");

private String value;

OsTypeEnum(String value) {
this.value = value;
}

public String getValue() {
return value;
}

@Override
public String toString() {
return String.valueOf(value);
}

public static OsTypeEnum fromValue(String text) {
for (OsTypeEnum b : OsTypeEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
}

public List<Igroup> getParentIgroups() {
return parentIgroups;
}

public void setParentIgroups(List<Igroup> parentIgroups) {
this.parentIgroups = parentIgroups;
}

public Igroup igroups(List<Igroup> igroups) {
this.igroups = igroups;
return this;
}

public List<Igroup> getIgroups() {
return igroups;
}

public void setIgroups(List<Igroup> igroups) {
this.igroups = igroups;
}

public enum ProtocolEnum {
iscsi("iscsi"),

mixed("mixed");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need mixed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, for FC we need


private String value;

ProtocolEnum(String value) {
this.value = value;
}

public String getValue() {
return value;
}

@Override
public String toString() {
return String.valueOf(value);
}

public static ProtocolEnum fromValue(String text) {
for (ProtocolEnum b : ProtocolEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
}
public Igroup deleteOnUnmap(Boolean deleteOnUnmap) {
this.deleteOnUnmap = deleteOnUnmap;
return this;
}

public Boolean isDeleteOnUnmap() {
return deleteOnUnmap;
}

public void setDeleteOnUnmap(Boolean deleteOnUnmap) {
this.deleteOnUnmap = deleteOnUnmap;
}

public Igroup initiators(List<Initiator> initiators) {
this.initiators = initiators;
return this;
}
public List<Initiator> getInitiators() {
return initiators;
}

public void setInitiators(List<Initiator> initiators) {
this.initiators = initiators;
}

public Igroup lunMaps(List<LunMap> lunMaps) {
this.lunMaps = lunMaps;
return this;
}
public List<LunMap> getLunMaps() {
return lunMaps;
}

public void setLunMaps(List<LunMap> lunMaps) {
this.lunMaps = lunMaps;
}

public Igroup name(String name) {
this.name = name;
return this;
}

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

public Igroup osType(OsTypeEnum osType) {
this.osType = osType;
return this;
}
public OsTypeEnum getOsType() {
return osType;
}

public void setOsType(OsTypeEnum osType) {
this.osType = osType;
}

public Igroup protocol(ProtocolEnum protocol) {
this.protocol = protocol;
return this;
}

public ProtocolEnum getProtocol() {
return protocol;
}

public void setProtocol(ProtocolEnum protocol) {
this.protocol = protocol;
}

public Igroup svm(Svm svm) {
this.svm = svm;
return this;
}
public Svm getSvm() {
return svm;
}

public void setSvm(Svm svm) {
this.svm = svm;
}

public String getUuid() {
return uuid;
}

@Override
public int hashCode() {
return Objects.hash(name, uuid);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Igroup other = (Igroup) obj;
return Objects.equals(name, other.name) && Objects.equals(uuid, other.uuid);
}

@Override
public String toString() {
return "Igroup [deleteOnUnmap=" + deleteOnUnmap + ", initiators=" + initiators + ", lunMaps=" + lunMaps
+ ", name=" + name + ", replication=" + ", osType=" + osType + ", parentIgroups="
+ parentIgroups + ", igroups=" + igroups + ", protocol=" + protocol + ", svm=" + svm + ", uuid=" + uuid
+ ", portset=" + "]";
}
}
Loading
Loading