Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class OntapPrimaryDatastoreDriver implements PrimaryDataStoreDriver {

private static final Logger s_logger = (Logger)LogManager.getLogger(OntapPrimaryDatastoreDriver.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.Aggregate;
import org.apache.cloudstack.storage.feign.FeignConfiguration;
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.RequestMethod;

import java.net.URI;

@Lazy
Copy link
Collaborator

Choose a reason for hiding this comment

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

To instantiate only when required, we can use this across all the feign clients?

Copy link
Author

Choose a reason for hiding this comment

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

some feign client we need upfront like Cluster, SVM for others we will use @lazy

@FeignClient(name="AggregateClient", url="https://{clusterIP}/api/storage/aggregates", configuration = FeignConfiguration.class)
public interface AggregateFeignClient {

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

@RequestMapping(method=RequestMethod.GET, value="/{uuid}")
Aggregate getAggregateByUUID(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,37 @@
/*
* 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.Cluster;
import org.springframework.cloud.openfeign.FeignClient;
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;

@FeignClient(name="ClusterClient", url="https://{clusterIP}/api/cluster", configuration = FeignConfiguration.class)
public interface ClusterFeignClient {

@RequestMapping(method= RequestMethod.GET)
Cluster getCluster(URI baseURL, @RequestHeader("Authorization") String header, @RequestHeader("return_records") boolean value);

}
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.Svm;
import org.apache.cloudstack.storage.feign.model.response.OntapResponse;
import org.springframework.cloud.openfeign.FeignClient;
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;

@FeignClient(name = "SvmClient", url = "https://{clusterIP}/api/svm/svms", configuration = FeignConfiguration.class)
public interface SvmFeignClient {

//this method to get all svms and also filtered svms based on query params as a part of URL
@RequestMapping(method = RequestMethod.GET)
Copy link

@piyush5netapp piyush5netapp Oct 16, 2025

Choose a reason for hiding this comment

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

A general comment which can be taken later. I see somewhere RequestMapping and somewhere GetMapping,PostMapping.We can have same aross all feign client

OntapResponse<Svm> getSvmResponse(URI baseURL, @RequestHeader("Authorization") String header);

@RequestMapping(method = RequestMethod.GET, value = "/{uuid}")
Svm getSvmByUUID(URI baseURL, @RequestHeader("Authorization") String header);

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@


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.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -34,27 +37,20 @@
public interface VolumeFeignClient {

@DeleteMapping("/storage/volumes/{id}")

Choose a reason for hiding this comment

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

/api is missing

void deleteVolume(@RequestHeader("Authorization") String authHeader,
@PathVariable("id") String volumeId);
void deleteVolume(@RequestHeader("Authorization") String authHeader, @PathVariable("id") String volumeId);

@PostMapping("/api/storage/volumes")
org.apache.cloudstack.storage.feign.model.response.JobResponseDTO createVolumeWithJob(
@RequestHeader("Authorization") String authHeader,
@RequestBody org.apache.cloudstack.storage.feign.model.request.VolumeRequestDTO request
JobResponseDTO createVolumeWithJob(@RequestHeader("Authorization") String authHeader, @RequestBody VolumeRequestDTO request
);

@GetMapping("/api/storage/volumes/{uuid}")
org.apache.cloudstack.storage.feign.model.response.VolumeDetailsResponseDTO getVolumeDetails(
@RequestHeader("Authorization") String authHeader,
@PathVariable("uuid") String uuid
VolumeDetailsResponseDTO getVolumeDetails(@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,
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
);


}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we reuse this in VolumeRequestDTO, instead of AggregateDTO?

Copy link
Author

Choose a reason for hiding this comment

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

As discussed, will remove the request DTOs and use the same ontap model with null annotation

Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,28 @@
package org.apache.cloudstack.storage.feign.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.google.gson.annotations.SerializedName;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Objects;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class Aggregate {

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

@Override
public int hashCode() {
return Objects.hash(getName(), getUuid());
}

@SerializedName("uuid")
@JsonProperty("uuid")
private String uuid = null;

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

/**
* Get name
*
* @return name
**/
public String getName() {
return name;
}
Expand All @@ -61,11 +55,6 @@ public Aggregate uuid(String uuid) {
return this;
}

/**
* Get uuid
*
* @return uuid
**/
public String getUuid() {
return uuid;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* 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.Objects;

/**
* Complete cluster information
*/
@SuppressWarnings("checkstyle:RegexpSingleline")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Cluster {

@JsonProperty("name")
private String name = null;
@JsonProperty("uuid")
private String uuid = null;
@JsonProperty("version")
private Version version = null;
@JsonProperty("health")
private String health = null;

@JsonProperty("san_optimized")
private Boolean sanOptimized = null;

@JsonProperty("disaggregated")
private Boolean disaggregated = null;


public String getHealth() {
return health;
}

public void setHealth(String health) {
this.health = health;
}

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


public String getName() {
return name;
}

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


public String getUuid() {
return uuid;
}

public Cluster version(Version version) {
this.version = version;
return this;
}

public Version getVersion() {
return version;
}

public void setVersion(Version version) {
this.version = version;
}

public Boolean getSanOptimized() {
return sanOptimized;
}

public void setSanOptimized(Boolean sanOptimized) {
this.sanOptimized = sanOptimized;
}

public Boolean getDisaggregated() {
return disaggregated;
}
public void setDisaggregated(Boolean disaggregated) {
this.disaggregated = disaggregated;
}

@Override
public int hashCode() {
return Objects.hash(getName(), getUuid());
}

@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Cluster cluster = (Cluster) o;
return Objects.equals(this.name, cluster.name) &&
Objects.equals(this.uuid, cluster.uuid);
}
@Override
public String toString() {
return "Cluster{" +
"name='" + name + '\'' +
", uuid='" + uuid + '\'' +
", version=" + version +
", sanOptimized=" + sanOptimized +
", disaggregated=" + disaggregated +
'}';
}
}
Loading
Loading