Skip to content

[NSX] Refactor API wrapper operations #8059

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

Merged
merged 6 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
Expand Up @@ -24,9 +24,9 @@ public class CreateNsxDhcpRelayConfigCommand extends NsxCommand {
private String networkName;
private List<String> addresses;

public CreateNsxDhcpRelayConfigCommand(String zoneName, Long zoneId, String accountName, Long accountId,
public CreateNsxDhcpRelayConfigCommand(String domainName, String accountName, String zoneName,
String vpcName, String networkName, List<String> addresses) {
super(zoneName, zoneId, accountName, accountId);
super(domainName, accountName, zoneName);
this.vpcName = vpcName;
this.networkName = networkName;
this.addresses = addresses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,38 @@
// under the License.
package org.apache.cloudstack.agent.api;

import com.cloud.network.dao.NetworkVO;

import java.util.Objects;

public class CreateNsxSegmentCommand extends CreateNsxTier1GatewayCommand {
private NetworkVO tierNetwork;
public CreateNsxSegmentCommand(String zoneName, Long zoneId, String accountName, Long accountId, String vpcName, NetworkVO tierNetwork) {
super(zoneName, zoneId, accountName, accountId, vpcName);
this.tierNetwork = tierNetwork;
public class CreateNsxSegmentCommand extends NsxCommand {

private String vpcName;
private String networkName;
private String networkGateway;
private String networkCidr;

public CreateNsxSegmentCommand(String domainName, String accountName, String zoneName,
String vpcName, String networkName, String networkGateway, String networkCidr) {
super(domainName, accountName, zoneName);
this.vpcName = vpcName;
this.networkName = networkName;
this.networkGateway = networkGateway;
this.networkCidr = networkCidr;
}

public String getVpcName() {
return vpcName;
}

public String getNetworkName() {
return networkName;
}

public NetworkVO getTierNetwork() {
return tierNetwork;
public String getNetworkGateway() {
return networkGateway;
}

public void setTierNetwork(NetworkVO tierNetwork) {
this.tierNetwork = tierNetwork;
public String getNetworkCidr() {
return networkCidr;
}

@Override
Expand All @@ -41,11 +56,11 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
CreateNsxSegmentCommand command = (CreateNsxSegmentCommand) o;
return Objects.equals(tierNetwork, command.tierNetwork);
return Objects.equals(networkName, command.networkName);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), tierNetwork);
return Objects.hash(super.hashCode(), networkName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,15 @@
public class CreateNsxTier1GatewayCommand extends NsxCommand {
private String vpcName;

public CreateNsxTier1GatewayCommand(String zoneName, Long zoneId, String accountName, Long accountId, String vpcName) {
super(zoneName, zoneId, accountName, accountId);
public CreateNsxTier1GatewayCommand(String domainName, String accountName, String zoneName, String vpcName) {
super(domainName, accountName, zoneName);
this.vpcName = vpcName;
}

public String getVpcName() {
return vpcName;
}

public void setVpcName(String vpcName) {
this.vpcName = vpcName;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@
// under the License.
package org.apache.cloudstack.agent.api;

import com.cloud.network.dao.NetworkVO;
public class DeleteNsxSegmentCommand extends NsxCommand {

public class DeleteNsxSegmentCommand extends CreateNsxSegmentCommand {
public DeleteNsxSegmentCommand(String zoneName, String accountName, String vpcName, NetworkVO network) {
super(zoneName, network.getDataCenterId(), accountName, network.getAccountId(), vpcName, network);
private String vpcName;
private String networkName;

public DeleteNsxSegmentCommand(String domainName, String accountName, String zoneName, String vpcName, String networkName) {
super(domainName, accountName, zoneName);
this.vpcName = vpcName;
this.networkName = networkName;
}

public String getVpcName() {
return vpcName;
}

public String getNetworkName() {
return networkName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@
// under the License.
package org.apache.cloudstack.agent.api;

public class DeleteNsxTier1GatewayCommand extends CreateNsxTier1GatewayCommand {
public class DeleteNsxTier1GatewayCommand extends NsxCommand {

public DeleteNsxTier1GatewayCommand(String zoneName, Long zoneId, String accountName, Long accountId, String vpcName) {
super(zoneName, zoneId, accountName, accountId, vpcName);
private String vpcName;

public DeleteNsxTier1GatewayCommand(String domainName, String accountName, String zoneName, String vpcName) {
super(domainName, accountName, zoneName);
this.vpcName = vpcName;
}

public String getVpcName() {
return vpcName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,27 @@

public class NsxCommand extends Command {
private String zoneName;
private Long zoneId;
private String accountName;
private Long accountId;
private String domainName;

public NsxCommand(String zoneName, Long zoneId, String accountName, Long accountId) {
public NsxCommand(String domainName, String accountName, String zoneName) {
this.zoneName = zoneName;
this.zoneId = zoneId;
this.accountName = accountName;
this.accountId = accountId;
this.domainName = domainName;
}

public String getZoneName() {
return zoneName;
}

public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}

public Long getZoneId() {
return zoneId;
}

public void setZoneId(Long zoneId) {
this.zoneId = zoneId;
}

public String getAccountName() {
return accountName;
}

public void setAccountName(String accountName) {
this.accountName = accountName;
public String getDomainName() {
return domainName;
}

public Long getAccountId() {
return accountId;
}

public void setAccountId(Long accountId) {
this.accountId = accountId;
}
@Override
public boolean executeInSequence() {
return false;
Expand All @@ -75,11 +54,11 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
NsxCommand that = (NsxCommand) o;
return Objects.equals(zoneName, that.zoneName) && Objects.equals(zoneId, that.zoneId) && Objects.equals(accountName, that.accountName) && Objects.equals(accountId, that.accountId);
return Objects.equals(zoneName, that.zoneName) && Objects.equals(accountName, that.accountName) && Objects.equals(domainName, that.domainName);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), zoneName, zoneId, accountName, accountId);
return Objects.hash(super.hashCode(), zoneName, accountName, domainName);
}
}
Loading