Skip to content

Commit f7b837a

Browse files
suryag1201Gupta, Surya
andauthored
Cluster, SVM and Aggr Feign Client
* CSTACKEX-29 Cluster, SVM and Aggr Feign Client * CSTACKEX-29 Change the endpoint method name in feign client * CSTACKEX-29 Make the alignment proper * CSTACKEX-29 Added License Info * CSTACKEX-29 Resolve Review Comments * CSTACKEX-29 Remove Component Annotation from datastoredriverclass * CSTACKEX-29 Resolve Style check issues * CSTACKEX-29 Resolve ALL Style issues * CSTACKEX-29 Resolve Precommits Issues * CSTACKEX-29 Added Method comments and change the ontap response class name --------- Co-authored-by: Gupta, Surya <[email protected]>
1 parent 2822946 commit f7b837a

File tree

12 files changed

+439
-45
lines changed

12 files changed

+439
-45
lines changed

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@
3939
import org.apache.cloudstack.storage.command.CommandResult;
4040
import org.apache.logging.log4j.LogManager;
4141
import org.apache.logging.log4j.Logger;
42-
import org.springframework.stereotype.Component;
4342

4443
import java.util.HashMap;
4544
import java.util.Map;
4645

47-
@Component
4846
public class OntapPrimaryDatastoreDriver implements PrimaryDataStoreDriver {
4947

5048
private static final Logger s_logger = (Logger)LogManager.getLogger(OntapPrimaryDatastoreDriver.class);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.client;
21+
22+
import org.apache.cloudstack.storage.feign.model.Aggregate;
23+
import org.apache.cloudstack.storage.feign.FeignConfiguration;
24+
import org.apache.cloudstack.storage.feign.model.response.OntapResponse;
25+
import org.springframework.cloud.openfeign.FeignClient;
26+
import org.springframework.context.annotation.Lazy;
27+
import org.springframework.web.bind.annotation.PathVariable;
28+
import org.springframework.web.bind.annotation.RequestHeader;
29+
import org.springframework.web.bind.annotation.RequestMapping;
30+
import org.springframework.web.bind.annotation.RequestMethod;
31+
32+
import java.net.URI;
33+
34+
@Lazy
35+
@FeignClient(name="AggregateClient", url="https://{clusterIP}/api/storage/aggregates", configuration = FeignConfiguration.class)
36+
public interface AggregateFeignClient {
37+
38+
//this method to get all aggregates and also filtered aggregates based on query params as a part of URL
39+
@RequestMapping(method=RequestMethod.GET)
40+
OntapResponse<Aggregate> getAggregateResponse(URI baseURL, @RequestHeader("Authorization") String header);
41+
42+
@RequestMapping(method=RequestMethod.GET, value="/{uuid}")
43+
Aggregate getAggregateByUUID(URI baseURL,@RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid);
44+
45+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.client;
21+
22+
import org.apache.cloudstack.storage.feign.FeignConfiguration;
23+
import org.apache.cloudstack.storage.feign.model.Cluster;
24+
import org.springframework.cloud.openfeign.FeignClient;
25+
import org.springframework.web.bind.annotation.RequestHeader;
26+
import org.springframework.web.bind.annotation.RequestMapping;
27+
import org.springframework.web.bind.annotation.RequestMethod;
28+
29+
import java.net.URI;
30+
31+
@FeignClient(name="ClusterClient", url="https://{clusterIP}/api/cluster", configuration = FeignConfiguration.class)
32+
public interface ClusterFeignClient {
33+
34+
@RequestMapping(method= RequestMethod.GET)
35+
Cluster getCluster(URI baseURL, @RequestHeader("Authorization") String header, @RequestHeader("return_records") boolean value);
36+
37+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.client;
21+
22+
import org.apache.cloudstack.storage.feign.FeignConfiguration;
23+
import org.apache.cloudstack.storage.feign.model.Svm;
24+
import org.apache.cloudstack.storage.feign.model.response.OntapResponse;
25+
import org.springframework.cloud.openfeign.FeignClient;
26+
import org.springframework.web.bind.annotation.RequestHeader;
27+
import org.springframework.web.bind.annotation.RequestMapping;
28+
import org.springframework.web.bind.annotation.RequestMethod;
29+
30+
import java.net.URI;
31+
32+
@FeignClient(name = "SvmClient", url = "https://{clusterIP}/api/svm/svms", configuration = FeignConfiguration.class)
33+
public interface SvmFeignClient {
34+
35+
//this method to get all svms and also filtered svms based on query params as a part of URL
36+
@RequestMapping(method = RequestMethod.GET)
37+
OntapResponse<Svm> getSvmResponse(URI baseURL, @RequestHeader("Authorization") String header);
38+
39+
@RequestMapping(method = RequestMethod.GET, value = "/{uuid}")
40+
Svm getSvmByUUID(URI baseURL, @RequestHeader("Authorization") String header);
41+
42+
}

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/VolumeFeignClient.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121

2222
import org.apache.cloudstack.storage.feign.FeignConfiguration;
23+
import org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO;
24+
import org.apache.cloudstack.storage.feign.model.response.JobResponseDTO;
25+
import org.apache.cloudstack.storage.feign.model.response.VolumeDetailsResponseDTO;
2326
import org.springframework.cloud.openfeign.FeignClient;
2427
import org.springframework.web.bind.annotation.DeleteMapping;
2528
import org.springframework.web.bind.annotation.GetMapping;
@@ -34,27 +37,20 @@
3437
public interface VolumeFeignClient {
3538

3639
@DeleteMapping("/storage/volumes/{id}")
37-
void deleteVolume(@RequestHeader("Authorization") String authHeader,
38-
@PathVariable("id") String volumeId);
40+
void deleteVolume(@RequestHeader("Authorization") String authHeader, @PathVariable("id") String volumeId);
3941

4042
@PostMapping("/api/storage/volumes")
41-
org.apache.cloudstack.storage.feign.model.response.JobResponseDTO createVolumeWithJob(
42-
@RequestHeader("Authorization") String authHeader,
43-
@RequestBody org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO request
43+
JobResponseDTO createVolumeWithJob(@RequestHeader("Authorization") String authHeader, @RequestBody VolumeRequestDTO request
4444
);
4545

4646
@GetMapping("/api/storage/volumes/{uuid}")
47-
org.apache.cloudstack.storage.feign.model.response.VolumeDetailsResponseDTO getVolumeDetails(
48-
@RequestHeader("Authorization") String authHeader,
49-
@PathVariable("uuid") String uuid
47+
VolumeDetailsResponseDTO getVolumeDetails(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid
5048
);
5149

5250
@PatchMapping("/api/storage/volumes/{uuid}")
53-
org.apache.cloudstack.storage.feign.model.response.JobResponseDTO updateVolumeRebalancing(
54-
@RequestHeader("accept") String acceptHeader,
51+
org.apache.cloudstack.storage.feign.model.response.JobResponseDTO updateVolumeRebalancing(@RequestHeader("accept") String acceptHeader,
5552
@PathVariable("uuid") String uuid,
5653
@RequestBody org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO request
5754
);
5855

59-
6056
}

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,28 @@
2020
package org.apache.cloudstack.storage.feign.model;
2121

2222
import com.fasterxml.jackson.annotation.JsonInclude;
23-
import com.google.gson.annotations.SerializedName;
23+
import com.fasterxml.jackson.annotation.JsonProperty;
2424

2525
import java.util.Objects;
2626

2727
@JsonInclude(JsonInclude.Include.NON_NULL)
2828
public class Aggregate {
2929

30-
@SerializedName("name")
30+
@JsonProperty("name")
3131
private String name = null;
3232

3333
@Override
3434
public int hashCode() {
3535
return Objects.hash(getName(), getUuid());
3636
}
3737

38-
@SerializedName("uuid")
38+
@JsonProperty("uuid")
3939
private String uuid = null;
4040

4141
public Aggregate name(String name) {
4242
this.name = name;
4343
return this;
4444
}
45-
46-
/**
47-
* Get name
48-
*
49-
* @return name
50-
**/
5145
public String getName() {
5246
return name;
5347
}
@@ -61,11 +55,6 @@ public Aggregate uuid(String uuid) {
6155
return this;
6256
}
6357

64-
/**
65-
* Get uuid
66-
*
67-
* @return uuid
68-
**/
6958
public String getUuid() {
7059
return uuid;
7160
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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.Objects;
26+
27+
/**
28+
* Complete cluster information
29+
*/
30+
@SuppressWarnings("checkstyle:RegexpSingleline")
31+
@JsonInclude(JsonInclude.Include.NON_NULL)
32+
public class Cluster {
33+
34+
@JsonProperty("name")
35+
private String name = null;
36+
@JsonProperty("uuid")
37+
private String uuid = null;
38+
@JsonProperty("version")
39+
private Version version = null;
40+
@JsonProperty("health")
41+
private String health = null;
42+
43+
@JsonProperty("san_optimized")
44+
private Boolean sanOptimized = null;
45+
46+
@JsonProperty("disaggregated")
47+
private Boolean disaggregated = null;
48+
49+
50+
public String getHealth() {
51+
return health;
52+
}
53+
54+
public void setHealth(String health) {
55+
this.health = health;
56+
}
57+
58+
public Cluster name(String name) {
59+
this.name = name;
60+
return this;
61+
}
62+
63+
64+
public String getName() {
65+
return name;
66+
}
67+
68+
public void setName(String name) {
69+
this.name = name;
70+
}
71+
72+
73+
public String getUuid() {
74+
return uuid;
75+
}
76+
77+
public Cluster version(Version version) {
78+
this.version = version;
79+
return this;
80+
}
81+
82+
public Version getVersion() {
83+
return version;
84+
}
85+
86+
public void setVersion(Version version) {
87+
this.version = version;
88+
}
89+
90+
public Boolean getSanOptimized() {
91+
return sanOptimized;
92+
}
93+
94+
public void setSanOptimized(Boolean sanOptimized) {
95+
this.sanOptimized = sanOptimized;
96+
}
97+
98+
public Boolean getDisaggregated() {
99+
return disaggregated;
100+
}
101+
public void setDisaggregated(Boolean disaggregated) {
102+
this.disaggregated = disaggregated;
103+
}
104+
105+
@Override
106+
public int hashCode() {
107+
return Objects.hash(getName(), getUuid());
108+
}
109+
110+
@Override
111+
public boolean equals(java.lang.Object o) {
112+
if (this == o) {
113+
return true;
114+
}
115+
if (o == null || getClass() != o.getClass()) {
116+
return false;
117+
}
118+
Cluster cluster = (Cluster) o;
119+
return Objects.equals(this.name, cluster.name) &&
120+
Objects.equals(this.uuid, cluster.uuid);
121+
}
122+
@Override
123+
public String toString() {
124+
return "Cluster{" +
125+
"name='" + name + '\'' +
126+
", uuid='" + uuid + '\'' +
127+
", version=" + version +
128+
", sanOptimized=" + sanOptimized +
129+
", disaggregated=" + disaggregated +
130+
'}';
131+
}
132+
}

0 commit comments

Comments
 (0)