Skip to content

Commit a492797

Browse files
suryag1201Gupta, Surya
andauthored
CSTACKEX-30 SAN Feign Client (#8)
* CSTACKEX-30 SAN Feign Client * CSTACKEX-30 Fixed check style issues * CSTACKEX-30 Fixed review comments --------- Co-authored-by: Gupta, Surya <[email protected]>
1 parent c585299 commit a492797

File tree

8 files changed

+884
-2
lines changed

8 files changed

+884
-2
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.cloudstack.storage.feign.client;
20+
21+
import org.apache.cloudstack.storage.feign.model.Igroup;
22+
import org.apache.cloudstack.storage.feign.model.Lun;
23+
import org.apache.cloudstack.storage.feign.FeignConfiguration;
24+
import org.apache.cloudstack.storage.feign.model.LunMap;
25+
import org.apache.cloudstack.storage.feign.model.response.OntapResponse;
26+
import org.springframework.cloud.openfeign.FeignClient;
27+
import org.springframework.context.annotation.Lazy;
28+
import org.springframework.web.bind.annotation.PathVariable;
29+
import org.springframework.web.bind.annotation.RequestBody;
30+
import org.springframework.web.bind.annotation.RequestMapping;
31+
import org.springframework.web.bind.annotation.RequestMethod;
32+
import org.springframework.web.bind.annotation.RequestHeader;
33+
34+
import java.net.URI;
35+
36+
@Lazy
37+
@FeignClient(name = "SANClient", url = "", configuration = FeignConfiguration.class )
38+
public interface SANFeignClient {
39+
40+
//Lun Operation APIs
41+
@RequestMapping(method = RequestMethod.POST)
42+
OntapResponse<Lun> createLun(URI baseURL, @RequestHeader("Authorization") String authHeader, @RequestHeader("return_records") boolean value,
43+
@RequestBody Lun lun);
44+
45+
//this method to get all luns and also filtered luns based on query params as a part of URL
46+
@RequestMapping(method = RequestMethod.GET)
47+
OntapResponse<Lun> getLunResponse(URI baseURL, @RequestHeader("Authorization") String authHeader);
48+
49+
@RequestMapping(method = RequestMethod.GET, value = "/{uuid}")
50+
Lun getLunByUUID(URI baseURL, @RequestHeader("Authorization") String authHeader, @PathVariable(name="uuid", required=true) String uuid);
51+
52+
@RequestMapping(method = RequestMethod.PATCH, value = "/{uuid}")
53+
void updateLun(URI uri, @RequestHeader("Authorization") String authHeader, @PathVariable(name="uuid", required=true) String uuid,
54+
@RequestBody Lun lun);
55+
56+
@RequestMapping(method = RequestMethod.DELETE, value = "/{uuid}")
57+
void deleteLun(URI baseURL, @RequestHeader("Authorization") String authHeader, @PathVariable(name="uuid", required=true) String uuid);
58+
59+
60+
//iGroup Operation APIs
61+
62+
@RequestMapping(method = RequestMethod.POST)
63+
OntapResponse<Igroup> createIgroup(URI uri, @RequestHeader("Authorization") String header, @RequestHeader("return_records") boolean value,
64+
@RequestBody Igroup igroupRequest);
65+
66+
//this method to get all igroups and also filtered igroups based on query params as a part of URL
67+
@RequestMapping(method = RequestMethod.GET)
68+
OntapResponse<Igroup> getIgroupResponse(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid);
69+
@RequestMapping(method = RequestMethod.GET, value = "/{uuid}")
70+
Igroup getIgroupByUUID(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid);
71+
@RequestMapping(method = RequestMethod.DELETE, value = "/{uuid}")
72+
void deleteIgroup(URI baseUri, @RequestHeader("Authorization") String authHeader, @PathVariable(name = "uuid", required = true) String uuid);
73+
74+
@RequestMapping(method = RequestMethod.POST, value = "/{uuid}/igroups")
75+
OntapResponse<Igroup> addNestedIgroups(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid,
76+
@RequestBody Igroup igroupNestedRequest, @RequestHeader(value="return_records", defaultValue = "true") boolean value);
77+
78+
79+
//Lun Maps Operation APIs
80+
81+
@RequestMapping(method = RequestMethod.POST)
82+
OntapResponse<LunMap> createLunMap(URI baseURL, @RequestHeader("Authorization") String authHeader, @RequestBody LunMap lunMap);
83+
84+
@RequestMapping(method = RequestMethod.GET)
85+
OntapResponse<LunMap> getLunMapResponse(URI baseURL, @RequestHeader("Authorization") String authHeader);
86+
87+
@RequestMapping(method = RequestMethod.GET, value = "/{lun.uuid}/{igroup.uuid}")
88+
void deleteLunMap(URI baseURL, @RequestHeader("Authorization") String authHeader, @PathVariable(name="lun.uuid", required=true) String uuid,
89+
@PathVariable(name="igroup.uuid", required=true) String igroupUUID);
90+
91+
}

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ExportPolicy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public boolean equals(Object o) {
9696

9797
@Override
9898
public int hashCode() {
99-
return Objects.hash( id, name, rules, svm);
99+
return Objects.hash( id, name);
100100
}
101101

102102

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/FileInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public boolean equals(Object o) {
255255

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

261261

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.cloudstack.storage.feign.model;
21+
22+
import com.fasterxml.jackson.annotation.JsonInclude;
23+
import com.fasterxml.jackson.annotation.JsonProperty;
24+
25+
import java.util.List;
26+
import java.util.Objects;
27+
28+
@JsonInclude(JsonInclude.Include.NON_NULL)
29+
public class Igroup {
30+
@JsonProperty("delete_on_unmap")
31+
private Boolean deleteOnUnmap = null;
32+
@JsonProperty("initiators")
33+
private List<Initiator> initiators = null;
34+
@JsonProperty("lun_maps")
35+
private List<LunMap> lunMaps = null;
36+
@JsonProperty("os_type")
37+
private OsTypeEnum osType = null;
38+
39+
@JsonProperty("parent_igroups")
40+
private List<Igroup> parentIgroups = null;
41+
42+
@JsonProperty("igroups")
43+
private List<Igroup> igroups = null;
44+
45+
@JsonProperty("name")
46+
private String name = null;
47+
48+
@JsonProperty("protocol")
49+
private ProtocolEnum protocol = ProtocolEnum.mixed;
50+
@JsonProperty("svm")
51+
private Svm svm = null;
52+
@JsonProperty("uuid")
53+
private String uuid = null;
54+
55+
public enum OsTypeEnum {
56+
hyper_v("hyper_v"),
57+
58+
linux("linux"),
59+
60+
vmware("vmware"),
61+
62+
windows("windows"),
63+
64+
xen("xen");
65+
66+
private String value;
67+
68+
OsTypeEnum(String value) {
69+
this.value = value;
70+
}
71+
72+
public String getValue() {
73+
return value;
74+
}
75+
76+
@Override
77+
public String toString() {
78+
return String.valueOf(value);
79+
}
80+
81+
public static OsTypeEnum fromValue(String text) {
82+
for (OsTypeEnum b : OsTypeEnum.values()) {
83+
if (String.valueOf(b.value).equals(text)) {
84+
return b;
85+
}
86+
}
87+
return null;
88+
}
89+
}
90+
91+
public List<Igroup> getParentIgroups() {
92+
return parentIgroups;
93+
}
94+
95+
public void setParentIgroups(List<Igroup> parentIgroups) {
96+
this.parentIgroups = parentIgroups;
97+
}
98+
99+
public Igroup igroups(List<Igroup> igroups) {
100+
this.igroups = igroups;
101+
return this;
102+
}
103+
104+
public List<Igroup> getIgroups() {
105+
return igroups;
106+
}
107+
108+
public void setIgroups(List<Igroup> igroups) {
109+
this.igroups = igroups;
110+
}
111+
112+
public enum ProtocolEnum {
113+
iscsi("iscsi"),
114+
115+
mixed("mixed");
116+
117+
private String value;
118+
119+
ProtocolEnum(String value) {
120+
this.value = value;
121+
}
122+
123+
public String getValue() {
124+
return value;
125+
}
126+
127+
@Override
128+
public String toString() {
129+
return String.valueOf(value);
130+
}
131+
132+
public static ProtocolEnum fromValue(String text) {
133+
for (ProtocolEnum b : ProtocolEnum.values()) {
134+
if (String.valueOf(b.value).equals(text)) {
135+
return b;
136+
}
137+
}
138+
return null;
139+
}
140+
}
141+
public Igroup deleteOnUnmap(Boolean deleteOnUnmap) {
142+
this.deleteOnUnmap = deleteOnUnmap;
143+
return this;
144+
}
145+
146+
public Boolean isDeleteOnUnmap() {
147+
return deleteOnUnmap;
148+
}
149+
150+
public void setDeleteOnUnmap(Boolean deleteOnUnmap) {
151+
this.deleteOnUnmap = deleteOnUnmap;
152+
}
153+
154+
public Igroup initiators(List<Initiator> initiators) {
155+
this.initiators = initiators;
156+
return this;
157+
}
158+
public List<Initiator> getInitiators() {
159+
return initiators;
160+
}
161+
162+
public void setInitiators(List<Initiator> initiators) {
163+
this.initiators = initiators;
164+
}
165+
166+
public Igroup lunMaps(List<LunMap> lunMaps) {
167+
this.lunMaps = lunMaps;
168+
return this;
169+
}
170+
public List<LunMap> getLunMaps() {
171+
return lunMaps;
172+
}
173+
174+
public void setLunMaps(List<LunMap> lunMaps) {
175+
this.lunMaps = lunMaps;
176+
}
177+
178+
public Igroup name(String name) {
179+
this.name = name;
180+
return this;
181+
}
182+
183+
public String getName() {
184+
return name;
185+
}
186+
public void setName(String name) {
187+
this.name = name;
188+
}
189+
190+
public Igroup osType(OsTypeEnum osType) {
191+
this.osType = osType;
192+
return this;
193+
}
194+
public OsTypeEnum getOsType() {
195+
return osType;
196+
}
197+
198+
public void setOsType(OsTypeEnum osType) {
199+
this.osType = osType;
200+
}
201+
202+
public Igroup protocol(ProtocolEnum protocol) {
203+
this.protocol = protocol;
204+
return this;
205+
}
206+
207+
public ProtocolEnum getProtocol() {
208+
return protocol;
209+
}
210+
211+
public void setProtocol(ProtocolEnum protocol) {
212+
this.protocol = protocol;
213+
}
214+
215+
public Igroup svm(Svm svm) {
216+
this.svm = svm;
217+
return this;
218+
}
219+
public Svm getSvm() {
220+
return svm;
221+
}
222+
223+
public void setSvm(Svm svm) {
224+
this.svm = svm;
225+
}
226+
227+
public String getUuid() {
228+
return uuid;
229+
}
230+
231+
@Override
232+
public int hashCode() {
233+
return Objects.hash(name, uuid);
234+
}
235+
236+
@Override
237+
public boolean equals(Object obj) {
238+
if (this == obj)
239+
return true;
240+
if (obj == null)
241+
return false;
242+
if (getClass() != obj.getClass())
243+
return false;
244+
Igroup other = (Igroup) obj;
245+
return Objects.equals(name, other.name) && Objects.equals(uuid, other.uuid);
246+
}
247+
248+
@Override
249+
public String toString() {
250+
return "Igroup [deleteOnUnmap=" + deleteOnUnmap + ", initiators=" + initiators + ", lunMaps=" + lunMaps
251+
+ ", name=" + name + ", replication=" + ", osType=" + osType + ", parentIgroups="
252+
+ parentIgroups + ", igroups=" + igroups + ", protocol=" + protocol + ", svm=" + svm + ", uuid=" + uuid
253+
+ ", portset=" + "]";
254+
}
255+
}

0 commit comments

Comments
 (0)