-
Notifications
You must be signed in to change notification settings - Fork 0
NAS and Job Feign Client #7
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
Changes from all commits
d46b0b6
2f3b41f
88bba44
5d03aae
6a76348
535289c
558bd19
9380d57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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.FeignConfiguration; | ||
import org.apache.cloudstack.storage.feign.model.Job; | ||
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.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import java.net.URI; | ||
|
||
/** | ||
* @author Administrator | ||
* | ||
*/ | ||
@Lazy | ||
@FeignClient(name = "JobClient", url = "https://{clusterIP}/api/cluster/jobs" , configuration = FeignConfiguration.class) | ||
public interface JobFeignClient { | ||
|
||
@RequestMapping(method = RequestMethod.GET, value="/{uuid}") | ||
Job getJobByUUID(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* 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.FeignConfiguration; | ||
import org.apache.cloudstack.storage.feign.model.ExportPolicy; | ||
import org.apache.cloudstack.storage.feign.model.FileInfo; | ||
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.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import java.net.URI; | ||
|
||
/** | ||
* @author Administrator | ||
* | ||
*/ | ||
@Lazy | ||
@FeignClient(name = "NASClient", url = "" , configuration = FeignConfiguration.class) | ||
public interface NASFeignClient { | ||
|
||
//File Operations | ||
|
||
@RequestMapping(method = RequestMethod.GET, value="/{volume.uuid}/files/{path}") | ||
OntapResponse<FileInfo> getFileResponse(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remember seeing OnTapResponse, was this changed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes changed to OntapResponse |
||
@PathVariable(name = "path", required = true) String filePath); | ||
@RequestMapping(method = RequestMethod.DELETE, value="/{volume.uuid}/files/{path}") | ||
void deleteFile(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID, | ||
@PathVariable(name = "path", required = true) String filePath); | ||
@RequestMapping(method = RequestMethod.PATCH, value="/{volume.uuid}/files/{path}") | ||
void updateFile(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID, | ||
@PathVariable(name = "path", required = true) String filePath, @RequestBody FileInfo fileInfo); | ||
@RequestMapping(method = RequestMethod.POST, value="/{volume.uuid}/files/{path}") | ||
void createFile(URI uri, @RequestHeader("Authorization") String header, @PathVariable(name = "volume.uuid", required = true) String volumeUUID, | ||
@PathVariable(name = "path", required = true) String filePath, @RequestBody FileInfo file); | ||
|
||
|
||
|
||
//Export Policy Operations | ||
|
||
@RequestMapping(method = RequestMethod.POST) | ||
ExportPolicy createExportPolicy(URI uri, @RequestHeader("Authorization") String header, @RequestHeader("return_records") boolean value, | ||
@RequestBody ExportPolicy exportPolicy); | ||
|
||
//this method to get all export policies and also filtered export policy based on query params as a part of URL | ||
@RequestMapping(method = RequestMethod.GET) | ||
OntapResponse<ExportPolicy> getExportPolicyResponse(URI baseURL, @RequestHeader("Authorization") String header); | ||
|
||
@RequestMapping(method = RequestMethod.GET, value="/{id}") | ||
OntapResponse<ExportPolicy> getExportPolicyById(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "id", required = true) String id); | ||
|
||
@RequestMapping(method = RequestMethod.DELETE, value="/{id}") | ||
void deleteExportPolicyById(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "id", required = true) String id); | ||
|
||
@RequestMapping(method = RequestMethod.PATCH, value="/{id}") | ||
OntapResponse<ExportPolicy> updateExportPolicy(URI baseURL, @RequestHeader("Authorization") String header, @PathVariable(name = "id", required = true) String id, | ||
@RequestBody ExportPolicy request); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,37 +20,31 @@ | |
|
||
|
||
import org.apache.cloudstack.storage.feign.FeignConfiguration; | ||
import org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO; | ||
import org.apache.cloudstack.storage.feign.model.response.JobResponseDTO; | ||
import org.apache.cloudstack.storage.feign.model.response.VolumeDetailsResponseDTO; | ||
import org.apache.cloudstack.storage.feign.model.Volume; | ||
import org.apache.cloudstack.storage.feign.model.response.JobResponse; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.context.annotation.Lazy; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
|
||
@Lazy | ||
@FeignClient(name = "VolumeClient", url = "https://{clusterIP}/api/storage/volumes", configuration = FeignConfiguration.class) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess here we can use Lazy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
public interface VolumeFeignClient { | ||
|
||
@DeleteMapping("/storage/volumes/{id}") | ||
void deleteVolume(@RequestHeader("Authorization") String authHeader, @PathVariable("id") String volumeId); | ||
@RequestMapping(method = RequestMethod.DELETE, value="/{uuid}") | ||
void deleteVolume(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid); | ||
|
||
@PostMapping("/api/storage/volumes") | ||
JobResponseDTO createVolumeWithJob(@RequestHeader("Authorization") String authHeader, @RequestBody VolumeRequestDTO request | ||
); | ||
@RequestMapping(method = RequestMethod.POST) | ||
JobResponse createVolumeWithJob(@RequestHeader("Authorization") String authHeader, @RequestBody Volume volumeRequest); | ||
|
||
@GetMapping("/api/storage/volumes/{uuid}") | ||
VolumeDetailsResponseDTO getVolumeDetails(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid | ||
); | ||
@RequestMapping(method = RequestMethod.GET, value="/{uuid}") | ||
Volume getVolumeByUUID(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid); | ||
|
||
@PatchMapping("/api/storage/volumes/{uuid}") | ||
org.apache.cloudstack.storage.feign.model.response.JobResponseDTO updateVolumeRebalancing(@RequestHeader("accept") String acceptHeader, | ||
@PathVariable("uuid") String uuid, | ||
@RequestBody org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO request | ||
); | ||
@RequestMapping(method = RequestMethod.PATCH) | ||
JobResponse updateVolumeRebalancing(@RequestHeader("accept") String acceptHeader, @PathVariable("uuid") String uuid, @RequestBody Volume volumeRequest); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,30 +16,105 @@ | |
* 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.math.BigInteger; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class ExportPolicy { | ||
private String name; | ||
private long id; | ||
public String getName() { return name; } | ||
public void setName(String name) { this.name = name; } | ||
public long getId() { return id; } | ||
public void setId(long id) { this.id = id; } | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ExportPolicy that = (ExportPolicy) o; | ||
return getId() == that.getId(); | ||
|
||
@JsonProperty("id") | ||
private BigInteger id = null; | ||
@JsonProperty("name") | ||
private String name = null; | ||
@JsonProperty("rules") | ||
private List<ExportRule> rules = null; | ||
@JsonProperty("svm") | ||
private Svm svm = null; | ||
|
||
public BigInteger getId() { | ||
return id; | ||
} | ||
|
||
public ExportPolicy name(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public ExportPolicy rules(List<ExportRule> rules) { | ||
this.rules = rules; | ||
return this; | ||
} | ||
|
||
public List<ExportRule> getRules() { | ||
return rules; | ||
} | ||
|
||
public void setRules(List<ExportRule> rules) { | ||
this.rules = rules; | ||
} | ||
|
||
public ExportPolicy svm(Svm svm) { | ||
this.svm = svm; | ||
return this; | ||
} | ||
|
||
public Svm getSvm() { | ||
return svm; | ||
} | ||
|
||
public void setSvm(Svm svm) { | ||
this.svm = svm; | ||
} | ||
|
||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
ExportPolicy exportPolicy = (ExportPolicy) o; | ||
return Objects.equals(this.id, exportPolicy.id) && | ||
Objects.equals(this.name, exportPolicy.name); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash( id, name, rules, svm); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hashcode and equals should use same set of attributes to evaluate the usecase. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, will include in next PR |
||
} | ||
|
||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(getId()); | ||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("class ExportPolicy {\n"); | ||
sb.append(" id: ").append(toIndentedString(id)).append("\n"); | ||
sb.append(" name: ").append(toIndentedString(name)).append("\n"); | ||
sb.append(" rules: ").append(toIndentedString(rules)).append("\n"); | ||
sb.append(" svm: ").append(toIndentedString(svm)).append("\n"); | ||
sb.append("}"); | ||
return sb.toString(); | ||
} | ||
private String toIndentedString(Object o) { | ||
if (o == null) { | ||
return "null"; | ||
} | ||
return o.toString().replace("\n", "\n "); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Job is needed while performing most of ontap operations, so, is Lazy needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once this is in use, it will get initialise and next time it will be available so it will not go to initilize phase again so we can use lazy annotation, only SVM and cluster i did not require lazy bcz we need disaggregated and protocol info