Merge branch 'apache:main' into Backroll

This commit is contained in:
PeterBackroll 2024-09-09 10:27:28 +02:00 committed by GitHub
commit f80a318a6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
574 changed files with 36235 additions and 2044 deletions

View File

@ -59,6 +59,7 @@ github:
- hsato03
- bernardodemarco
- abh1sar
- FelipeM525
protected_branches: ~

View File

@ -30,7 +30,7 @@ under the License.
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
<PatternLayout pattern="%d{ISO8601} %-5p [%c{3}] (%t:%x) (logid:%X{logcontextid}) %m%ex%n"/>
<PatternLayout pattern="%d{DEFAULT} %-5p [%c{3}] (%t:%x) (logid:%X{logcontextid}) %m%ex%n"/>
</RollingFile>
<!-- ============================== -->

View File

@ -504,6 +504,13 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
startup.setGuid(getResourceGuid());
startup.setResourceName(getResourceName());
startup.setVersion(getVersion());
startup.setArch(getAgentArch());
}
protected String getAgentArch() {
final Script command = new Script("/usr/bin/arch", 500, logger);
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
return command.execute(parser);
}
@Override
@ -858,11 +865,21 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
setId(ready.getHostId());
}
verifyAgentArch(ready.getArch());
processManagementServerList(ready.getMsHostList(), ready.getLbAlgorithm(), ready.getLbCheckInterval());
logger.info("Ready command is processed for agent id = {}", getId());
}
private void verifyAgentArch(String arch) {
if (StringUtils.isNotBlank(arch)) {
String agentArch = getAgentArch();
if (!arch.equals(agentArch)) {
logger.error("Unexpected arch {}, expected {}", agentArch, arch);
}
}
}
public void processOtherTask(final Task task) {
final Object obj = task.get();
if (obj instanceof Response) {

View File

@ -0,0 +1,50 @@
// 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 com.cloud.agent.api.to;
import org.apache.cloudstack.storage.object.Bucket;
public final class BucketTO {
private String name;
private String accessKey;
private String secretKey;
public BucketTO(Bucket bucket) {
this.name = bucket.getName();
this.accessKey = bucket.getAccessKey();
this.secretKey = bucket.getSecretKey();
}
public BucketTO(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public String getAccessKey() {
return this.accessKey;
}
public String getSecretKey() {
return this.secretKey;
}
}

View File

@ -155,9 +155,7 @@ public class FirewallRuleTO implements InternalIdentity {
rule.getIcmpType(),
rule.getIcmpCode());
this.trafficType = trafficType;
if (FirewallRule.Purpose.Ipv6Firewall.equals(purpose)) {
this.destCidrList = rule.getDestinationCidrList();
}
this.destCidrList = rule.getDestinationCidrList();
}
public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp, FirewallRule.Purpose purpose, FirewallRule.TrafficType trafficType,

View File

@ -0,0 +1,38 @@
// 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 com.cloud.bgp;
import org.apache.cloudstack.acl.InfrastructureEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import java.util.Date;
public interface ASNumber extends InfrastructureEntity, InternalIdentity, Identity {
Long getAccountId();
Long getDomainId();
long getAsNumber();
long getAsNumberRangeId();
long getDataCenterId();
Date getAllocatedTime();
boolean isAllocated();
Long getNetworkId();
Long getVpcId();
Date getCreated();
Date getRemoved();
}

View File

@ -0,0 +1,31 @@
// 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 com.cloud.bgp;
import org.apache.cloudstack.acl.InfrastructureEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import java.util.Date;
public interface ASNumberRange extends InfrastructureEntity, InternalIdentity, Identity {
long getStartASNumber();
long getEndASNumber();
long getDataCenterId();
Date getCreated();
}

View File

@ -0,0 +1,39 @@
// 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 com.cloud.bgp;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.vpc.Vpc;
import com.cloud.utils.Pair;
import org.apache.cloudstack.api.command.user.bgp.ListASNumbersCmd;
import java.util.List;
public interface BGPService {
ASNumberRange createASNumberRange(long zoneId, long startASNumber, long endASNumber);
List<ASNumberRange> listASNumberRanges(Long zoneId);
Pair<List<ASNumber>, Integer> listASNumbers(ListASNumbersCmd cmd);
boolean allocateASNumber(long zoneId, Long asNumber, Long networkId, Long vpcId);
Pair<Boolean, String> releaseASNumber(long zoneId, long asNumber, boolean isReleaseNetworkDestroy);
boolean deleteASRange(long id);
boolean applyBgpPeers(Network network, boolean continueOnError) throws ResourceUnavailableException;
boolean applyBgpPeers(Vpc vpc, boolean continueOnError) throws ResourceUnavailableException;
}

View File

@ -0,0 +1,67 @@
// 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 com.cloud.cpu;
import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.commons.lang3.StringUtils;
import java.util.LinkedHashMap;
import java.util.Map;
public class CPU {
public static final String archX86Identifier = "i686";
public static final String archX86_64Identifier = "x86_64";
public static final String archARM64Identifier = "aarch64";
public static class CPUArch {
private static final Map<String, CPUArch> cpuArchMap = new LinkedHashMap<>();
public static final CPUArch archX86 = new CPUArch(archX86Identifier, 32);
public static final CPUArch amd64 = new CPUArch(archX86_64Identifier, 64);
public static final CPUArch arm64 = new CPUArch(archARM64Identifier, 64);
private String type;
private int bits;
public CPUArch(String type, int bits) {
this.type = type;
this.bits = bits;
cpuArchMap.put(type, this);
}
public String getType() {
return this.type;
}
public int getBits() {
return this.bits;
}
public static CPUArch fromType(String type) {
if (StringUtils.isBlank(type)) {
return amd64;
}
switch (type) {
case archX86Identifier: return archX86;
case archX86_64Identifier: return amd64;
case archARM64Identifier: return arm64;
default: throw new CloudRuntimeException(String.format("Unsupported arch type: %s", type));
}
}
}
}

View File

@ -28,8 +28,12 @@ import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.PodResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.config.Configuration;
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
import org.apache.cloudstack.ha.HAConfig;
import org.apache.cloudstack.network.BgpPeer;
import org.apache.cloudstack.network.Ipv4GuestSubnetNetworkMap;
import org.apache.cloudstack.quota.QuotaTariff;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.object.Bucket;
import org.apache.cloudstack.storage.object.ObjectStore;
import org.apache.cloudstack.usage.Usage;
@ -393,6 +397,11 @@ public class EventTypes {
public static final String EVENT_VLAN_IP_RANGE_RELEASE = "VLAN.IP.RANGE.RELEASE";
public static final String EVENT_VLAN_IP_RANGE_UPDATE = "VLAN.IP.RANGE.UPDATE";
// AS Number
public static final String EVENT_AS_RANGE_CREATE = "AS.RANGE.CREATE";
public static final String EVENT_AS_RANGE_DELETE = "AS.RANGE.DELETE";
public static final String EVENT_AS_NUMBER_RELEASE = "AS.NUMBER.RELEASE";
public static final String EVENT_MANAGEMENT_IP_RANGE_CREATE = "MANAGEMENT.IP.RANGE.CREATE";
public static final String EVENT_MANAGEMENT_IP_RANGE_DELETE = "MANAGEMENT.IP.RANGE.DELETE";
public static final String EVENT_MANAGEMENT_IP_RANGE_UPDATE = "MANAGEMENT.IP.RANGE.UPDATE";
@ -451,6 +460,7 @@ public class EventTypes {
public static final String EVENT_MAINTENANCE_PREPARE_PRIMARY_STORAGE = "MAINT.PREPARE.PS";
// Primary storage pool
public static final String EVENT_UPDATE_PRIMARY_STORAGE = "UPDATE.PS";
public static final String EVENT_ENABLE_PRIMARY_STORAGE = "ENABLE.PS";
public static final String EVENT_DISABLE_PRIMARY_STORAGE = "DISABLE.PS";
public static final String EVENT_SYNC_STORAGE_POOL = "SYNC.STORAGE.POOL";
@ -743,6 +753,37 @@ public class EventTypes {
public static final String EVENT_QUOTA_TARIFF_DELETE = "QUOTA.TARIFF.DELETE";
public static final String EVENT_QUOTA_TARIFF_UPDATE = "QUOTA.TARIFF.UPDATE";
// Routing
public static final String EVENT_ZONE_IP4_SUBNET_CREATE = "ZONE.IP4.SUBNET.CREATE";
public static final String EVENT_ZONE_IP4_SUBNET_UPDATE = "ZONE.IP4.SUBNET.UPDATE";
public static final String EVENT_ZONE_IP4_SUBNET_DELETE = "ZONE.IP4.SUBNET.DELETE";
public static final String EVENT_ZONE_IP4_SUBNET_DEDICATE = "ZONE.IP4.SUBNET.DEDICATE";
public static final String EVENT_ZONE_IP4_SUBNET_RELEASE = "ZONE.IP4.SUBNET.RELEASE";
public static final String EVENT_IP4_GUEST_SUBNET_CREATE = "IP4.GUEST.SUBNET.CREATE";
public static final String EVENT_IP4_GUEST_SUBNET_DELETE = "IP4.GUEST.SUBNET.DELETE";
public static final String EVENT_ROUTING_IPV4_FIREWALL_RULE_CREATE = "ROUTING.IPV4.FIREWALL.RULE.CREATE";
public static final String EVENT_ROUTING_IPV4_FIREWALL_RULE_UPDATE = "ROUTING.IPV4.FIREWALL.RULE.UPDATE";
public static final String EVENT_ROUTING_IPV4_FIREWALL_RULE_DELETE = "ROUTING.IPV4.FIREWALL.RULE.DELETE";
public static final String EVENT_BGP_PEER_CREATE = "BGP.PEER.CREATE";
public static final String EVENT_BGP_PEER_UPDATE = "BGP.PEER.UPDATE";
public static final String EVENT_BGP_PEER_DELETE = "BGP.PEER.DELETE";
public static final String EVENT_BGP_PEER_DEDICATE = "BGP.PEER.DEDICATE";
public static final String EVENT_BGP_PEER_RELEASE = "BGP.PEER.RELEASE";
public static final String EVENT_NETWORK_BGP_PEER_UPDATE = "NETWORK.BGP.PEER.UPDATE";
public static final String EVENT_VPC_BGP_PEER_UPDATE = "VPC.BGP.PEER.UPDATE";
// SharedFS
public static final String EVENT_SHAREDFS_CREATE = "SHAREDFS.CREATE";
public static final String EVENT_SHAREDFS_START = "SHAREDFS.START";
public static final String EVENT_SHAREDFS_UPDATE = "SHAREDFS.UPDATE";
public static final String EVENT_SHAREDFS_CHANGE_SERVICE_OFFERING = "SHAREDFS.CHANGE.SERVICE.OFFERING";
public static final String EVENT_SHAREDFS_CHANGE_DISK_OFFERING = "SHAREDFS.CHANGE.DISK.OFFERING";
public static final String EVENT_SHAREDFS_STOP = "SHAREDFS.STOP";
public static final String EVENT_SHAREDFS_RESTART = "SHAREDFS.RESTART";
public static final String EVENT_SHAREDFS_DESTROY = "SHAREDFS.DESTROY";
public static final String EVENT_SHAREDFS_EXPUNGE = "SHAREDFS.EXPUNGE";
public static final String EVENT_SHAREDFS_RECOVER = "SHAREDFS.RECOVER";
static {
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
@ -1007,6 +1048,7 @@ public class EventTypes {
entityEventDetails.put(EVENT_MAINTENANCE_PREPARE_PRIMARY_STORAGE, Host.class);
// Primary storage pool
entityEventDetails.put(EVENT_UPDATE_PRIMARY_STORAGE, StoragePool.class);
entityEventDetails.put(EVENT_ENABLE_PRIMARY_STORAGE, StoragePool.class);
entityEventDetails.put(EVENT_DISABLE_PRIMARY_STORAGE, StoragePool.class);
entityEventDetails.put(EVENT_CHANGE_STORAGE_POOL_SCOPE, StoragePool.class);
@ -1201,6 +1243,35 @@ public class EventTypes {
entityEventDetails.put(EVENT_QUOTA_TARIFF_CREATE, QuotaTariff.class);
entityEventDetails.put(EVENT_QUOTA_TARIFF_DELETE, QuotaTariff.class);
entityEventDetails.put(EVENT_QUOTA_TARIFF_UPDATE, QuotaTariff.class);
// Routing
entityEventDetails.put(EVENT_ZONE_IP4_SUBNET_CREATE, DataCenterIpv4GuestSubnet.class);
entityEventDetails.put(EVENT_ZONE_IP4_SUBNET_UPDATE, DataCenterIpv4GuestSubnet.class);
entityEventDetails.put(EVENT_ZONE_IP4_SUBNET_DELETE, DataCenterIpv4GuestSubnet.class);
entityEventDetails.put(EVENT_ZONE_IP4_SUBNET_DEDICATE, DataCenterIpv4GuestSubnet.class);
entityEventDetails.put(EVENT_ZONE_IP4_SUBNET_RELEASE, DataCenterIpv4GuestSubnet.class);
entityEventDetails.put(EVENT_IP4_GUEST_SUBNET_CREATE, Ipv4GuestSubnetNetworkMap.class);
entityEventDetails.put(EVENT_IP4_GUEST_SUBNET_DELETE, Ipv4GuestSubnetNetworkMap.class);
entityEventDetails.put(EVENT_ROUTING_IPV4_FIREWALL_RULE_CREATE, FirewallRule.class);
entityEventDetails.put(EVENT_ROUTING_IPV4_FIREWALL_RULE_UPDATE, FirewallRule.class);
entityEventDetails.put(EVENT_ROUTING_IPV4_FIREWALL_RULE_DELETE, FirewallRule.class);
entityEventDetails.put(EVENT_BGP_PEER_CREATE, BgpPeer.class);
entityEventDetails.put(EVENT_BGP_PEER_UPDATE, BgpPeer.class);
entityEventDetails.put(EVENT_BGP_PEER_DELETE, BgpPeer.class);
entityEventDetails.put(EVENT_BGP_PEER_DEDICATE, BgpPeer.class);
entityEventDetails.put(EVENT_BGP_PEER_RELEASE, BgpPeer.class);
// SharedFS
entityEventDetails.put(EVENT_SHAREDFS_CREATE, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_START, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_STOP, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_UPDATE, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_CHANGE_SERVICE_OFFERING, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_CHANGE_DISK_OFFERING, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_RESTART, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_DESTROY, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_EXPUNGE, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_RECOVER, SharedFS.class);
}
public static boolean isNetworkEvent(String eventType) {

View File

@ -16,6 +16,7 @@
// under the License.
package com.cloud.host;
import com.cloud.cpu.CPU;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.resource.ResourceState;
import com.cloud.utils.fsm.StateObject;
@ -208,4 +209,6 @@ public interface Host extends StateObject<Status>, Identity, Partition, HAResour
boolean isDisabled();
ResourceState getResourceState();
CPU.CPUArch getArch();
}

View File

@ -103,7 +103,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
public static final Service Vpn = new Service("Vpn", Capability.SupportedVpnProtocols, Capability.VpnTypes);
public static final Service Dhcp = new Service("Dhcp", Capability.ExtraDhcpOptions);
public static final Service Dns = new Service("Dns", Capability.AllowDnsSuffixModification);
public static final Service Gateway = new Service("Gateway");
public static final Service Gateway = new Service("Gateway", Capability.RedundantRouter);
public static final Service Firewall = new Service("Firewall", Capability.SupportedProtocols, Capability.MultipleIps, Capability.TrafficStatistics,
Capability.SupportedTrafficDirection, Capability.SupportedEgressProtocols);
public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms, Capability.SupportedLBIsolation, Capability.SupportedProtocols,
@ -412,12 +412,16 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
String getGateway();
void setGateway(String gateway);
// "cidr" is the Cloudstack managed address space, all CloudStack managed vms get IP address from "cidr",
// In general "cidr" also serves as the network CIDR
// But in case IP reservation is configured for a Guest network, "networkcidr" is the Effective network CIDR for that network,
// "cidr" will still continue to be the effective address space for CloudStack managed vms in that Guest network
String getCidr();
void setCidr(String cidr);
// "networkcidr" is the network CIDR of the guest network which uses IP reservation.
// It is the summation of "cidr" and the reservedIPrange(the address space used for non CloudStack purposes).
// For networks not configured with IP reservation, "networkcidr" is always null
@ -503,4 +507,6 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
Integer getPublicMtu();
Integer getPrivateMtu();
Integer getNetworkCidrSize();
}

View File

@ -173,6 +173,8 @@ public interface NetworkModel {
boolean isProviderSupportServiceInNetwork(long networkId, Service service, Provider provider);
boolean isAnyServiceSupportedInNetwork(long networkId, Provider provider, Service... services);
boolean isProviderEnabledInPhysicalNetwork(long physicalNetowrkId, String providerName);
String getNetworkTag(HypervisorType hType, Network network);
@ -356,4 +358,8 @@ public interface NetworkModel {
void verifyIp6DnsPair(final String ip6Dns1, final String ip6Dns2);
boolean isSecurityGroupSupportedForZone(Long zoneId);
boolean checkSecurityGroupSupportForNetwork(DataCenter zone, List<Long> networkIds,
List<Long> securityGroupsIds);
}

View File

@ -41,8 +41,8 @@ public class NetworkProfile implements Network {
private final Mode mode;
private final BroadcastDomainType broadcastDomainType;
private TrafficType trafficType;
private final String gateway;
private final String cidr;
private String gateway;
private String cidr;
private final String networkCidr;
private final String ip6Gateway;
private final String ip6Cidr;
@ -62,6 +62,7 @@ public class NetworkProfile implements Network {
private final String guruName;
private boolean strechedL2Subnet;
private String externalId;
private Integer networkCidrSize;
public NetworkProfile(Network network) {
id = network.getId();
@ -98,6 +99,7 @@ public class NetworkProfile implements Network {
isRedundant = network.isRedundant();
isRollingRestart = network.isRollingRestart();
externalId = network.getExternalId();
networkCidrSize = network.getNetworkCidrSize();
}
@Override
@ -210,11 +212,21 @@ public class NetworkProfile implements Network {
return gateway;
}
@Override
public void setGateway(String gateway) {
this.gateway = gateway;
}
@Override
public String getCidr() {
return cidr;
}
@Override
public void setCidr(String cidr) {
this.cidr = cidr;
}
@Override
public String getNetworkCidr() {
return networkCidr;
@ -367,4 +379,9 @@ public class NetworkProfile implements Network {
return null;
}
@Override
public Integer getNetworkCidrSize() {
return networkCidrSize;
}
}

View File

@ -0,0 +1,31 @@
// 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 com.cloud.network.element;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.vpc.Vpc;
import org.apache.cloudstack.network.BgpPeer;
import java.util.List;
public interface BgpServiceProvider extends NetworkElement {
boolean applyBgpPeers(Vpc vpc, Network network, List<? extends BgpPeer> bgpPeers) throws ResourceUnavailableException;
}

View File

@ -18,9 +18,19 @@ package com.cloud.network.nsx;
import com.cloud.network.IpAddress;
import com.cloud.network.vpc.Vpc;
import org.apache.cloudstack.framework.config.ConfigKey;
public interface NsxService {
ConfigKey<Integer> NSX_API_FAILURE_RETRIES = new ConfigKey<>("Advanced", Integer.class,
"nsx.api.failure.retries", "30",
"Number of retries for NSX API operations in case of failures",
true, ConfigKey.Scope.Zone);
ConfigKey<Integer> NSX_API_FAILURE_INTERVAL = new ConfigKey<>("Advanced", Integer.class,
"nsx.api.failure.interval", "60",
"Waiting time (in seconds) before retrying an NSX API operation in case of failure",
true, ConfigKey.Scope.Zone);
boolean createVpcNetwork(Long zoneId, long accountId, long domainId, Long vpcId, String vpcName, boolean sourceNatEnabled);
boolean updateVpcSourceNatIp(Vpc vpc, IpAddress address);
}

View File

@ -18,6 +18,7 @@ package com.cloud.network.vpc;
import java.util.Date;
import com.cloud.offering.NetworkOffering;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
@ -57,7 +58,7 @@ public interface VpcOffering extends InternalIdentity, Identity {
boolean isForNsx();
String getNsxMode();
NetworkOffering.NetworkMode getNetworkMode();
/**
* @return service offering id used by VPC virtual router
@ -79,4 +80,8 @@ public interface VpcOffering extends InternalIdentity, Identity {
Date getRemoved();
Date getCreated();
NetworkOffering.RoutingMode getRoutingMode();
Boolean isSpecifyAsNumber();
}

View File

@ -24,6 +24,7 @@ import org.apache.cloudstack.api.command.admin.vpc.CreateVPCOfferingCmd;
import org.apache.cloudstack.api.command.admin.vpc.UpdateVPCOfferingCmd;
import org.apache.cloudstack.api.command.user.vpc.ListVPCOfferingsCmd;
import com.cloud.offering.NetworkOffering;
import com.cloud.utils.Pair;
import com.cloud.utils.net.NetUtils;
@ -36,8 +37,10 @@ public interface VpcProvisioningService {
VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices,
Map<String, List<String>> serviceProviders,
Map serviceCapabilitystList, NetUtils.InternetProtocol internetProtocol,
Long serviceOfferingId, Boolean forNsx, String mode,
List<Long> domainIds, List<Long> zoneIds, VpcOffering.State state);
Long serviceOfferingId, Boolean forNsx, NetworkOffering.NetworkMode networkMode,
List<Long> domainIds, List<Long> zoneIds, VpcOffering.State state,
NetworkOffering.RoutingMode routingMode, boolean specifyAsNumber);
Pair<List<? extends VpcOffering>,Integer> listVpcOfferings(ListVPCOfferingsCmd cmd);

View File

@ -56,7 +56,8 @@ public interface VpcService {
* @throws ResourceAllocationException TODO
*/
Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain,
String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc, Integer publicMtu)
String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc, Integer publicMtu, Integer cidrSize,
Long asNumber, List<Long> bgpPeerIds)
throws ResourceAllocationException;
/**

View File

@ -43,11 +43,15 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
InternalLbProvider, PublicLbProvider, servicepackageuuid, servicepackagedescription, PromiscuousMode, MacAddressChanges, ForgedTransmits, MacLearning, RelatedNetworkOffering, domainid, zoneid, pvlanType, internetProtocol
}
public enum NsxMode {
public enum NetworkMode {
NATTED,
ROUTED
}
enum RoutingMode {
Static, Dynamic
}
public final static String SystemPublicNetwork = "System-Public-Network";
public final static String SystemControlNetwork = "System-Control-Network";
public final static String SystemManagementNetwork = "System-Management-Network";
@ -102,7 +106,7 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
boolean isForNsx();
String getNsxMode();
NetworkMode getNetworkMode();
TrafficType getTrafficType();
@ -165,4 +169,8 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
String getServicePackage();
Date getCreated();
RoutingMode getRoutingMode();
Boolean isSpecifyAsNumber();
}

View File

@ -16,6 +16,7 @@
// under the License.
package com.cloud.org;
import com.cloud.cpu.CPU;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.org.Managed.ManagedState;
import org.apache.cloudstack.kernel.Partition;
@ -38,4 +39,6 @@ public interface Cluster extends Grouping, Partition {
AllocationState getAllocationState();
ManagedState getManagedState();
CPU.CPUArch getArch();
}

View File

@ -95,6 +95,10 @@ public interface StorageService {
StoragePool updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException;
StoragePool enablePrimaryStoragePool(Long id);
StoragePool disablePrimaryStoragePool(Long id);
StoragePool getStoragePool(long id);
boolean deleteImageStore(DeleteImageStoreCmd cmd);

View File

@ -102,8 +102,12 @@ public interface VolumeApiService {
boolean deleteVolume(long volumeId, Account caller);
Volume changeDiskOfferingForVolumeInternal(Long volumeId, Long newDiskOfferingId, Long newSize, Long newMinIops, Long newMaxIops, boolean autoMigrateVolume, boolean shrinkOk) throws ResourceAllocationException;
Volume attachVolumeToVM(AttachVolumeCmd command);
Volume attachVolumeToVM(Long vmId, Long volumeId, Long deviceId, Boolean allowAttachForSharedFS);
Volume detachVolumeViaDestroyVM(long vmId, long volumeId);
Volume detachVolumeFromVM(DetachVolumeCmd cmd);

View File

@ -19,6 +19,7 @@ package com.cloud.template;
import java.util.Date;
import java.util.Map;
import com.cloud.cpu.CPU;
import com.cloud.user.UserData;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Identity;
@ -148,4 +149,6 @@ public interface VirtualMachineTemplate extends ControlledEntity, Identity, Inte
UserData.UserDataOverridePolicy getUserDataOverridePolicy();
CPU.CPUArch getArch();
}

View File

@ -333,6 +333,8 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Partition,
*/
Date getCreated();
Date getRemoved();
long getServiceOfferingId();
Long getBackupOfferingId();

View File

@ -85,7 +85,8 @@ public enum ApiCommandResourceType {
Bucket(org.apache.cloudstack.storage.object.Bucket.class),
QuotaTariff(org.apache.cloudstack.quota.QuotaTariff.class),
KubernetesCluster(null),
KubernetesSupportedVersion(null);
KubernetesSupportedVersion(null),
SharedFS(org.apache.cloudstack.storage.sharedfs.SharedFS.class);
private final Class<?> clazz;

View File

@ -29,10 +29,18 @@ public class ApiConstants {
public static final String ADDRESS = "address";
public static final String ALGORITHM = "algorithm";
public static final String ALIAS = "alias";
public static final String ALLOCATED_DATE = "allocateddate";
public static final String ALLOCATED_ONLY = "allocatedonly";
public static final String ALLOCATED_TIME = "allocated";
public static final String ALLOW_USER_FORCE_STOP_VM = "allowuserforcestopvm";
public static final String ANNOTATION = "annotation";
public static final String API_KEY = "apikey";
public static final String ARCHIVED = "archived";
public static final String ARCH = "arch";
public static final String AS_NUMBER = "asnumber";
public static final String AS_NUMBER_ID = "asnumberid";
public static final String ASN_RANGE = "asnrange";
public static final String ASN_RANGE_ID = "asnrangeid";
public static final String ASYNC_BACKUP = "asyncbackup";
public static final String AUTO_SELECT = "autoselect";
public static final String USER_API_KEY = "userapikey";
@ -46,6 +54,8 @@ public class ApiConstants {
public static final String BACKUP_OFFERING_NAME = "backupofferingname";
public static final String BACKUP_OFFERING_ID = "backupofferingid";
public static final String BASE64_IMAGE = "base64image";
public static final String BGP_PEERS = "bgppeers";
public static final String BGP_PEER_IDS = "bgppeerids";
public static final String BITS = "bits";
public static final String BOOTABLE = "bootable";
public static final String BIND_DN = "binddn";
@ -87,6 +97,8 @@ public class ApiConstants {
public static final String DNS_SEARCH_ORDER = "dnssearchorder";
public static final String CHAIN_INFO = "chaininfo";
public static final String CIDR = "cidr";
public static final String CIDR_SIZE = "cidrsize";
public static final String IP6_CIDR = "ip6cidr";
public static final String CIDR_LIST = "cidrlist";
public static final String DEST_CIDR_LIST = "destcidrlist";
@ -170,6 +182,7 @@ public class ApiConstants {
public static final String DURATION = "duration";
public static final String ELIGIBLE = "eligible";
public static final String EMAIL = "email";
public static final String END_ASN = "endasn";
public static final String END_DATE = "enddate";
public static final String END_IP = "endip";
public static final String END_IPV6 = "endipv6";
@ -187,6 +200,7 @@ public class ApiConstants {
public static final String EXTERNAL_UUID = "externaluuid";
public static final String FENCE = "fence";
public static final String FETCH_LATEST = "fetchlatest";
public static final String FILESYSTEM = "filesystem";
public static final String FIRSTNAME = "firstname";
public static final String FORCED = "forced";
public static final String FORCED_DESTROY_LOCAL_STORAGE = "forcedestroylocalstorage";
@ -313,7 +327,9 @@ public class ApiConstants {
public static final String MIGRATIONS = "migrations";
public static final String MEMORY = "memory";
public static final String MODE = "mode";
public static final String MULTI_ARCH = "ismultiarch";
public static final String NSX_MODE = "nsxmode";
public static final String NETWORK_MODE = "networkmode";
public static final String NSX_ENABLED = "isnsxenabled";
public static final String NAME = "name";
public static final String METHOD_NAME = "methodname";
@ -354,6 +370,7 @@ public class ApiConstants {
public static final String PARENT = "parent";
public static final String PARENT_ID = "parentid";
public static final String PARENT_DOMAIN_ID = "parentdomainid";
public static final String PARENT_SUBNET = "parentsubnet";
public static final String PARENT_TEMPLATE_ID = "parenttemplateid";
public static final String PASSWORD = "password";
public static final String CURRENT_PASSWORD = "currentpassword";
@ -431,6 +448,7 @@ public class ApiConstants {
public static final String SIGNATURE_VERSION = "signatureversion";
public static final String SINCE = "since";
public static final String SIZE = "size";
public static final String SIZEGB = "sizegb";
public static final String SNAPSHOT = "snapshot";
public static final String SNAPSHOT_ID = "snapshotid";
public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
@ -438,6 +456,7 @@ public class ApiConstants {
public static final String SNAPSHOT_QUIESCEVM = "quiescevm";
public static final String SOURCE_ZONE_ID = "sourcezoneid";
public static final String SSL_VERIFICATION = "sslverification";
public static final String START_ASN = "startasn";
public static final String START_DATE = "startdate";
public static final String START_ID = "startid";
public static final String START_IP = "startip";
@ -503,6 +522,7 @@ public class ApiConstants {
public static final String VIRTUAL_MACHINE_ID_IP = "vmidipmap";
public static final String VIRTUAL_MACHINE_COUNT = "virtualmachinecount";
public static final String VIRTUAL_MACHINE_TYPE = "virtualmachinetype";
public static final String VIRTUAL_MACHINE_STATE = "vmstate";
public static final String VIRTUAL_MACHINES = "virtualmachines";
public static final String USAGE_ID = "usageid";
public static final String USAGE_TYPE = "usagetype";
@ -515,6 +535,7 @@ public class ApiConstants {
public static final String ISOLATED_PVLAN = "isolatedpvlan";
public static final String ISOLATED_PVLAN_TYPE = "isolatedpvlantype";
public static final String ISOLATION_URI = "isolationuri";
public static final String IS_ALLOCATED = "isallocated";
public static final String IS_DEDICATED = "isdedicated";
public static final String TAKEN = "taken";
public static final String VM_AVAILABLE = "vmavailable";
@ -543,6 +564,7 @@ public class ApiConstants {
public static final String NETWORK_ID = "networkid";
public static final String NETWORK_FILTER = "networkfilter";
public static final String NIC_ID = "nicid";
public static final String SPECIFY_AS_NUMBER = "specifyasnumber";
public static final String SPECIFY_VLAN = "specifyvlan";
public static final String IS_DEFAULT = "isdefault";
public static final String IS_SYSTEM = "issystem";
@ -684,6 +706,8 @@ public class ApiConstants {
public static final String ASSOCIATED_NETWORK = "associatednetwork";
public static final String ASSOCIATED_NETWORK_ID = "associatednetworkid";
public static final String ASSOCIATED_NETWORK_NAME = "associatednetworkname";
public static final String ASSOCIATED_VPC_ID = "associatedvpcid";
public static final String ASSOCIATED_VPC_NAME = "associatedvpcname";
public static final String SOURCE_NAT_SUPPORTED = "sourcenatsupported";
public static final String RESOURCE_STATE = "resourcestate";
public static final String PROJECT_INVITE_REQUIRED = "projectinviterequired";
@ -699,6 +723,8 @@ public class ApiConstants {
public static final String LIST_ONLY_REMOVED = "listonlyremoved";
public static final String LIST_SYSTEM_VMS = "listsystemvms";
public static final String IP_RANGES = "ipranges";
public static final String IPV4_ROUTING = "ip4routing";
public static final String IPV4_ROUTES = "ip4routes";
public static final String IPV6_ROUTING = "ip6routing";
public static final String IPV6_ROUTES = "ip6routes";
public static final String SPECIFY_IP_RANGES = "specifyipranges";
@ -960,6 +986,7 @@ public class ApiConstants {
public static final String NUMBER = "number";
public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable";
public static final String ROUTING = "isrouting";
public static final String ROUTING_MODE = "routingmode";
public static final String MAX_CONNECTIONS = "maxconnections";
public static final String SERVICE_STATE = "servicestate";
@ -1141,6 +1168,10 @@ public class ApiConstants {
public static final String WEBHOOK_NAME = "webhookname";
public static final String NFS_MOUNT_OPTIONS = "nfsmountopts";
public static final String MOUNT_OPTIONS = "mountopts";
public static final String SHAREDFSVM_MIN_CPU_COUNT = "sharedfsvmmincpucount";
public static final String SHAREDFSVM_MIN_RAM_SIZE = "sharedfsvmminramsize";
public static final String PARAMETER_DESCRIPTION_ACTIVATION_RULE = "Quota tariff's activation rule. It can receive a JS script that results in either " +
"a boolean or a numeric value: if it results in a boolean value, the tariff value will be applied according to the result; if it results in a numeric value, the " +

View File

@ -31,6 +31,7 @@ import java.util.regex.Pattern;
import javax.inject.Inject;
import com.cloud.bgp.BGPService;
import org.apache.cloudstack.acl.ProjectRoleService;
import org.apache.cloudstack.acl.RoleService;
import org.apache.cloudstack.acl.RoleType;
@ -38,6 +39,7 @@ import org.apache.cloudstack.affinity.AffinityGroupService;
import org.apache.cloudstack.alert.AlertService;
import org.apache.cloudstack.annotation.AnnotationService;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.network.RoutedIpv4Manager;
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
import org.apache.cloudstack.query.QueryService;
@ -217,7 +219,11 @@ public abstract class BaseCmd {
public VnfTemplateManager vnfTemplateManager;
@Inject
public BucketApiService _bucketService;
@Inject
public BGPService bgpService;
@Inject
public RoutedIpv4Manager routedIpv4Manager;
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException, NetworkRuleConflictException;

View File

@ -16,8 +16,10 @@
// under the License.
package org.apache.cloudstack.api;
import com.cloud.cpu.CPU;
import org.apache.cloudstack.api.response.GuestOSResponse;
import org.apache.cloudstack.api.response.TemplateResponse;
import org.apache.commons.lang3.StringUtils;
import java.util.Collection;
import java.util.Map;
@ -77,6 +79,11 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
description = "optional boolean field, which indicates if details should be cleaned up or not (if set to true, details removed for this resource, details field ignored; if false or not set, no action)")
private Boolean cleanupDetails;
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
description = "the CPU arch of the template/ISO. Valid options are: x86_64, aarch64",
since = "4.20")
private String arch;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -141,4 +148,11 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
public boolean isCleanupDetails(){
return cleanupDetails == null ? false : cleanupDetails.booleanValue();
}
public CPU.CPUArch getCPUArch() {
if (StringUtils.isBlank(arch)) {
return null;
}
return CPU.CPUArch.fromType(arch);
}
}

View File

@ -22,6 +22,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.cloud.bgp.ASNumber;
import com.cloud.bgp.ASNumberRange;
import org.apache.cloudstack.storage.object.Bucket;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
@ -31,11 +34,14 @@ import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
import org.apache.cloudstack.api.response.AccountResponse;
import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
import org.apache.cloudstack.api.response.ASNRangeResponse;
import org.apache.cloudstack.api.response.ASNumberResponse;
import org.apache.cloudstack.api.response.AsyncJobResponse;
import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
import org.apache.cloudstack.api.response.BackupOfferingResponse;
import org.apache.cloudstack.api.response.BackupRepositoryResponse;
import org.apache.cloudstack.api.response.BackupResponse;
import org.apache.cloudstack.api.response.BackupScheduleResponse;
import org.apache.cloudstack.api.response.BucketResponse;
@ -54,6 +60,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.DomainRouterResponse;
import org.apache.cloudstack.api.response.EventResponse;
import org.apache.cloudstack.api.response.ExtractResponse;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.api.response.FirewallResponse;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
@ -139,6 +146,7 @@ import org.apache.cloudstack.api.response.VpnUsersResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.backup.Backup;
import org.apache.cloudstack.backup.BackupOffering;
import org.apache.cloudstack.backup.BackupRepository;
import org.apache.cloudstack.backup.BackupSchedule;
import org.apache.cloudstack.config.Configuration;
import org.apache.cloudstack.config.ConfigurationGroup;
@ -151,6 +159,7 @@ import org.apache.cloudstack.region.PortableIp;
import org.apache.cloudstack.region.PortableIpRange;
import org.apache.cloudstack.region.Region;
import org.apache.cloudstack.secstorage.heuristics.Heuristic;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.object.ObjectStore;
import org.apache.cloudstack.usage.Usage;
@ -551,4 +560,12 @@ public interface ResponseGenerator {
ObjectStoreResponse createObjectStoreResponse(ObjectStore os);
BucketResponse createBucketResponse(Bucket bucket);
ASNRangeResponse createASNumberRangeResponse(ASNumberRange asnRange);
ASNumberResponse createASNumberResponse(ASNumber asn);
BackupRepositoryResponse createBackupRepositoryResponse(BackupRepository repository);
SharedFSResponse createSharedFSResponse(ResponseView view, SharedFS sharedFS);
}

View File

@ -0,0 +1,83 @@
// 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.api.command.admin.bgp;
import com.cloud.bgp.ASNumberRange;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ASNRangeResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
@APICommand(name = "createASNRange",
description = "Creates a range of Autonomous Systems for BGP Dynamic Routing",
responseObject = ASNRangeResponse.class,
entityType = {ASNumberRange.class},
since = "4.20.0",
authorized = {RoleType.Admin})
public class CreateASNRangeCmd extends BaseCmd {
@Parameter(name = ApiConstants.ZONE_ID, type = BaseCmd.CommandType.UUID, entityType = ZoneResponse.class,
description = "the zone ID", required = true)
private Long zoneId;
@Parameter(name = ApiConstants.START_ASN, type = CommandType.LONG, required=true, description = "the start AS Number")
private Long startASNumber;
@Parameter(name = ApiConstants.END_ASN, type = CommandType.LONG, required=true, description = "the end AS Number")
private Long endASNumber;
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
try {
ASNumberRange asnRange = bgpService.createASNumberRange(zoneId, startASNumber, endASNumber);
ASNRangeResponse response = _responseGenerator.createASNumberRangeResponse(asnRange);
response.setResponseName(getCommandName());
setResponseObject(response);
} catch (Exception e) {
String msg = String.format("Cannot create AS Number Range %s-%s for zone %s: %s", startASNumber, endASNumber, zoneId, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
}
}
public Long getZoneId() {
return zoneId;
}
public Long getStartASNumber() {
return startASNumber;
}
public Long getEndASNumber() {
return endASNumber;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -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.api.command.admin.bgp;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ASNRangeResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext;
@APICommand(name = "deleteASNRange",
description = "deletes a range of Autonomous Systems for BGP Dynamic Routing",
responseObject = SuccessResponse.class,
since = "4.20.0",
authorized = {RoleType.Admin})
public class DeleteASNRangeCmd extends BaseCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
entityType = ASNRangeResponse.class,
required = true,
description = "ID of the AS range")
private Long id;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
if (bgpService.deleteASRange(getId())) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove AS range: " + getId());
}
}
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
}

View File

@ -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.api.command.admin.bgp;
import com.cloud.bgp.ASNumberRange;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ASNRangeResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import java.util.ArrayList;
import java.util.List;
@APICommand(name = "listASNRanges",
description = "List Autonomous Systems Number Ranges",
responseObject = ASNRangeResponse.class,
entityType = {ASNumberRange.class},
since = "4.20.0",
authorized = {RoleType.Admin})
public class ListASNRangesCmd extends BaseListCmd {
@Parameter(name = ApiConstants.ZONE_ID, type = BaseCmd.CommandType.UUID, entityType = ZoneResponse.class,
description = "the zone ID")
private Long zoneId;
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
try {
List<ASNumberRange> ranges = bgpService.listASNumberRanges(zoneId);
ListResponse<ASNRangeResponse> response = new ListResponse<>();
List<ASNRangeResponse> responses = new ArrayList<>();
for (ASNumberRange asnRange : ranges) {
responses.add(_responseGenerator.createASNumberRangeResponse(asnRange));
}
response.setResponses(responses);
response.setResponseName(getCommandName());
setResponseObject(response);
} catch (Exception e) {
String msg = String.format("Error listing AS Number Ranges: %s", e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
}
}
public Long getZoneId() {
return zoneId;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,83 @@
// 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.api.command.admin.bgp;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
@APICommand(name = "releaseASNumber",
description = "Releases an AS Number back to the pool",
since = "4.20.0",
authorized = {RoleType.Admin},
responseObject = SuccessResponse.class,
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false)
public class ReleaseASNumberCmd extends BaseCmd {
@Parameter(name = ApiConstants.ZONE_ID, type = BaseCmd.CommandType.UUID, entityType = ZoneResponse.class,
description = "the zone ID", required = true)
private Long zoneId;
@Parameter(name= ApiConstants.AS_NUMBER, type=CommandType.LONG, description="the AS Number to be released",
required = true)
private Long asNumber;
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
try {
Pair<Boolean, String> resultPair = bgpService.releaseASNumber(zoneId, asNumber, false);
Boolean result = resultPair.first();
if (!result) {
String details = resultPair.second();
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Cannot release AS Number %s: %s", asNumber, details));
}
SuccessResponse response = new SuccessResponse(getCommandName());
response.setDisplayText(String.format("AS Number %s is released successfully", asNumber));
setResponseObject(response);
} catch (Exception e) {
String msg = String.format("Error releasing AS Number %s: %s", asNumber, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
}
}
public Long getZoneId() {
return zoneId;
}
public Long getAsNumber() {
return asNumber;
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -20,6 +20,7 @@ package org.apache.cloudstack.api.command.admin.cluster;
import java.util.ArrayList;
import java.util.List;
import com.cloud.cpu.CPU;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.APICommand;
@ -67,6 +68,11 @@ public class AddClusterCmd extends BaseCmd {
description = "hypervisor type of the cluster: XenServer,KVM,VMware,Hyperv,BareMetal,Simulator,Ovm3")
private String hypervisor;
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
description = "the CPU arch of the cluster. Valid options are: x86_64, aarch64",
since = "4.20")
private String arch;
@Parameter(name = ApiConstants.CLUSTER_TYPE, type = CommandType.STRING, required = true, description = "type of the cluster: CloudManaged, ExternalManaged")
private String clusterType;
@ -204,6 +210,10 @@ public class AddClusterCmd extends BaseCmd {
return ApiCommandResourceType.Cluster;
}
public CPU.CPUArch getArch() {
return CPU.CPUArch.fromType(arch);
}
@Override
public void execute() {
try {

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.admin.cluster;
import com.cloud.cpu.CPU;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.APICommand;
@ -29,6 +30,7 @@ import org.apache.cloudstack.api.response.ClusterResponse;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.org.Cluster;
import com.cloud.user.Account;
import org.apache.commons.lang3.StringUtils;
@APICommand(name = "updateCluster", description = "Updates an existing cluster", responseObject = ClusterResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
@ -53,6 +55,11 @@ public class UpdateClusterCmd extends BaseCmd {
@Parameter(name = ApiConstants.MANAGED_STATE, type = CommandType.STRING, description = "whether this cluster is managed by cloudstack")
private String managedState;
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
description = "the CPU arch of the cluster. Valid options are: x86_64, aarch64",
since = "4.20")
private String arch;
public String getClusterName() {
return clusterName;
}
@ -108,6 +115,13 @@ public class UpdateClusterCmd extends BaseCmd {
return ApiCommandResourceType.Cluster;
}
public CPU.CPUArch getArch() {
if (StringUtils.isBlank(arch)) {
return null;
}
return CPU.CPUArch.fromType(arch);
}
@Override
public void execute() {
Cluster cluster = _resourceService.getCluster(getId());

View File

@ -0,0 +1,108 @@
// 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.api.command.admin.network;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
import org.apache.cloudstack.api.response.Ipv4SubnetForGuestNetworkResponse;
import com.cloud.event.EventTypes;
import com.cloud.user.Account;
import org.apache.cloudstack.network.Ipv4GuestSubnetNetworkMap;
@APICommand(name = "createIpv4SubnetForGuestNetwork",
description = "Creates a IPv4 subnet for guest networks.",
responseObject = Ipv4SubnetForGuestNetworkResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class CreateIpv4SubnetForGuestNetworkCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.PARENT_ID,
type = CommandType.UUID,
entityType = DataCenterIpv4SubnetResponse.class,
required = true,
description = "The zone Ipv4 subnet which the IPv4 subnet belongs to.")
private Long parentId;
@Parameter(name = ApiConstants.SUBNET,
type = CommandType.STRING,
description = "The CIDR of this Ipv4 subnet.")
private String subnet;
@Parameter(name = ApiConstants.CIDR_SIZE,
type = CommandType.INTEGER,
description = "the CIDR size of IPv4 network. This is mutually exclusive with subnet.")
private Integer cidrSize;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getParentId() {
return parentId;
}
public String getSubnet() {
return subnet;
}
public Integer getCidrSize() {
return cidrSize;
}
@Override
public String getEventType() {
return EventTypes.EVENT_IP4_GUEST_SUBNET_CREATE;
}
@Override
public String getEventDescription() {
return "Creating guest IPv4 subnet " + getSubnet() + " in zone subnet=" + getParentId();
}
@Override
public void execute() {
Ipv4GuestSubnetNetworkMap result = routedIpv4Manager.createIpv4SubnetForGuestNetwork(this);
if (result != null) {
Ipv4SubnetForGuestNetworkResponse response = routedIpv4Manager.createIpv4SubnetForGuestNetworkResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create zone guest IPv4 subnet.");
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,125 @@
// 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.api.command.admin.network;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
import com.cloud.event.EventTypes;
import com.cloud.user.Account;
@APICommand(name = "createIpv4SubnetForZone",
description = "Creates a IPv4 subnet for a zone.",
responseObject = DataCenterIpv4SubnetResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class CreateIpv4SubnetForZoneCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.UUID,
entityType = ZoneResponse.class,
required = true,
description = "UUID of the zone which the IPv4 subnet belongs to.",
validations = {ApiArgValidator.PositiveNumber})
private Long zoneId;
@Parameter(name = ApiConstants.SUBNET,
type = CommandType.STRING,
required = true,
description = "The CIDR of the IPv4 subnet.")
private String subnet;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "account who will own the IPv4 subnet")
private String accountName;
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "project who will own the IPv4 subnet")
private Long projectId;
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "domain ID of the account owning the IPv4 subnet")
private Long domainId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getZoneId() {
return zoneId;
}
public String getSubnet() {
return subnet;
}
public String getAccountName() {
return accountName;
}
public Long getProjectId() {
return projectId;
}
public Long getDomainId() {
return domainId;
}
@Override
public String getEventType() {
return EventTypes.EVENT_ZONE_IP4_SUBNET_CREATE;
}
@Override
public String getEventDescription() {
return "Creating guest IPv4 subnet " + getSubnet() + " for zone=" + getZoneId();
}
@Override
public void execute() {
DataCenterIpv4GuestSubnet result = routedIpv4Manager.createDataCenterIpv4GuestSubnet(this);
if (result != null) {
DataCenterIpv4SubnetResponse response = routedIpv4Manager.createDataCenterIpv4SubnetResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create zone guest IPv4 subnet.");
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -24,10 +24,13 @@ import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.command.admin.AdminCmd;
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
import org.apache.cloudstack.api.response.BgpPeerResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import com.cloud.network.Network;
import java.util.List;
@APICommand(name = "createNetwork", description = "Creates a network", responseObject = NetworkResponse.class, responseView = ResponseView.Full, entityType = {Network.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class CreateNetworkCmdByAdmin extends CreateNetworkCmd implements AdminCmd {
@ -49,6 +52,14 @@ public class CreateNetworkCmdByAdmin extends CreateNetworkCmd implements AdminCm
validations = {ApiArgValidator.NotNullOrEmpty})
private String routerIpv6;
@Parameter(name = ApiConstants.BGP_PEER_IDS,
type = CommandType.LIST,
collectionType = CommandType.UUID,
entityType = BgpPeerResponse.class,
description = "Ids of the Bgp Peer for the network",
since = "4.20.0")
private List<Long> bgpPeerIds;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -78,4 +89,8 @@ public class CreateNetworkCmdByAdmin extends CreateNetworkCmd implements AdminCm
public String getRouterIpv6() {
return routerIpv6;
}
public List<Long> getBgpPeerIds() {
return bgpPeerIds;
}
}

View File

@ -146,12 +146,6 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
since = "4.20.0")
private Boolean forNsx;
@Parameter(name = ApiConstants.NSX_MODE,
type = CommandType.STRING,
description = "Indicates the mode with which the network will operate. Valid option: NATTED or ROUTED",
since = "4.20.0")
private String nsxMode;
@Parameter(name = ApiConstants.NSX_SUPPORT_LB,
type = CommandType.BOOLEAN,
description = "true if network offering for NSX network offering supports Load balancer service.",
@ -164,6 +158,12 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
since = "4.20.0")
private Boolean nsxSupportsInternalLbService;
@Parameter(name = ApiConstants.NETWORK_MODE,
type = CommandType.STRING,
description = "Indicates the mode with which the network will operate. Valid option: NATTED or ROUTED",
since = "4.20.0")
private String networkMode;
@Parameter(name = ApiConstants.FOR_TUNGSTEN,
type = CommandType.BOOLEAN,
description = "true if network offering is meant to be used for Tungsten-Fabric, false otherwise.")
@ -211,6 +211,16 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
since = "4.16")
private Boolean enable;
@Parameter(name = ApiConstants.SPECIFY_AS_NUMBER, type = CommandType.BOOLEAN, since = "4.20.0",
description = "true if network offering supports choosing AS number")
private Boolean specifyAsNumber;
@Parameter(name = ApiConstants.ROUTING_MODE,
type = CommandType.STRING,
since = "4.20.0",
description = "the routing mode for the network offering. Supported types are: Static or Dynamic.")
private String routingMode;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -302,8 +312,8 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
return BooleanUtils.isTrue(forNsx);
}
public String getNsxMode() {
return nsxMode;
public String getNetworkMode() {
return networkMode;
}
public boolean getNsxSupportsLbService() {
@ -462,6 +472,14 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
return false;
}
public boolean getSpecifyAsNumber() {
return BooleanUtils.toBoolean(specifyAsNumber);
}
public String getRoutingMode() {
return routingMode;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -0,0 +1,111 @@
// 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.api.command.admin.network;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "dedicateIpv4SubnetForZone",
description = "Dedicates an existing IPv4 subnet for a zone to an account or a domain.",
responseObject = DataCenterIpv4SubnetResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class DedicateIpv4SubnetForZoneCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DataCenterIpv4SubnetResponse.class, required = true, description = "Id of the guest network IPv4 subnet")
private Long id;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "account who will own the IPv4 subnet")
private String accountName;
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "project who will own the IPv4 subnet")
private Long projectId;
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "domain ID of the account owning the IPv4 subnet")
private Long domainId;
public Long getId() {
return id;
}
public String getAccountName() {
return accountName;
}
public Long getProjectId() {
return projectId;
}
public Long getDomainId() {
return domainId;
}
@Override
public String getEventType() {
return EventTypes.EVENT_ZONE_IP4_SUBNET_DEDICATE;
}
@Override
public String getEventDescription() {
return "Dedicating zone IPv4 subnet " + getId();
}
@Override
public void execute() {
try {
DataCenterIpv4GuestSubnet result = routedIpv4Manager.dedicateDataCenterIpv4GuestSubnet(this);
if (result != null) {
DataCenterIpv4SubnetResponse response = routedIpv4Manager.createDataCenterIpv4SubnetResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate guest network IPv4 subnet:" + getId());
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
} catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,88 @@
// 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.api.command.admin.network;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.Ipv4SubnetForGuestNetworkResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "deleteIpv4SubnetForGuestNetwork",
description = "Deletes an existing IPv4 subnet for guest network.",
responseObject = SuccessResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class DeleteIpv4SubnetForGuestNetworkCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = Ipv4SubnetForGuestNetworkResponse.class, required = true, description = "Id of the guest network IPv4 subnet")
private Long id;
public Long getId() {
return id;
}
@Override
public String getEventType() {
return EventTypes.EVENT_IP4_GUEST_SUBNET_DELETE;
}
@Override
public String getEventDescription() {
return "Deleting guest IPv4 subnet " + getId();
}
@Override
public void execute() {
try {
boolean result = routedIpv4Manager.deleteIpv4SubnetForGuestNetwork(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete guest network IPv4 subnet:" + getId());
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
} catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,88 @@
// 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.api.command.admin.network;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "deleteIpv4SubnetForZone",
description = "Deletes an existing IPv4 subnet for a zone.",
responseObject = SuccessResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class DeleteIpv4SubnetForZoneCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DataCenterIpv4SubnetResponse.class, required = true, description = "Id of the guest network IPv4 subnet")
private Long id;
public Long getId() {
return id;
}
@Override
public String getEventType() {
return EventTypes.EVENT_ZONE_IP4_SUBNET_DELETE;
}
@Override
public String getEventDescription() {
return "Deleting zone IPv4 subnet " + getId();
}
@Override
public void execute() {
try {
boolean result = routedIpv4Manager.deleteDataCenterIpv4GuestSubnet(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete guest network IPv4 subnet:" + getId());
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
} catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,123 @@
// 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.api.command.admin.network;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
import org.apache.cloudstack.api.response.Ipv4SubnetForGuestNetworkResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.api.response.VpcResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.network.Ipv4GuestSubnetNetworkMap;
@APICommand(name = "listIpv4SubnetsForGuestNetwork",
description = "Lists IPv4 subnets for guest networks.",
responseObject = Ipv4SubnetForGuestNetworkResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class ListIpv4SubnetsForGuestNetworkCmd extends BaseListCmd {
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
entityType = Ipv4SubnetForGuestNetworkResponse.class,
description = "UUID of the IPv4 subnet for guest network.")
private Long id;
@Parameter(name = ApiConstants.PARENT_ID,
type = CommandType.UUID,
entityType = DataCenterIpv4SubnetResponse.class,
description = "UUID of zone Ipv4 subnet which the IPv4 subnet belongs to.")
private Long parentId;
@Parameter(name = ApiConstants.SUBNET,
type = CommandType.STRING,
description = "The CIDR of the Ipv4 subnet.")
private String subnet;
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.UUID,
entityType = ZoneResponse.class,
description = "UUID of zone to which the IPv4 subnet belongs to.")
private Long zoneId;
@Parameter(name = ApiConstants.NETWORK_ID,
type = CommandType.UUID,
entityType = NetworkResponse.class,
description = "UUID of network to which the IPv4 subnet is associated to.")
private Long networkId;
@Parameter(name = ApiConstants.VPC_ID,
type = CommandType.UUID,
entityType = VpcResponse.class,
description = "UUID of VPC to which the IPv4 subnet is associated to.")
private Long vpcId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public Long getParentId() {
return parentId;
}
public Long getZoneId() {
return zoneId;
}
public String getSubnet() {
return subnet;
}
public Long getNetworkId() {
return networkId;
}
public Long getVpcId() {
return vpcId;
}
@Override
public void execute() {
List<? extends Ipv4GuestSubnetNetworkMap> subnets = routedIpv4Manager.listIpv4GuestSubnetsForGuestNetwork(this);
ListResponse<Ipv4SubnetForGuestNetworkResponse> response = new ListResponse<>();
List<Ipv4SubnetForGuestNetworkResponse> subnetResponses = new ArrayList<>();
for (Ipv4GuestSubnetNetworkMap subnet : subnets) {
Ipv4SubnetForGuestNetworkResponse subnetResponse = routedIpv4Manager.createIpv4SubnetForGuestNetworkResponse(subnet);
subnetResponses.add(subnetResponse);
}
response.setResponses(subnetResponses, subnets.size());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}

View File

@ -0,0 +1,120 @@
// 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.api.command.admin.network;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
@APICommand(name = "listIpv4SubnetsForZone",
description = "Lists IPv4 subnets for zone.",
responseObject = DataCenterIpv4SubnetResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class ListIpv4SubnetsForZoneCmd extends BaseListCmd {
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
entityType = DataCenterIpv4SubnetResponse.class,
description = "UUID of the IPv4 subnet.")
private Long id;
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.UUID,
entityType = ZoneResponse.class,
description = "UUID of zone to which the IPv4 subnet belongs to.")
private Long zoneId;
@Parameter(name = ApiConstants.SUBNET,
type = CommandType.STRING,
description = "CIDR of the IPv4 subnet.")
private String subnet;
@Parameter(name = ApiConstants.ACCOUNT,
type = CommandType.STRING,
description = "the account which the IPv4 subnet is dedicated to. Must be used with the domainId parameter.")
private String accountName;
@Parameter(name = ApiConstants.PROJECT_ID,
type = CommandType.UUID,
entityType = ProjectResponse.class,
description = "project who which the IPv4 subnet is dedicated to")
private Long projectId;
@Parameter(name = ApiConstants.DOMAIN_ID,
type = CommandType.UUID,
entityType = DomainResponse.class,
description = "the domain ID which the IPv4 subnet is dedicated to.")
private Long domainId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public Long getZoneId() {
return zoneId;
}
public String getSubnet() {
return subnet;
}
public String getAccountName() {
return accountName;
}
public Long getProjectId() {
return projectId;
}
public Long getDomainId() {
return domainId;
}
@Override
public void execute() {
List<? extends DataCenterIpv4GuestSubnet> subnets = routedIpv4Manager.listDataCenterIpv4GuestSubnets(this);
ListResponse<DataCenterIpv4SubnetResponse> response = new ListResponse<>();
List<DataCenterIpv4SubnetResponse> subnetResponses = new ArrayList<>();
for (DataCenterIpv4GuestSubnet subnet : subnets) {
DataCenterIpv4SubnetResponse subnetResponse = routedIpv4Manager.createDataCenterIpv4SubnetResponse(subnet);
subnetResponses.add(subnetResponse);
}
response.setResponses(subnetResponses, subnets.size());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}

View File

@ -0,0 +1,88 @@
// 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.api.command.admin.network;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "releaseIpv4SubnetForZone",
description = "Releases an existing dedicated IPv4 subnet for a zone.",
responseObject = DataCenterIpv4SubnetResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class ReleaseDedicatedIpv4SubnetForZoneCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DataCenterIpv4SubnetResponse.class, required = true, description = "Id of the guest network IPv4 subnet")
private Long id;
public Long getId() {
return id;
}
@Override
public String getEventType() {
return EventTypes.EVENT_ZONE_IP4_SUBNET_RELEASE;
}
@Override
public String getEventDescription() {
return "Releasing a dedicated zone IPv4 subnet " + getId();
}
@Override
public void execute() {
try {
DataCenterIpv4GuestSubnet result = routedIpv4Manager.releaseDedicatedDataCenterIpv4GuestSubnet(this);
if (result != null) {
DataCenterIpv4SubnetResponse response = routedIpv4Manager.createDataCenterIpv4SubnetResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to release guest network IPv4 subnet:" + getId());
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
} catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,98 @@
// 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.api.command.admin.network;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "updateIpv4SubnetForZone",
description = "Updates an existing IPv4 subnet for a zone.",
responseObject = DataCenterIpv4SubnetResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class UpdateIpv4SubnetForZoneCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DataCenterIpv4SubnetResponse.class, required = true, description = "Id of the guest network IPv4 subnet")
private Long id;
@Parameter(name = ApiConstants.SUBNET,
type = CommandType.STRING,
required = true,
description = "The new CIDR of the IPv4 subnet.")
private String subnet;
public Long getId() {
return id;
}
public String getSubnet() {
return subnet;
}
@Override
public String getEventType() {
return EventTypes.EVENT_ZONE_IP4_SUBNET_UPDATE;
}
@Override
public String getEventDescription() {
return "Updating zone IPv4 subnet " + getId();
}
@Override
public void execute() {
try {
DataCenterIpv4GuestSubnet result = routedIpv4Manager.updateDataCenterIpv4GuestSubnet(this);
if (result != null) {
DataCenterIpv4SubnetResponse response = routedIpv4Manager.createDataCenterIpv4SubnetResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update guest network IPv4 subnet:" + getId());
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
} catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,109 @@
// 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.api.command.admin.network.bgp;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.admin.AdminCmd;
import org.apache.cloudstack.api.response.BgpPeerResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.Network;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
import java.util.List;
@APICommand(name = "changeBgpPeersForNetwork",
description = "Change the BGP peers for a network.",
responseObject = BgpPeerResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class ChangeBgpPeersForNetworkCmd extends BaseAsyncCmd implements AdminCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.NETWORK_ID,
type = CommandType.UUID,
entityType = NetworkResponse.class,
required = true,
description = "UUID of the network which the Bgp Peers are associated to.",
validations = {ApiArgValidator.PositiveNumber})
private Long networkId;
@Parameter(name = ApiConstants.BGP_PEER_IDS,
type = CommandType.LIST,
collectionType = CommandType.UUID,
entityType = BgpPeerResponse.class,
description = "Ids of the Bgp Peer. If it is empty, all BGP peers will be unlinked.")
private List<Long> bgpPeerIds;
public Long getNetworkId() {
return networkId;
}
public List<Long> getBgpPeerIds() {
return bgpPeerIds;
}
@Override
public String getEventType() {
return EventTypes.EVENT_NETWORK_BGP_PEER_UPDATE;
}
@Override
public String getEventDescription() {
return "Changing Bgp Peers for network " + getNetworkId();
}
@Override
public void execute() {
try {
Network result = routedIpv4Manager.changeBgpPeersForNetwork(this);
if (result != null) {
NetworkResponse response = _responseGenerator.createNetworkResponse(getResponseView(), result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to change BGP Peers for network");
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
} catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,109 @@
// 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.api.command.admin.network.bgp;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.admin.AdminCmd;
import org.apache.cloudstack.api.response.BgpPeerResponse;
import org.apache.cloudstack.api.response.VpcResponse;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.vpc.Vpc;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
import java.util.List;
@APICommand(name = "changeBgpPeersForVpc",
description = "Change the BGP peers for a VPC.",
responseObject = BgpPeerResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class ChangeBgpPeersForVpcCmd extends BaseAsyncCmd implements AdminCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.VPC_ID,
type = CommandType.UUID,
entityType = VpcResponse.class,
required = true,
description = "UUID of the VPC which the Bgp Peers are associated to.",
validations = {ApiArgValidator.PositiveNumber})
private Long vpcId;
@Parameter(name = ApiConstants.BGP_PEER_IDS,
type = CommandType.LIST,
collectionType = CommandType.UUID,
entityType = BgpPeerResponse.class,
description = "Ids of the Bgp Peer. If it is empty, all BGP peers will be unlinked.")
private List<Long> bgpPeerIds;
public Long getVpcId() {
return vpcId;
}
public List<Long> getBgpPeerIds() {
return bgpPeerIds;
}
@Override
public String getEventType() {
return EventTypes.EVENT_VPC_BGP_PEER_UPDATE;
}
@Override
public String getEventDescription() {
return "Changing Bgp Peers for VPC " + getVpcId();
}
@Override
public void execute() {
try {
Vpc result = routedIpv4Manager.changeBgpPeersForVpc(this);
if (result != null) {
VpcResponse response = _responseGenerator.createVpcResponse(getResponseView(), result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to change BGP Peers for vpc");
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
} catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,168 @@
// 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.api.command.admin.network.bgp;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.BgpPeerResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.network.BgpPeer;
import org.apache.commons.collections.MapUtils;
import com.cloud.event.EventTypes;
import com.cloud.user.Account;
import java.util.Collection;
import java.util.Map;
@APICommand(name = "createBgpPeer",
description = "Creates a Bgp Peer for a zone.",
responseObject = BgpPeerResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = true,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class CreateBgpPeerCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.UUID,
entityType = ZoneResponse.class,
required = true,
description = "UUID of the zone which the Bgp Peer belongs to.",
validations = {ApiArgValidator.PositiveNumber})
private Long zoneId;
@Parameter(name = ApiConstants.IP_ADDRESS,
type = CommandType.STRING,
description = "The IPv4 address of the Bgp Peer.")
private String ip4Address;
@Parameter(name = ApiConstants.IP6_ADDRESS,
type = CommandType.STRING,
description = "The IPv6 address of the Bgp Peer.")
private String ip6Address;
@Parameter(name = ApiConstants.AS_NUMBER,
type = CommandType.LONG,
required = true,
description = "The AS number of the Bgp Peer.")
private Long asNumber;
@Parameter(name = ApiConstants.PASSWORD,
type = CommandType.STRING,
description = "The password of the Bgp Peer.")
private String password;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "account who will own the Bgp Peer")
private String accountName;
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "project who will own the Bgp Peer")
private Long projectId;
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "domain ID of the account owning the Bgp Peer")
private Long domainId;
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP,
description = "BGP peer details in key/value pairs.")
protected Map details;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getZoneId() {
return zoneId;
}
public String getIp4Address() {
return ip4Address;
}
public String getIp6Address() {
return ip6Address;
}
public String getPassword() {
return password;
}
public Long getAsNumber() {
return asNumber;
}
public String getAccountName() {
return accountName;
}
public Long getProjectId() {
return projectId;
}
public Long getDomainId() {
return domainId;
}
public Map<String, String> getDetails() {
if (MapUtils.isEmpty(details)) {
return null;
}
Collection<String> paramsCollection = this.details.values();
return (Map<String, String>) (paramsCollection.toArray())[0];
}
@Override
public String getEventType() {
return EventTypes.EVENT_BGP_PEER_CREATE;
}
@Override
public String getEventDescription() {
return "Creating Bgp Peer " + getAsNumber() + " for zone=" + getZoneId();
}
@Override
public void execute() {
BgpPeer result = routedIpv4Manager.createBgpPeer(this);
if (result != null) {
BgpPeerResponse response = routedIpv4Manager.createBgpPeerResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Bgp Peer.");
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,111 @@
// 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.api.command.admin.network.bgp;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.BgpPeerResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.network.BgpPeer;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "dedicateBgpPeer",
description = "Dedicates an existing Bgp Peer to an account or a domain.",
responseObject = BgpPeerResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class DedicateBgpPeerCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = BgpPeerResponse.class, required = true, description = "Id of the Bgp Peer")
private Long id;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "account who will own the Bgp Peer")
private String accountName;
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "project who will own the Bgp Peer")
private Long projectId;
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "domain ID of the account owning the Bgp Peer")
private Long domainId;
public Long getId() {
return id;
}
public String getAccountName() {
return accountName;
}
public Long getProjectId() {
return projectId;
}
public Long getDomainId() {
return domainId;
}
@Override
public String getEventType() {
return EventTypes.EVENT_BGP_PEER_DEDICATE;
}
@Override
public String getEventDescription() {
return "Dedicating Bgp Peer " + getId();
}
@Override
public void execute() {
try {
BgpPeer result = routedIpv4Manager.dedicateBgpPeer(this);
if (result != null) {
BgpPeerResponse response = routedIpv4Manager.createBgpPeerResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate Bgp Peer:" + getId());
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
} catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,88 @@
// 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.api.command.admin.network.bgp;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.BgpPeerResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "deleteBgpPeer",
description = "Deletes an existing Bgp Peer.",
responseObject = SuccessResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class DeleteBgpPeerCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = BgpPeerResponse.class, required = true, description = "Id of the Bgp Peer")
private Long id;
public Long getId() {
return id;
}
@Override
public String getEventType() {
return EventTypes.EVENT_BGP_PEER_DELETE;
}
@Override
public String getEventDescription() {
return "Deleting Bgp Peer " + getId();
}
@Override
public void execute() {
try {
boolean result = routedIpv4Manager.deleteBgpPeer(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete Bgp Peer:" + getId());
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
} catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,130 @@
// 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.api.command.admin.network.bgp;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.BgpPeerResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.network.BgpPeer;
@APICommand(name = "listBgpPeers",
description = "Lists Bgp Peers.",
responseObject = BgpPeerResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class ListBgpPeersCmd extends BaseListCmd {
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
entityType = BgpPeerResponse.class,
description = "UUID of the Bgp Peer.")
private Long id;
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.UUID,
entityType = ZoneResponse.class,
description = "UUID of zone to which the Bgp Peer belongs to.")
private Long zoneId;
@Parameter(name = ApiConstants.AS_NUMBER,
type = CommandType.LONG,
description = "AS number of the Bgp Peer.")
private Long asNumber;
@Parameter(name = ApiConstants.ACCOUNT,
type = CommandType.STRING,
description = "the account which the Bgp Peer is dedicated to. Must be used with the domainId parameter.")
private String accountName;
@Parameter(name = ApiConstants.PROJECT_ID,
type = CommandType.UUID,
entityType = ProjectResponse.class,
description = "project who which the Bgp Peer is dedicated to")
private Long projectId;
@Parameter(name = ApiConstants.DOMAIN_ID,
type = CommandType.UUID,
entityType = DomainResponse.class,
description = "the domain ID which the Bgp Peer is dedicated to.")
private Long domainId;
@Parameter(name = ApiConstants.IS_DEDICATED,
type = CommandType.BOOLEAN,
description = "Lists only dedicated or non-dedicated Bgp Peers. If not set, lists all dedicated and non-dedicated BGP peers the domain/account can access.")
private Boolean isDedicated;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public Long getZoneId() {
return zoneId;
}
public Long getAsNumber() {
return asNumber;
}
public String getAccountName() {
return accountName;
}
public Long getProjectId() {
return projectId;
}
public Long getDomainId() {
return domainId;
}
public Boolean getDedicated() {
return isDedicated;
}
@Override
public void execute() {
List<? extends BgpPeer> subnets = routedIpv4Manager.listBgpPeers(this);
ListResponse<BgpPeerResponse> response = new ListResponse<>();
List<BgpPeerResponse> subnetResponses = new ArrayList<>();
for (BgpPeer subnet : subnets) {
BgpPeerResponse subnetResponse = routedIpv4Manager.createBgpPeerResponse(subnet);
subnetResponse.setObjectName("bgppeer");
subnetResponses.add(subnetResponse);
}
response.setResponses(subnetResponses, subnets.size());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}

View File

@ -0,0 +1,88 @@
// 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.api.command.admin.network.bgp;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.BgpPeerResponse;
import org.apache.cloudstack.network.BgpPeer;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "releaseBgpPeer",
description = "Releases an existing dedicated Bgp Peer.",
responseObject = BgpPeerResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class ReleaseDedicatedBgpPeerCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = BgpPeerResponse.class, required = true, description = "Id of the Bgp Peer")
private Long id;
public Long getId() {
return id;
}
@Override
public String getEventType() {
return EventTypes.EVENT_BGP_PEER_RELEASE;
}
@Override
public String getEventDescription() {
return "Releasing a dedicated Bgp Peer " + getId();
}
@Override
public void execute() {
try {
BgpPeer result = routedIpv4Manager.releaseDedicatedBgpPeer(this);
if (result != null) {
BgpPeerResponse response = routedIpv4Manager.createBgpPeerResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to release Bgp Peer:" + getId());
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
} catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -0,0 +1,149 @@
// 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.api.command.admin.network.bgp;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.BgpPeerResponse;
import org.apache.cloudstack.network.BgpPeer;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.commons.collections.MapUtils;
import java.util.Collection;
import java.util.Map;
@APICommand(name = "updateBgpPeer",
description = "Updates an existing Bgp Peer.",
responseObject = BgpPeerResponse.class,
since = "4.20.0",
requestHasSensitiveInfo = true,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin})
public class UpdateBgpPeerCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = BgpPeerResponse.class, required = true, description = "Id of the Bgp Peer")
private Long id;
@Parameter(name = ApiConstants.IP_ADDRESS,
type = CommandType.STRING,
description = "The IPv4 address of the Bgp Peer.")
private String ip4Address;
@Parameter(name = ApiConstants.IP6_ADDRESS,
type = CommandType.STRING,
description = "The IPv6 address of the Bgp Peer.")
private String ip6Address;
@Parameter(name = ApiConstants.AS_NUMBER,
type = CommandType.LONG,
description = "The AS number of the Bgp Peer.")
private Long asNumber;
@Parameter(name = ApiConstants.PASSWORD,
type = CommandType.STRING,
description = "The password of the Bgp Peer.")
private String password;
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP,
description = "BGP peer details in key/value pairs.")
protected Map details;
@Parameter(name = ApiConstants.CLEAN_UP_DETAILS,
type = CommandType.BOOLEAN,
description = "optional boolean field, which indicates if details should be cleaned up or not (if set to true, details are removed for this resource; if false or not set, no action)")
private Boolean cleanupDetails;
public Long getId() {
return id;
}
public String getIp4Address() {
return ip4Address;
}
public String getIp6Address() {
return ip6Address;
}
public Long getAsNumber() {
return asNumber;
}
public String getPassword() {
return password;
}
public Map<String, String> getDetails() {
if (MapUtils.isEmpty(details)) {
return null;
}
Collection<String> paramsCollection = this.details.values();
return (Map<String, String>) (paramsCollection.toArray())[0];
}
public boolean isCleanupDetails(){
return cleanupDetails == null ? false : cleanupDetails.booleanValue();
}
@Override
public String getEventType() {
return EventTypes.EVENT_BGP_PEER_UPDATE;
}
@Override
public String getEventDescription() {
return "Updating Bgp Peer " + getId();
}
@Override
public void execute() {
try {
BgpPeer result = routedIpv4Manager.updateBgpPeer(this);
if (result != null) {
BgpPeerResponse response = routedIpv4Manager.createBgpPeerResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update Bgp Peer:" + getId());
}
} catch (InvalidParameterValueException ex) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
} catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -31,6 +31,8 @@ import org.apache.cloudstack.api.response.StoragePoolResponse;
import com.cloud.storage.StoragePool;
import com.cloud.user.Account;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
@SuppressWarnings("rawtypes")
@APICommand(name = "updateStoragePool", description = "Updates a storage pool.", responseObject = StoragePoolResponse.class, since = "3.0.0",
@ -147,7 +149,17 @@ public class UpdateStoragePoolCmd extends BaseCmd {
@Override
public void execute() {
StoragePool result = _storageService.updateStoragePool(this);
StoragePool result = null;
if (ObjectUtils.anyNotNull(name, capacityIops, capacityBytes, url, isTagARule, tags) ||
MapUtils.isNotEmpty(details)) {
result = _storageService.updateStoragePool(this);
}
if (enabled != null) {
result = enabled ? _storageService.enablePrimaryStoragePool(id)
: _storageService.disablePrimaryStoragePool(id);
}
if (result != null) {
StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
response.setResponseName(getCommandName());

View File

@ -17,13 +17,31 @@
package org.apache.cloudstack.api.command.admin.vpc;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.command.admin.AdminCmd;
import org.apache.cloudstack.api.command.user.vpc.CreateVPCCmd;
import org.apache.cloudstack.api.response.BgpPeerResponse;
import org.apache.cloudstack.api.response.VpcResponse;
import com.cloud.network.vpc.Vpc;
import java.util.List;
@APICommand(name = "createVPC", description = "Creates a VPC", responseObject = VpcResponse.class, responseView = ResponseView.Full, entityType = {Vpc.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class CreateVPCCmdByAdmin extends CreateVPCCmd implements AdminCmd {}
public class CreateVPCCmdByAdmin extends CreateVPCCmd implements AdminCmd {
@Parameter(name = ApiConstants.BGP_PEER_IDS,
type = CommandType.LIST,
collectionType = CommandType.UUID,
entityType = BgpPeerResponse.class,
description = "Ids of the Bgp Peer for the VPC",
since = "4.20.0")
private List<Long> bgpPeerIds;
public List<Long> getBgpPeerIds() {
return bgpPeerIds;
}
}

View File

@ -118,12 +118,6 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
since = "4.20.0")
private Boolean forNsx;
@Parameter(name = ApiConstants.NSX_MODE,
type = CommandType.STRING,
description = "Indicates the mode with which the network will operate. Valid option: NATTED or ROUTED",
since = "4.20.0")
private String nsxMode;
@Parameter(name = ApiConstants.NSX_SUPPORT_LB,
type = CommandType.BOOLEAN,
description = "true if network offering for NSX VPC offering supports Load balancer service.",
@ -136,6 +130,22 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
since = "4.16")
private Boolean enable;
@Parameter(name = ApiConstants.NETWORK_MODE,
type = CommandType.STRING,
description = "Indicates the mode with which the network will operate. Valid option: NATTED or ROUTED",
since = "4.20.0")
private String networkMode;
@Parameter(name = ApiConstants.SPECIFY_AS_NUMBER, type = CommandType.BOOLEAN, since = "4.20.0",
description = "true if the VPC offering supports choosing AS number")
private Boolean specifyAsNumber;
@Parameter(name = ApiConstants.ROUTING_MODE,
type = CommandType.STRING,
since = "4.20.0",
description = "the routing mode for the VPC offering. Supported types are: Static or Dynamic.")
private String routingMode;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -173,8 +183,8 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
return BooleanUtils.isTrue(forNsx);
}
public String getNsxMode() {
return nsxMode;
public String getNetworkMode() {
return networkMode;
}
public boolean getNsxSupportsLbService() {
@ -265,6 +275,14 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
return false;
}
public Boolean getSpecifyAsNumber() {
return BooleanUtils.toBoolean(specifyAsNumber);
}
public String getRoutingMode() {
return routingMode;
}
@Override
public void create() throws ResourceAllocationException {
VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(this);

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.user.backup;
import javax.inject.Inject;
import com.amazonaws.util.CollectionUtils;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -27,6 +28,7 @@ import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.BackupScheduleResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.backup.BackupManager;
import org.apache.cloudstack.backup.BackupSchedule;
@ -39,6 +41,9 @@ import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.utils.exception.CloudRuntimeException;
import java.util.ArrayList;
import java.util.List;
@APICommand(name = "listBackupSchedule",
description = "List backup schedule of a VM",
responseObject = BackupScheduleResponse.class, since = "4.14.0",
@ -74,9 +79,14 @@ public class ListBackupScheduleCmd extends BaseCmd {
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
try{
BackupSchedule schedule = backupManager.listBackupSchedule(getVmId());
if (schedule != null) {
BackupScheduleResponse response = _responseGenerator.createBackupScheduleResponse(schedule);
List<BackupSchedule> schedules = backupManager.listBackupSchedule(getVmId());
ListResponse<BackupScheduleResponse> response = new ListResponse<>();
List<BackupScheduleResponse> scheduleResponses = new ArrayList<>();
if (CollectionUtils.isNullOrEmpty(schedules)) {
for (BackupSchedule schedule : schedules) {
scheduleResponses.add(_responseGenerator.createBackupScheduleResponse(schedule));
}
response.setResponses(scheduleResponses, schedules.size());
response.setResponseName(getCommandName());
setResponseObject(response);
} else {

View File

@ -0,0 +1,137 @@
// 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.api.command.user.backup.repository;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.BackupRepositoryResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.backup.BackupRepository;
import org.apache.cloudstack.backup.BackupRepositoryService;
import org.apache.cloudstack.context.CallContext;
import javax.inject.Inject;
@APICommand(name = "addBackupRepository",
description = "Adds a backup repository to store NAS backups",
responseObject = BackupRepositoryResponse.class, since = "4.20.0",
authorized = {RoleType.Admin})
public class AddBackupRepositoryCmd extends BaseCmd {
@Inject
private BackupRepositoryService backupRepositoryService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the backup repository")
private String name;
@Parameter(name = ApiConstants.ADDRESS, type = CommandType.STRING, required = true, description = "address of the backup repository")
private String address;
@Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, required = true, description = "type of the backup repository storage. Supported values: nfs, cephfs, cifs")
private String type;
@Parameter(name = ApiConstants.PROVIDER, type = CommandType.STRING, description = "backup repository provider")
private String provider;
@Parameter(name = ApiConstants.MOUNT_OPTIONS, type = CommandType.STRING, description = "shared storage mount options")
private String mountOptions;
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.UUID,
entityType = ZoneResponse.class,
required = true,
description = "ID of the zone where the backup repository is to be added")
private Long zoneId;
@Parameter(name = ApiConstants.CAPACITY_BYTES, type = CommandType.LONG, description = "capacity of this backup repository")
private Long capacityBytes;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public BackupRepositoryService getBackupRepositoryService() {
return backupRepositoryService;
}
public String getName() {
return name;
}
public String getType() {
if ("cephfs".equalsIgnoreCase(type)) {
return "ceph";
}
return type.toLowerCase();
}
public String getAddress() {
return address;
}
public String getProvider() {
return provider;
}
public String getMountOptions() {
return mountOptions == null ? "" : mountOptions;
}
public Long getZoneId() {
return zoneId;
}
public Long getCapacityBytes() {
return capacityBytes;
}
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
try {
BackupRepository result = backupRepositoryService.addBackupRepository(this);
if (result != null) {
BackupRepositoryResponse response = _responseGenerator.createBackupRepositoryResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add backup repository");
}
} catch (Exception ex4) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex4.getMessage());
}
}
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
}

View File

@ -0,0 +1,76 @@
// 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.api.command.user.backup.repository;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.BackupRepositoryResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.backup.BackupRepositoryService;
import javax.inject.Inject;
@APICommand(name = "deleteBackupRepository",
description = "delete a backup repository",
responseObject = SuccessResponse.class, since = "4.20.0",
authorized = {RoleType.Admin})
public class DeleteBackupRepositoryCmd extends BaseCmd {
@Inject
BackupRepositoryService backupRepositoryService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
entityType = BackupRepositoryResponse.class,
required = true,
description = "ID of the backup repository to be deleted")
private Long id;
/////////////////////////////////////////////////////
//////////////// Accessors //////////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
@Override
public void execute() {
boolean result = backupRepositoryService.deleteBackupRepository(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete backup repository");
}
}
@Override
public long getEntityOwnerId() {
return 0;
}
}

View File

@ -0,0 +1,110 @@
// 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.api.command.user.backup.repository;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.utils.Pair;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.BackupRepositoryResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.backup.BackupRepository;
import org.apache.cloudstack.backup.BackupRepositoryService;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
@APICommand(name = "listBackupRepositories",
description = "Lists all backup repositories",
responseObject = BackupRepositoryResponse.class, since = "4.20.0",
authorized = {RoleType.Admin})
public class ListBackupRepositoriesCmd extends BaseListCmd {
@Inject
BackupRepositoryService backupRepositoryService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "name of the backup repository")
private String name;
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.UUID,
entityType = ZoneResponse.class,
description = "ID of the zone where the backup repository is to be added")
private Long zoneId;
@Parameter(name = ApiConstants.PROVIDER, type = CommandType.STRING, description = "the backup repository provider")
private String provider;
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = BackupRepositoryResponse.class, description = "ID of the backup repository")
private Long id;
/////////////////////////////////////////////////////
//////////////// Accessors //////////////////////////
/////////////////////////////////////////////////////
public String getName() {
return name;
}
public Long getZoneId() {
return zoneId;
}
public String getProvider() {
return provider;
}
public Long getId() {
return id;
}
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
try {
Pair<List<BackupRepository>, Integer> repositoriesPair = backupRepositoryService.listBackupRepositories(this);
List<BackupRepository> backupRepositories = repositoriesPair.first();
ListResponse<BackupRepositoryResponse> response = new ListResponse<>();
List<BackupRepositoryResponse> responses = new ArrayList<>();
for (BackupRepository repository : backupRepositories) {
responses.add(_responseGenerator.createBackupRepositoryResponse(repository));
}
response.setResponses(responses, repositoriesPair.second());
response.setResponseName(getCommandName());
setResponseObject(response);
} catch (Exception e) {
String msg = String.format("Error listing backup repositories, due to: %s", e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
}
}
}

View File

@ -0,0 +1,134 @@
// 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.api.command.user.bgp;
import com.cloud.bgp.ASNumber;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.utils.Pair;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ASNRangeResponse;
import org.apache.cloudstack.api.response.ASNumberResponse;
import org.apache.cloudstack.api.response.AccountResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.api.response.VpcResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import java.util.ArrayList;
import java.util.List;
@APICommand(name = "listASNumbers",
description = "List Autonomous Systems Numbers",
responseObject = ASNumberResponse.class,
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User},
since = "4.20.0")
public class ListASNumbersCmd extends BaseListCmd {
@Parameter(name = ApiConstants.ZONE_ID, type = BaseCmd.CommandType.UUID, entityType = ZoneResponse.class,
description = "the zone ID")
private Long zoneId;
@Parameter(name = ApiConstants.ASN_RANGE_ID, type = BaseCmd.CommandType.UUID, entityType = ASNRangeResponse.class,
description = "the AS Number range ID")
private Long asNumberRangeId;
@Parameter(name = ApiConstants.AS_NUMBER, type = CommandType.INTEGER, entityType = ASNumberResponse.class,
description = "AS number")
private Integer asNumber;
@Parameter(name = ApiConstants.IS_ALLOCATED, type = CommandType.BOOLEAN,
description = "to indicate if the AS number is allocated to any network")
private Boolean allocated;
@Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class,
description = "the network id")
private Long networkId;
@Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class,
description = "the vpc id")
private Long vpcId;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, entityType = AccountResponse.class,
description = "account name")
private String account;
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class,
description = "domain id")
private Long domainId;
public Long getZoneId() {
return zoneId;
}
public Long getAsNumberRangeId() {
return asNumberRangeId;
}
public Boolean getAllocated() {
return allocated;
}
public Integer getAsNumber() { return asNumber; }
public Long getNetworkId() {
return networkId;
}
public String getAccount() {
return account;
}
public Long getDomainId() {
return domainId;
}
public Long getVpcId() {
return vpcId;
}
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
try {
Pair<List<ASNumber>, Integer> pair = bgpService.listASNumbers(this);
List<ASNumber> asNumbers = pair.first();
ListResponse<ASNumberResponse> response = new ListResponse<>();
List<ASNumberResponse> responses = new ArrayList<>();
for (ASNumber asn : asNumbers) {
responses.add(_responseGenerator.createASNumberResponse(asn));
}
response.setResponses(responses, pair.second());
response.setResponseName(getCommandName());
setResponseObject(response);
} catch (Exception e) {
String msg = String.format("Error listing AS Numbers, due to: %s", e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
}
}
}

View File

@ -55,6 +55,7 @@ public class ListCapabilitiesCmd extends BaseCmd {
response.setAllowUserExpungeRecoverVM((Boolean)capabilities.get("allowUserExpungeRecoverVM"));
response.setAllowUserExpungeRecoverVolume((Boolean)capabilities.get("allowUserExpungeRecoverVolume"));
response.setAllowUserViewAllDomainAccounts((Boolean)capabilities.get("allowUserViewAllDomainAccounts"));
response.setAllowUserForceStopVM((Boolean)capabilities.get(ApiConstants.ALLOW_USER_FORCE_STOP_VM));
response.setKubernetesServiceEnabled((Boolean)capabilities.get("kubernetesServiceEnabled"));
response.setKubernetesClusterExperimentalFeaturesEnabled((Boolean)capabilities.get("kubernetesClusterExperimentalFeaturesEnabled"));
response.setCustomHypervisorDisplayName((String) capabilities.get("customHypervisorDisplayName"));
@ -69,6 +70,8 @@ public class ListCapabilitiesCmd extends BaseCmd {
response.setInstancesStatsUserOnly((Boolean) capabilities.get(ApiConstants.INSTANCES_STATS_USER_ONLY));
response.setInstancesDisksStatsRetentionEnabled((Boolean) capabilities.get(ApiConstants.INSTANCES_DISKS_STATS_RETENTION_ENABLED));
response.setInstancesDisksStatsRetentionTime((Integer) capabilities.get(ApiConstants.INSTANCES_DISKS_STATS_RETENTION_TIME));
response.setSharedFsVmMinCpuCount((Integer)capabilities.get(ApiConstants.SHAREDFSVM_MIN_CPU_COUNT));
response.setSharedFsVmMinRamSize((Integer)capabilities.get(ApiConstants.SHAREDFSVM_MIN_RAM_SIZE));
response.setObjectName("capability");
response.setResponseName(getCommandName());
this.setResponseObject(response);

View File

@ -43,7 +43,7 @@ import com.cloud.user.Account;
import com.cloud.utils.net.NetUtils;
@APICommand(name = "createIpv6FirewallRule",
description = "Creates an Ipv6 firewall rule in the given network (the network has to belong to VPC)",
description = "Creates an Ipv6 firewall rule in the given network (the network must not belong to VPC)",
responseObject = FirewallRuleResponse.class,
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.user.iso;
import com.cloud.cpu.CPU;
import com.cloud.server.ResourceIcon;
import com.cloud.server.ResourceTag;
import org.apache.cloudstack.api.response.ResourceIconResponse;
@ -34,6 +35,7 @@ import org.apache.cloudstack.context.CallContext;
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
import com.cloud.user.Account;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
@ -88,6 +90,11 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd implements UserCmd {
@Parameter(name = ApiConstants.SHOW_RESOURCE_ICON, type = CommandType.BOOLEAN, description = "flag to display the resource image for the isos")
private Boolean showIcon;
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
description = "the CPU arch of the ISO. Valid options are: x86_64, aarch64",
since = "4.20")
private String arch;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -159,6 +166,13 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd implements UserCmd {
return onlyReady;
}
public CPU.CPUArch getArch() {
if (StringUtils.isBlank(arch)) {
return null;
}
return CPU.CPUArch.fromType(arch);
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.user.iso;
import java.util.List;
import com.cloud.cpu.CPU;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
@ -118,6 +119,11 @@ public class RegisterIsoCmd extends BaseCmd implements UserCmd {
description = "true if password reset feature is supported; default is false")
private Boolean passwordEnabled;
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
description = "the CPU arch of the ISO. Valid options are: x86_64, aarch64",
since = "4.20")
private String arch;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -229,6 +235,14 @@ public class RegisterIsoCmd extends BaseCmd implements UserCmd {
return passwordEnabled == null ? false : passwordEnabled;
}
public void setArch(String arch) {
this.arch = arch;
}
public CPU.CPUArch getArch() {
return CPU.CPUArch.fromType(arch);
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -191,6 +191,14 @@ public class CreateNetworkCmd extends BaseCmd implements UserCmd {
since = "4.19")
private String sourceNatIP;
@Parameter(name = ApiConstants.CIDR_SIZE, type = CommandType.INTEGER,
description = "the CIDR size of IPv4 network. For regular users, this is required for isolated networks with ROUTED mode.",
since = "4.20.0")
private Integer cidrSize;
@Parameter(name=ApiConstants.AS_NUMBER, type=CommandType.LONG, since = "4.20.0", description="the AS Number of the network")
private Long asNumber;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -364,6 +372,10 @@ public class CreateNetworkCmd extends BaseCmd implements UserCmd {
return NetUtils.standardizeIp6Cidr(ip6Cidr);
}
public Integer getCidrSize() {
return cidrSize;
}
public Long getAclId() {
return aclId;
}
@ -391,6 +403,10 @@ public class CreateNetworkCmd extends BaseCmd implements UserCmd {
return ip6Dns2;
}
public Long getAsNumber() {
return asNumber;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -110,6 +110,12 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
@Parameter(name = ApiConstants.FOR_VPC, type = CommandType.BOOLEAN, description = "the network offering can be used" + " only for network creation inside the VPC")
private Boolean forVpc;
@Parameter(name = ApiConstants.ROUTING_MODE,
type = CommandType.STRING,
description = "the routing mode for the network offering. Supported types are: Static or Dynamic.",
since = "4.20.0")
private String routingMode;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -186,6 +192,8 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
return forVpc;
}
public String getRoutingMode() { return routingMode; }
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -0,0 +1,271 @@
// 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.api.command.user.network.routing;
import java.util.ArrayList;
import java.util.List;
import com.cloud.exception.NetworkRuleConflictException;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.FirewallResponse;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.commons.lang3.StringUtils;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.rules.FirewallRule;
import com.cloud.user.Account;
import com.cloud.utils.net.NetUtils;
@APICommand(name = "createRoutingFirewallRule",
description = "Creates a routing firewall rule in the given network in ROUTED mode",
since = "4.20.0",
responseObject = FirewallRuleResponse.class,
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class CreateRoutingFirewallRuleCmd extends BaseAsyncCreateCmd {
// ///////////////////////////////////////////////////
// ////////////// API parameters /////////////////////
// ///////////////////////////////////////////////////
@Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, required = true, description = "the protocol for the firewall rule. Valid values are TCP/UDP/ICMP/ALL or valid protocol number")
private String protocol;
@Parameter(name = ApiConstants.START_PORT, type = CommandType.INTEGER, description = "the starting port of firewall rule")
private Integer publicStartPort;
@Parameter(name = ApiConstants.END_PORT, type = CommandType.INTEGER, description = "the ending port of firewall rule")
private Integer publicEndPort;
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING,
description = "the source CIDR list to allow traffic from. Multiple entries must be separated by a single comma character (,).")
protected List<String> sourceCidrList;
@Parameter(name = ApiConstants.DEST_CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING,
description = "the destination CIDR list to allow traffic to. Multiple entries must be separated by a single comma character (,).")
protected List<String> destinationCidrlist;
@Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type of the ICMP message being sent")
private Integer icmpType;
@Parameter(name = ApiConstants.ICMP_CODE, type = CommandType.INTEGER, description = "error code for this ICMP message")
private Integer icmpCode;
@Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class,
description = "The network of the VM the firewall rule will be created for", required = true)
private Long networkId;
@Parameter(name = ApiConstants.TRAFFIC_TYPE, type = CommandType.STRING,
description = "the traffic type for the Routing firewall rule, can be ingress or egress, defaulted to ingress if not specified")
private String trafficType;
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN,
description = "an optional field, whether to the display the rule to the end user or not", authorized = {RoleType.Admin})
private Boolean display;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public boolean isDisplay() {
if (display != null) {
return display;
} else {
return true;
}
}
public String getProtocol() {
String p = protocol == null ? "" : protocol.trim();
if (StringUtils.isNumeric(p)) {
int protoNumber = Integer.parseInt(p);
switch (protoNumber) {
case 1:
p = NetUtils.ICMP_PROTO;
break;
case 6:
p = NetUtils.TCP_PROTO;
break;
case 17:
p = NetUtils.UDP_PROTO;
break;
default:
throw new InvalidParameterValueException(String.format("Protocol %d not supported", protoNumber));
}
}
return p;
}
public List<String> getSourceCidrList() {
if (sourceCidrList != null) {
return sourceCidrList;
} else {
List<String> oneCidrList = new ArrayList<String>();
oneCidrList.add(NetUtils.ALL_IP4_CIDRS);
return oneCidrList;
}
}
public List<String> getDestinationCidrList() {
if (destinationCidrlist != null) {
return destinationCidrlist;
} else {
List<String> oneCidrList = new ArrayList<String>();
oneCidrList.add(NetUtils.ALL_IP4_CIDRS);
return oneCidrList;
}
}
public FirewallRule.TrafficType getTrafficType() {
if (trafficType == null) {
return FirewallRule.TrafficType.Ingress;
}
for (FirewallRule.TrafficType type : FirewallRule.TrafficType.values()) {
if (type.toString().equalsIgnoreCase(trafficType)) {
return type;
}
}
throw new InvalidParameterValueException("Invalid traffic type " + trafficType);
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
public Integer getSourcePortStart() {
return publicStartPort;
}
public Integer getSourcePortEnd() {
if (publicEndPort == null) {
if (publicStartPort != null) {
return publicStartPort;
}
} else {
return publicEndPort;
}
return null;
}
public Long getNetworkId() {
return networkId;
}
@Override
public long getEntityOwnerId() {
Network network = _networkService.getNetwork(networkId);
if (network != null) {
return network.getAccountId();
}
Account owner = CallContext.current().getCallingAccount();
return owner.getAccountId();
}
@Override
public String getEventType() {
return EventTypes.EVENT_ROUTING_IPV4_FIREWALL_RULE_CREATE;
}
@Override
public String getEventDescription() {
return "Creating ipv4 firewall rule for routed network";
}
public Integer getIcmpCode() {
if (icmpCode != null) {
return icmpCode;
} else if (getProtocol().equalsIgnoreCase(NetUtils.ICMP_PROTO)) {
return -1;
}
return null;
}
public Integer getIcmpType() {
if (icmpType != null) {
return icmpType;
} else if (getProtocol().equalsIgnoreCase(NetUtils.ICMP_PROTO)) {
return -1;
}
return null;
}
@Override
public void create() {
try {
FirewallRule result = routedIpv4Manager.createRoutingFirewallRule(this);
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} catch (NetworkRuleConflictException e) {
logger.trace("Network Rule Conflict: ", e);
throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage(), e);
}
}
@Override
public void execute() throws ResourceUnavailableException {
boolean success = false;
FirewallRule rule = _firewallService.getFirewallRule(getEntityId());
try {
CallContext.current().setEventDetails("Rule ID: " + getEntityId());
success = routedIpv4Manager.applyRoutingFirewallRule(rule.getId());
// State is different after the rule is applied, so get new object here
rule = _firewallService.getFirewallRule(getEntityId());
FirewallResponse ruleResponse = new FirewallResponse();
if (rule != null) {
ruleResponse = _responseGenerator.createFirewallResponse(rule);
setResponseObject(ruleResponse);
}
ruleResponse.setResponseName(getCommandName());
} catch (Exception ex) {
logger.error("Got exception when create Routing firewall rules: " + ex);
} finally {
if (!success || rule == null) {
routedIpv4Manager.revokeRoutingFirewallRule(getEntityId());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Routing firewall rule");
}
}
}
@Override
public Long getApiResourceId() {
return getNetworkId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Network;
}
}

View File

@ -0,0 +1,109 @@
// 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.api.command.user.network.routing;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext;
import com.cloud.event.EventTypes;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.rules.FirewallRule;
import com.cloud.user.Account;
@APICommand(name = "deleteRoutingFirewallRule",
description = "Deletes a routing firewall rule",
since = "4.20.0",
responseObject = SuccessResponse.class,
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class DeleteRoutingFirewallRuleCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the Routing firewall rule")
private Long id;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getEventType() {
return EventTypes.EVENT_ROUTING_IPV4_FIREWALL_RULE_DELETE;
}
@Override
public String getEventDescription() {
return String.format("Deleting ipv4 routing firewall rule ID=%s", id);
}
@Override
public long getEntityOwnerId() {
FirewallRule rule = _firewallService.getFirewallRule(id);
if (rule != null) {
return rule.getAccountId();
}
Account caller = CallContext.current().getCallingAccount();
return caller.getAccountId();
}
@Override
public void execute() throws ResourceUnavailableException {
CallContext.current().setEventDetails("Routing firewall rule ID: " + id);
boolean result = routedIpv4Manager.revokeRoutingFirewallRule(id);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete Routing firewall rule");
}
}
@Override
public Long getApiResourceId() {
FirewallRule rule = _firewallService.getFirewallRule(id);
if (rule != null) {
return rule.getNetworkId();
}
return null;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Network;
}
}

View File

@ -0,0 +1,115 @@
// 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.api.command.user.network.routing;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.command.user.firewall.IListFirewallRulesCmd;
import org.apache.cloudstack.api.response.FirewallResponse;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import com.cloud.network.rules.FirewallRule;
import com.cloud.utils.Pair;
@APICommand(name = "listRoutingFirewallRules",
description = "Lists all Routing firewall rules",
since = "4.20.0",
responseObject = FirewallRuleResponse.class,
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class ListRoutingFirewallRulesCmd extends BaseListTaggedResourcesCmd implements IListFirewallRulesCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class,
description = "Lists Routing firewall rule with the specified ID")
private Long id;
@Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list Routing firewall rules by network ID")
private Long networkId;
@Parameter(name = ApiConstants.TRAFFIC_TYPE, type = CommandType.STRING, description = "list Routing firewall rules by traffic type - ingress or egress")
private String trafficType;
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", authorized = {RoleType.Admin})
private Boolean display;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@Override
public Long getNetworkId() {
return networkId;
}
@Override
public Long getId() {
return id;
}
@Override
public FirewallRule.TrafficType getTrafficType() {
if (trafficType != null) {
return FirewallRule.TrafficType.valueOf(trafficType);
}
return null;
}
@Override
public Long getIpAddressId() {
return null;
}
@Override
public Boolean getDisplay() {
if (display != null) {
return display;
}
return super.getDisplay();
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
Pair<List<? extends FirewallRule>, Integer> result = routedIpv4Manager.listRoutingFirewallRules(this);
ListResponse<FirewallResponse> response = new ListResponse<>();
List<FirewallResponse> ruleResponses = new ArrayList<>();
for (FirewallRule rule : result.first()) {
FirewallResponse ruleData = _responseGenerator.createFirewallResponse(rule);
ruleResponses.add(ruleData);
}
response.setResponses(ruleResponses, result.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
}

View File

@ -0,0 +1,125 @@
// 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.api.command.user.network.routing;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseAsyncCustomIdCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.FirewallResponse;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
import org.apache.cloudstack.context.CallContext;
import com.cloud.event.EventTypes;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.rules.FirewallRule;
import com.cloud.user.Account;
@APICommand(name = "updateRoutingFirewallRule",
description = "Updates Routing firewall rule with specified ID",
since = "4.20.0",
responseObject = FirewallRuleResponse.class,
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class UpdateRoutingFirewallRuleCmd extends BaseAsyncCustomIdCmd {
// ///////////////////////////////////////////////////
// ////////////// API parameters /////////////////////
// ///////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the Routing firewall rule")
private Long id;
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the Routing firewall rule to the end user or not",
authorized = {RoleType.Admin})
private Boolean display;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public boolean isDisplay() {
if (display != null) {
return display;
} else {
return true;
}
}
public Long getId() {
return id;
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public long getEntityOwnerId() {
FirewallRule rule = _firewallService.getFirewallRule(id);
if (rule != null) {
return rule.getAccountId();
}
Account caller = CallContext.current().getCallingAccount();
return caller.getAccountId();
}
@Override
public String getEventType() {
return EventTypes.EVENT_ROUTING_IPV4_FIREWALL_RULE_UPDATE;
}
@Override
public String getEventDescription() {
return "Updating ipv4 routing firewall rule";
}
@Override
public void execute() throws ResourceUnavailableException {
CallContext.current().setEventDetails("Rule Id: " + getId());
FirewallRule rule = routedIpv4Manager.updateRoutingFirewallRule(this);
FirewallResponse ruleResponse = _responseGenerator.createFirewallResponse(rule);
setResponseObject(ruleResponse);
ruleResponse.setResponseName(getCommandName());
}
@Override
public void checkUuid() {
if (this.getCustomId() != null) {
_uuidMgr.checkUuid(this.getCustomId(), FirewallRule.class);
}
}
@Override
public Long getApiResourceId() {
FirewallRule rule = _firewallService.getFirewallRule(id);
if (rule != null) {
return rule.getNetworkId();
}
return null;
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Network;
}
}

View File

@ -0,0 +1,145 @@
// 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.api.command.user.storage.sharedfs;
import javax.inject.Inject;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.DiskOfferingResponse;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
import com.cloud.event.EventTypes;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.user.Account;
@APICommand(name = "changeSharedFileSystemDiskOffering",
responseObject= SharedFSResponse.class,
description = "Change Disk offering of a Shared FileSystem",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class ChangeSharedFSDiskOfferingCmd extends BaseAsyncCmd implements UserCmd {
@Inject
SharedFSService sharedFSService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
required = true,
entityType = SharedFSResponse.class,
description = "the ID of the shared filesystem")
private Long id;
@Parameter(name = ApiConstants.DISK_OFFERING_ID,
type = CommandType.UUID,
entityType = DiskOfferingResponse.class,
description = "the disk offering to use for the underlying storage")
private Long diskOfferingId;
@Parameter(name = ApiConstants.SIZE,
type = CommandType.LONG,
description = "the size of the shared filesystem in GiB")
private Long size;
@Parameter(name = ApiConstants.MIN_IOPS,
type = CommandType.LONG,
description = "min iops")
private Long minIops;
@Parameter(name = ApiConstants.MAX_IOPS,
type = CommandType.LONG,
description = "max iops")
private Long maxIops;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public Long getSize() {
return size;
}
public Long getDiskOfferingId() {
return diskOfferingId;
}
public Long getMinIops() {
return minIops;
}
public Long getMaxIops() {
return maxIops;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getEventType() {
return EventTypes.EVENT_SHAREDFS_CHANGE_DISK_OFFERING;
}
@Override
public String getEventDescription() {
return "Changing disk offering for the Shared FileSystem " + id;
}
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
@Override
public void execute() throws ResourceAllocationException {
SharedFS sharedFS = sharedFSService.changeSharedFSDiskOffering(this);
if (sharedFS != null) {
ResponseObject.ResponseView respView = getResponseView();
Account caller = CallContext.current().getCallingAccount();
if (_accountService.isRootAdmin(caller.getId())) {
respView = ResponseObject.ResponseView.Full;
}
SharedFSResponse response = _responseGenerator.createSharedFSResponse(respView, sharedFS);
response.setObjectName(SharedFS.class.getSimpleName().toLowerCase());
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to change disk offering for the Shared FileSystem");
}
}
}

View File

@ -0,0 +1,147 @@
// 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.api.command.user.storage.sharedfs;
import javax.inject.Inject;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
import com.cloud.event.EventTypes;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ManagementServerException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.VirtualMachineMigrationException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "changeSharedFileSystemServiceOffering",
responseObject= SharedFSResponse.class,
description = "Change Service offering of a Shared FileSystem",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class ChangeSharedFSServiceOfferingCmd extends BaseAsyncCmd implements UserCmd {
@Inject
SharedFSService sharedFSService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
required = true,
entityType = SharedFSResponse.class,
description = "the ID of the shared filesystem")
private Long id;
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID,
type = CommandType.UUID,
entityType = ServiceOfferingResponse.class,
required = true,
description = "the offering to use for the shared filesystem vm")
private Long serviceOfferingId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public Long getServiceOfferingId() {
return serviceOfferingId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getEventType() {
return EventTypes.EVENT_SHAREDFS_CHANGE_SERVICE_OFFERING;
}
@Override
public String getEventDescription() {
return "Changing service offering for the Shared FileSystem " + id;
}
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
private String getExceptionMsg(Exception ex) {
return "Shared FileSystem restart failed with exception" + ex.getMessage();
}
@Override
public void execute() {
SharedFS sharedFS;
try {
sharedFS = sharedFSService.changeSharedFSServiceOffering(this);
} catch (ResourceUnavailableException ex) {
logger.warn("Shared FileSystem change service offering exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, getExceptionMsg(ex));
} catch (InsufficientCapacityException ex) {
logger.warn("Shared FileSystem change service offering exception: ", ex);
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, getExceptionMsg(ex));
} catch (OperationTimedoutException ex) {
logger.warn("Shared FileSystem change service offering exception: ", ex);
throw new CloudRuntimeException("Shared FileSystem change service offering timed out due to " + ex.getMessage());
} catch (ManagementServerException ex) {
logger.warn("Shared FileSystem change service offering exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (VirtualMachineMigrationException ex) {
logger.warn("Shared FileSystem change service offering exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
if (sharedFS != null) {
ResponseObject.ResponseView respView = getResponseView();
Account caller = CallContext.current().getCallingAccount();
if (_accountService.isRootAdmin(caller.getId())) {
respView = ResponseObject.ResponseView.Full;
}
SharedFSResponse response = _responseGenerator.createSharedFSResponse(respView, sharedFS);
response.setObjectName(SharedFS.class.getSimpleName().toLowerCase());
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to change the service offering for the Shared FileSystem");
}
}
}

View File

@ -0,0 +1,304 @@
// 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.api.command.user.storage.sharedfs;
import javax.inject.Inject;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.DiskOfferingResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSProvider;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
@APICommand(name = "createSharedFileSystem",
responseObject= SharedFSResponse.class,
description = "Create a new Shared File System of specified size and disk offering, attached to the given network",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class CreateSharedFSCmd extends BaseAsyncCreateCmd implements UserCmd {
@Inject
SharedFSService sharedFSService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.NAME,
type = CommandType.STRING,
required = true,
description = "the name of the shared filesystem.")
private String name;
@Parameter(name = ApiConstants.ACCOUNT,
type = BaseCmd.CommandType.STRING,
description = "the account associated with the shared filesystem. Must be used with the domainId parameter.")
private String accountName;
@Parameter(name = ApiConstants.DOMAIN_ID,
type = CommandType.UUID,
entityType = DomainResponse.class,
description = "the domain ID associated with the shared filesystem. If used with the account parameter"
+ " returns the shared filesystem associated with the account for the specified domain." +
"If account is NOT provided then the shared filesystem will be assigned to the caller account and domain.")
private Long domainId;
@Parameter(name = ApiConstants.PROJECT_ID,
type = CommandType.UUID,
entityType = ProjectResponse.class,
description = "the project associated with the shared filesystem. Mutually exclusive with account parameter")
private Long projectId;
@Parameter(name = ApiConstants.DESCRIPTION,
type = CommandType.STRING,
description = "the description for the shared filesystem.")
private String description;
@Parameter(name = ApiConstants.SIZE,
type = CommandType.LONG,
description = "the size of the shared filesystem in GiB")
private Long size;
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.UUID,
required = true,
entityType = ZoneResponse.class,
description = "the zone id.")
private Long zoneId;
@Parameter(name = ApiConstants.DISK_OFFERING_ID,
type = CommandType.UUID,
required = true,
entityType = DiskOfferingResponse.class,
description = "the disk offering to use for the underlying storage. This will define the size and other specifications like encryption and qos for the shared filesystem.")
private Long diskOfferingId;
@Parameter(name = ApiConstants.MIN_IOPS,
type = CommandType.LONG,
description = "min iops")
private Long minIops;
@Parameter(name = ApiConstants.MAX_IOPS,
type = CommandType.LONG,
description = "max iops")
private Long maxIops;
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID,
type = CommandType.UUID,
required = true,
entityType = ServiceOfferingResponse.class,
description = "the service offering to use for the shared filesystem VM hosting the data. The offering should be HA enabled and the cpu count and memory size should be greater than equal to sharedfsvm.min.cpu.count and sharedfsvm.min.ram.size respectively")
private Long serviceOfferingId;
@Parameter(name = ApiConstants.FILESYSTEM,
type = CommandType.STRING,
required = true,
description = "the filesystem format (XFS / EXT4) which will be installed on the shared filesystem.")
private String fsFormat;
@Parameter(name = ApiConstants.PROVIDER,
type = CommandType.STRING,
description = "the provider to be used for the shared filesystem. The list of providers can be fetched by using the listSharedFileSystemProviders API.")
private String sharedFSProviderName;
@Parameter(name = ApiConstants.NETWORK_ID,
type = CommandType.UUID,
required = true,
entityType = NetworkResponse.class,
description = "network to attach the shared filesystem to")
private Long networkId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public String getName() {
return name;
}
public Long getProjectId() {
return projectId;
}
public Long getDomainId() {
return domainId;
}
public String getAccountName() {
return accountName;
}
public String getDescription() {
return description;
}
public Long getSize() {
return size;
}
public Long getZoneId() {
return zoneId;
}
public Long getDiskOfferingId() {
return diskOfferingId;
}
public Long getServiceOfferingId() {
return serviceOfferingId;
}
public Long getMaxIops() {
return maxIops;
}
public Long getMinIops() {
return minIops;
}
public String getFsFormat() {
return fsFormat;
}
public Long getNetworkId() {
return networkId;
}
public String getSharedFSProviderName() {
if (sharedFSProviderName != null) {
return sharedFSProviderName;
} else {
return SharedFSProvider.SharedFSProviderType.SHAREDFSVM.toString();
}
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.SharedFS;
}
@Override
public Long getApiResourceId() {
return this.getEntityId();
}
@Override
public long getEntityOwnerId() {
Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return CallContext.current().getCallingAccount().getId();
}
return accountId;
}
@Override
public String getEventType() {
return EventTypes.EVENT_SHAREDFS_CREATE;
}
@Override
public String getEventDescription() {
return "Creating shared filesystem " + name;
}
private String getCreateExceptionMsg(Exception ex) {
return "Shared FileSystem create failed with exception" + ex.getMessage();
}
private String getStartExceptionMsg(Exception ex) {
return "Shared FileSystem start failed with exception: " + ex.getMessage();
}
public void create() {
SharedFS sharedFS;
sharedFS = sharedFSService.allocSharedFS(this);
if (sharedFS != null) {
setEntityId(sharedFS.getId());
setEntityUuid(sharedFS.getUuid());
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Shared FileSystem");
}
}
@Override
public void execute() {
SharedFS sharedFS;
try {
sharedFS = sharedFSService.deploySharedFS(this);
} catch (ResourceUnavailableException ex) {
logger.warn("Shared FileSystem start exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, getStartExceptionMsg(ex));
} catch (ConcurrentOperationException ex) {
logger.warn("Shared FileSystem start exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, getStartExceptionMsg(ex));
} catch (InsufficientCapacityException ex) {
logger.warn("Shared FileSystem start exception: ", ex);
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, getStartExceptionMsg(ex));
} catch (ResourceAllocationException ex) {
logger.warn("Shared FileSystem start exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (OperationTimedoutException ex) {
throw new CloudRuntimeException("Shared FileSystem start timed out due to " + ex.getMessage());
}
if (sharedFS != null) {
ResponseObject.ResponseView respView = getResponseView();
Account caller = CallContext.current().getCallingAccount();
if (_accountService.isRootAdmin(caller.getId())) {
respView = ResponseObject.ResponseView.Full;
}
SharedFSResponse response = _responseGenerator.createSharedFSResponse(respView, sharedFS);
response.setObjectName(SharedFS.class.getSimpleName().toLowerCase());
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start Shared FileSystem");
}
}
}

View File

@ -0,0 +1,116 @@
// 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.api.command.user.storage.sharedfs;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
import javax.inject.Inject;
import com.cloud.event.EventTypes;
@APICommand(name = "destroySharedFileSystem",
responseObject= SuccessResponse.class,
description = "Destroy a Shared FileSystem by id",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class DestroySharedFSCmd extends BaseAsyncCmd implements UserCmd {
@Inject
SharedFSService sharedFSService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
entityType = SharedFSResponse.class,
description = "the ID of the shared filesystem to delete")
private Long id;
@Parameter(name = ApiConstants.EXPUNGE,
type = CommandType.BOOLEAN,
description = "If true is passed, the shared filesystem is expunged immediately. False by default.")
private Boolean expunge;
@Parameter(name = ApiConstants.FORCED,
type = CommandType.BOOLEAN,
description = "If true is passed, the shared filesystem can be destroyed without stopping it first.")
private Boolean forced;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public boolean isExpunge() {
return (expunge != null) ? expunge : false;
}
public boolean isForced() {
return (forced != null) ? forced : false;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getEventType() {
return EventTypes.EVENT_SHAREDFS_DESTROY;
}
@Override
public String getEventDescription() {
return "Destroying Shared FileSystem " + id;
}
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
@Override
public void execute() {
Boolean result = sharedFSService.destroySharedFS(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to destroy Shared FileSystem");
}
}
}

View File

@ -0,0 +1,96 @@
// 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.api.command.user.storage.sharedfs;
import javax.inject.Inject;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
import com.cloud.event.EventTypes;
@APICommand(name = "expungeSharedFileSystem",
responseObject= SuccessResponse.class,
description = "Expunge a Shared FileSystem by id",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class ExpungeSharedFSCmd extends BaseAsyncCmd implements UserCmd {
@Inject
SharedFSService sharedFSService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SharedFSResponse.class, description = "the ID of the shared filesystem to expunge")
private Long id;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getEventType() {
return EventTypes.EVENT_SHAREDFS_EXPUNGE;
}
@Override
public String getEventDescription() {
return "Expunging Shared FileSystem " + id;
}
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
@Override
public void execute() {
try {
sharedFSService.deleteSharedFS(id);
} catch (Exception ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to expunge Shared FileSystem");
} finally {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
}
}
}

View File

@ -0,0 +1,114 @@
// 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.api.command.user.storage.sharedfs;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListRetrieveOnlyResourceCountCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.DiskOfferingResponse;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
import javax.inject.Inject;
@APICommand(name = "listSharedFileSystems",
responseObject= SharedFSResponse.class,
description = "List Shared FileSystems",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class ListSharedFSCmd extends BaseListRetrieveOnlyResourceCountCmd implements UserCmd {
@Inject
SharedFSService sharedFSService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SharedFSResponse.class, description = "the ID of the shared filesystem")
private Long id;
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the shared filesystem")
private String name;
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the ID of the availability zone")
private Long zoneId;
@Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "the ID of the network")
private Long networkId;
@Parameter(name = ApiConstants.DISK_OFFERING_ID, type = CommandType.UUID, entityType = DiskOfferingResponse.class, description = "the disk offering of the shared filesystem")
private Long diskOfferingId;
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class, description = "the service offering of the shared filesystem")
private Long serviceOfferingId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public String getName() {
return name;
}
public Long getZoneId() {
return zoneId;
}
public Long getNetworkId() {
return networkId;
}
public Long getDiskOfferingId() {
return diskOfferingId;
}
public Long getServiceOfferingId() {
return serviceOfferingId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
public long getEntityOwnerId() {
return 0;
}
@Override
public void execute() {
ListResponse<SharedFSResponse> response = sharedFSService.searchForSharedFS(getResponseView(), this);
response.setResponseName(getCommandName());
setResponseObject(response);
}
}

View File

@ -0,0 +1,60 @@
// 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.api.command.user.storage.sharedfs;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.response.SharedFSProviderResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.storage.sharedfs.SharedFSProvider;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
@APICommand(name = "listSharedFileSystemProviders",
responseObject = SharedFSProviderResponse.class,
description = "Lists all available shared filesystem providers.",
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class ListSharedFSProvidersCmd extends BaseListCmd {
@Inject
public SharedFSService sharedFSService;
@Override
public void execute() {
List<SharedFSProvider> sharedFSProviders = sharedFSService.getSharedFSProviders();
final ListResponse<SharedFSProviderResponse> response = new ListResponse<>();
final List<SharedFSProviderResponse> responses = new ArrayList<>();
for (SharedFSProvider sharedFSProvider : sharedFSProviders) {
SharedFSProviderResponse sharedFSProviderResponse = new SharedFSProviderResponse();
sharedFSProviderResponse.setName(sharedFSProvider.getName());
sharedFSProviderResponse.setObjectName("sharedfilesystemprovider");
responses.add(sharedFSProviderResponse);
}
response.setResponses(responses, responses.size());
response.setResponseName(this.getCommandName());
setResponseObject(response);
}
}

View File

@ -0,0 +1,83 @@
// 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.api.command.user.storage.sharedfs;
import javax.inject.Inject;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
@APICommand(name = "recoverSharedFileSystem",
responseObject= SuccessResponse.class,
description = "Recover a Shared FileSystem by id",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class RecoverSharedFSCmd extends BaseCmd implements UserCmd {
@Inject
SharedFSService sharedFSService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SharedFSResponse.class, description = "the ID of the shared filesystem to recover")
private Long id;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
@Override
public void execute() {
SharedFS sharedFS = sharedFSService.recoverSharedFS(id);
if (sharedFS != null) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to recover Shared FileSystem");
}
}
}

View File

@ -0,0 +1,145 @@
// 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.api.command.user.storage.sharedfs;
import javax.inject.Inject;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "restartSharedFileSystem",
responseObject= SuccessResponse.class,
description = "Restart a Shared FileSystem",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class RestartSharedFSCmd extends BaseAsyncCmd implements UserCmd {
@Inject
SharedFSService sharedFSService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
required = true,
entityType = SharedFSResponse.class,
description = "the ID of the shared filesystem")
private Long id;
@Parameter(name = ApiConstants.CLEANUP,
type = CommandType.BOOLEAN,
description = "is cleanup required")
private boolean cleanup;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public Boolean getCleanup() {
return cleanup;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getEventType() {
return EventTypes.EVENT_SHAREDFS_RESTART;
}
@Override
public String getEventDescription() {
return "Restarting Shared FileSystem " + id;
}
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
private String getRestartExceptionMsg(Exception ex) {
return "Shared FileSystem restart failed with exception" + ex.getMessage();
}
@Override
public void execute() {
SharedFS sharedFS;
try {
sharedFS = sharedFSService.restartSharedFS(this.getId(), this.getCleanup());
} catch (ResourceUnavailableException ex) {
logger.warn("Shared FileSystem restart exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, getRestartExceptionMsg(ex));
} catch (ConcurrentOperationException ex) {
logger.warn("Shared FileSystem restart exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, getRestartExceptionMsg(ex));
} catch (InsufficientCapacityException ex) {
logger.warn("Shared FileSystem restart exception: ", ex);
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, getRestartExceptionMsg(ex));
} catch (ResourceAllocationException ex) {
logger.warn("Shared FileSystem restart exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (OperationTimedoutException ex) {
logger.warn("Shared FileSystem restart exception: ", ex);
throw new CloudRuntimeException("Shared FileSystem start timed out due to " + ex.getMessage());
}
if (sharedFS != null) {
ResponseObject.ResponseView respView = getResponseView();
Account caller = CallContext.current().getCallingAccount();
if (_accountService.isRootAdmin(caller.getId())) {
respView = ResponseObject.ResponseView.Full;
}
SharedFSResponse response = _responseGenerator.createSharedFSResponse(respView, sharedFS);
response.setObjectName(SharedFS.class.getSimpleName().toLowerCase());
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to restart Shared FileSystem");
}
}
}

View File

@ -0,0 +1,135 @@
// 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.api.command.user.storage.sharedfs;
import javax.inject.Inject;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "startSharedFileSystem",
responseObject= SharedFSResponse.class,
description = "Start a Shared FileSystem",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class StartSharedFSCmd extends BaseAsyncCmd implements UserCmd {
@Inject
SharedFSService sharedFSService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
required = true,
entityType = SharedFSResponse.class,
description = "the ID of the shared filesystem")
private Long id;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
@Override
public String getEventDescription() {
return "Starting Shared FileSystem " + id;
}
@Override
public String getEventType() {
return EventTypes.EVENT_SHAREDFS_START;
}
private String getStartExceptionMsg(Exception ex) {
return "Shared FileSystem start failed with exception: " + ex.getMessage();
}
@Override
public void execute() {
SharedFS sharedFS;
try {
sharedFS = sharedFSService.startSharedFS(this.getId());
} catch (ResourceUnavailableException ex) {
logger.warn("Shared FileSystem start exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, getStartExceptionMsg(ex));
} catch (ConcurrentOperationException ex) {
logger.warn("Shared FileSystem start exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, getStartExceptionMsg(ex));
} catch (InsufficientCapacityException ex) {
logger.warn("Shared FileSystem start exception: ", ex);
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, getStartExceptionMsg(ex));
} catch (ResourceAllocationException ex) {
logger.warn("Shared FileSystem start exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (OperationTimedoutException ex) {
logger.warn("Shared FileSystem start exception: ", ex);
throw new CloudRuntimeException("Shared FileSystem start timed out due to " + ex.getMessage());
}
if (sharedFS != null) {
ResponseObject.ResponseView respView = getResponseView();
Account caller = CallContext.current().getCallingAccount();
if (_accountService.isRootAdmin(caller.getId())) {
respView = ResponseObject.ResponseView.Full;
}
SharedFSResponse response = _responseGenerator.createSharedFSResponse(respView, sharedFS);
response.setObjectName(SharedFS.class.getSimpleName().toLowerCase());
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start Shared FileSystem");
}
}
}

View File

@ -0,0 +1,115 @@
// 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.api.command.user.storage.sharedfs;
import javax.inject.Inject;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
import com.cloud.event.EventTypes;
import com.cloud.user.Account;
@APICommand(name = "stopSharedFileSystem",
responseObject= SharedFSResponse.class,
description = "Stop a Shared FileSystem",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class StopSharedFSCmd extends BaseAsyncCmd implements UserCmd {
@Inject
SharedFSService sharedFSService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
required = true,
entityType = SharedFSResponse.class,
description = "the ID of the shared filesystem")
private Long id;
@Parameter(name = ApiConstants.FORCED,
type = CommandType.BOOLEAN,
description = "Force stop the shared filesystem.")
private Boolean forced;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public boolean isForced() {
return (forced != null) ? forced : false;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
@Override
public String getEventType() {
return EventTypes.EVENT_SHAREDFS_STOP;
}
@Override
public String getEventDescription() {
return "Stopping Shared FileSystem " + id;
}
@Override
public void execute() {
SharedFS sharedFS = sharedFSService.stopSharedFS(this.getId(), this.isForced());
if (sharedFS != null) {
ResponseObject.ResponseView respView = getResponseView();
Account caller = CallContext.current().getCallingAccount();
if (_accountService.isRootAdmin(caller.getId())) {
respView = ResponseObject.ResponseView.Full;
}
SharedFSResponse response = _responseGenerator.createSharedFSResponse(respView, sharedFS);
response.setObjectName(SharedFS.class.getSimpleName().toLowerCase());
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop Shared FileSystem");
}
}
}

View File

@ -0,0 +1,113 @@
// 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.api.command.user.storage.sharedfs;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;
import javax.inject.Inject;
import com.cloud.user.Account;
@APICommand(name = "updateSharedFileSystem",
responseObject= SharedFSResponse.class,
description = "Update a Shared FileSystem",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class UpdateSharedFSCmd extends BaseCmd implements UserCmd {
@Inject
SharedFSService sharedFSService;
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
required = true,
entityType = SharedFSResponse.class,
description = "the ID of the shared filesystem")
private Long id;
@Parameter(name = ApiConstants.NAME,
type = CommandType.STRING,
description = "the name of the shared filesystem.")
private String name;
@Parameter(name = ApiConstants.DESCRIPTION,
type = CommandType.STRING,
description = "the description for the shared filesystem.")
private String description;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}
@Override
public void execute() {
SharedFS sharedFS = sharedFSService.updateSharedFS(this);
if (sharedFS != null) {
ResponseObject.ResponseView respView = getResponseView();
Account caller = CallContext.current().getCallingAccount();
if (_accountService.isRootAdmin(caller.getId())) {
respView = ResponseObject.ResponseView.Full;
}
SharedFSResponse response = _responseGenerator.createSharedFSResponse(respView, sharedFS);
response.setObjectName(SharedFS.class.getSimpleName().toLowerCase());
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update Shared FileSystem");
}
}
}

View File

@ -22,6 +22,7 @@ import java.net.MalformedURLException;
import java.util.Collection;
import java.util.Map;
import com.cloud.cpu.CPU;
import com.cloud.hypervisor.Hypervisor;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
@ -55,6 +56,11 @@ public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
description = "the ID of the OS Type that best represents the OS of this template. Not required for VMware as the guest OS is obtained from the OVF file.")
private Long osTypeId;
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
description = "the CPU arch of the template. Valid options are: x86_64, aarch64",
since = "4.20")
private String arch;
@Parameter(name = ApiConstants.BITS, type = CommandType.INTEGER, description = "32 or 64 bits support. 64 by default")
private Integer bits;
@ -162,6 +168,10 @@ public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
Boolean.TRUE.equals(deployAsIs);
}
public CPU.CPUArch getArch() {
return CPU.CPUArch.fromType(arch);
}
@Override
public void execute() throws ServerApiException {
validateRequest();

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.user.template;
import com.cloud.cpu.CPU;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.server.ResourceIcon;
import com.cloud.server.ResourceTag;
@ -41,6 +42,7 @@ import org.apache.cloudstack.context.CallContext;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
import com.cloud.user.Account;
import org.apache.commons.lang3.StringUtils;
@APICommand(name = "listTemplates", description = "List all public, private, and privileged templates.", responseObject = TemplateResponse.class, entityType = {VirtualMachineTemplate.class}, responseView = ResponseView.Restricted,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
@ -104,6 +106,11 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd implements User
since = "4.19.0")
private Boolean isVnf;
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
description = "the CPU arch of the template. Valid options are: x86_64, aarch64",
since = "4.20")
private String arch;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -191,6 +198,13 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd implements User
return isVnf;
}
public CPU.CPUArch getArch() {
if (StringUtils.isBlank(arch)) {
return null;
}
return CPU.CPUArch.fromType(arch);
}
@Override
public String getCommandName() {
return s_name;

View File

@ -16,6 +16,7 @@
// under the License.
package org.apache.cloudstack.api.command.user.template;
import com.cloud.cpu.CPU;
import com.cloud.hypervisor.Hypervisor;
import java.net.URISyntaxException;
import java.util.ArrayList;
@ -172,6 +173,11 @@ public class RegisterTemplateCmd extends BaseCmd implements UserCmd {
since = "4.19.0")
private String templateType;
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
description = "the CPU arch of the template. Valid options are: x86_64, aarch64",
since = "4.20")
private String arch;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -293,6 +299,10 @@ public class RegisterTemplateCmd extends BaseCmd implements UserCmd {
return templateType;
}
public CPU.CPUArch getArch() {
return CPU.CPUArch.fromType(arch);
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -79,7 +79,7 @@ public class AddIpToVmNicCmd extends BaseAsyncCreateCmd {
private boolean isZoneSGEnabled() {
Network ntwk = _entityMgr.findById(Network.class, getNetworkId());
DataCenter dc = _entityMgr.findById(DataCenter.class, ntwk.getDataCenterId());
return dc.isSecurityGroupEnabled();
return dc.isSecurityGroupEnabled() || _ntwkModel.isSecurityGroupSupportedForZone(dc.getId());
}
@Override

View File

@ -127,7 +127,7 @@ public class RemoveIpFromVmNicCmd extends BaseAsyncCmd {
private boolean isZoneSGEnabled() {
Network ntwk = _entityMgr.findById(Network.class, getNetworkId());
DataCenter dc = _entityMgr.findById(DataCenter.class, ntwk.getDataCenterId());
return dc.isSecurityGroupEnabled();
return dc.isSecurityGroupEnabled() || _ntwkModel.isSecurityGroupSupportedForZone(dc.getId());
}
@Override

View File

@ -75,10 +75,15 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd implements UserCmd {
private String displayText;
@Parameter(name = ApiConstants.CIDR, type = CommandType.STRING, required = true, description = "the cidr of the VPC. All VPC " +
"guest networks' cidrs should be within this CIDR")
@Parameter(name = ApiConstants.CIDR, type = CommandType.STRING,
description = "the cidr of the VPC. All VPC guest networks' cidrs should be within this CIDR")
private String cidr;
@Parameter(name = ApiConstants.CIDR_SIZE, type = CommandType.INTEGER,
description = "the CIDR size of VPC. For regular users, this is required for VPC with ROUTED mode.",
since = "4.20.0")
private Integer cidrSize;
@Parameter(name = ApiConstants.VPC_OFF_ID, type = CommandType.UUID, entityType = VpcOfferingResponse.class,
required = true, description = "the ID of the VPC offering")
private Long vpcOffering;
@ -117,6 +122,9 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd implements UserCmd {
since = "4.19")
private String sourceNatIP;
@Parameter(name=ApiConstants.AS_NUMBER, type=CommandType.LONG, since = "4.20.0", description="the AS Number of the VPC tiers")
private Long asNumber;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@ -141,6 +149,10 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd implements UserCmd {
return cidr;
}
public Integer getCidrSize() {
return cidrSize;
}
public String getDisplayText() {
return StringUtils.isEmpty(displayText) ? vpcName : displayText;
}
@ -189,6 +201,10 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd implements UserCmd {
return sourceNatIP;
}
public Long getAsNumber() {
return asNumber;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -0,0 +1,93 @@
// 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.api.response;
import com.cloud.bgp.ASNumberRange;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import java.util.Date;
@EntityReference(value = ASNumberRange.class)
public class ASNRangeResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "ID of the AS Number Range")
private String id;
@SerializedName(ApiConstants.ZONE_ID)
@Param(description = "Zone ID")
private String zoneId;
@SerializedName(ApiConstants.START_ASN)
@Param(description = "Start AS Number")
private Long startASNumber;
@SerializedName(ApiConstants.END_ASN)
@Param(description = "End AS Number")
private Long endASNumber;
@SerializedName(ApiConstants.CREATED)
@Param(description = "Created date")
private Date created;
public ASNRangeResponse() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getZoneId() {
return zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public Long getStartASNumber() {
return startASNumber;
}
public void setStartASNumber(Long startASNumber) {
this.startASNumber = startASNumber;
}
public Long getEndASNumber() {
return endASNumber;
}
public void setEndASNumber(Long endASNumber) {
this.endASNumber = endASNumber;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
}

View File

@ -0,0 +1,237 @@
// 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.api.response;
import com.cloud.bgp.ASNumber;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import java.util.Date;
@EntityReference(value = ASNumber.class)
public class ASNumberResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "ID of the AS Number")
private String id;
@SerializedName(ApiConstants.ACCOUNT_ID)
@Param(description = "Account ID")
private String accountId;
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the account name")
private String accountName;
@SerializedName(ApiConstants.DOMAIN_ID)
@Param(description = "Domain ID")
private String domainId;
@SerializedName(ApiConstants.DOMAIN)
@Param(description = "the domain name")
private String domainName;
@SerializedName(ApiConstants.AS_NUMBER)
@Param(description = "AS Number")
private Long asNumber;
@SerializedName(ApiConstants.ASN_RANGE_ID)
@Param(description = "AS Number ID")
private String asNumberRangeId;
@SerializedName(ApiConstants.ASN_RANGE)
@Param(description = "AS Number Range")
private String asNumberRange;
@SerializedName(ApiConstants.ZONE_ID)
@Param(description = "Zone ID")
private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME)
@Param(description = "the zone name of the AS Number range")
private String zoneName;
@SerializedName("allocated")
@Param(description = "Allocated Date")
private Date allocated;
@SerializedName(ApiConstants.ALLOCATION_STATE)
@Param(description = "Allocation state")
private String allocationState;
@SerializedName(ApiConstants.ASSOCIATED_NETWORK_ID)
@Param(description = "Network ID")
private String associatedNetworkId;
@SerializedName(ApiConstants.ASSOCIATED_NETWORK_NAME)
@Param(description = "Network Name")
private String associatedNetworkName;
@SerializedName((ApiConstants.VPC_ID))
@Param(description = "VPC ID")
private String vpcId;
@SerializedName(ApiConstants.VPC_NAME)
@Param(description = "VPC Name")
private String vpcName;
@SerializedName(ApiConstants.CREATED)
@Param(description = "Created Date")
private Date created;
public ASNumberResponse() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public String getDomainId() {
return domainId;
}
public void setDomainId(String domainId) {
this.domainId = domainId;
}
public String getDomainName() {
return domainName;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public Long getAsNumber() {
return asNumber;
}
public void setAsNumber(Long asNumber) {
this.asNumber = asNumber;
}
public String getAsNumberRangeId() {
return asNumberRangeId;
}
public void setAsNumberRangeId(String asNumberRangeId) {
this.asNumberRangeId = asNumberRangeId;
}
public String getAsNumberRange() {
return asNumberRange;
}
public void setAsNumberRange(String asNumberRange) {
this.asNumberRange = asNumberRange;
}
public String getZoneId() {
return zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getZoneName() {
return zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public Date getAllocated() {
return allocated;
}
public void setAllocated(Date allocatedDate) {
this.allocated = allocatedDate;
}
public String getAllocationState() {
return allocationState;
}
public void setAllocationState(String allocated) {
allocationState = allocated;
}
public String getAssociatedNetworkId() {
return associatedNetworkId;
}
public void setAssociatedNetworkId(String associatedNetworkId) {
this.associatedNetworkId = associatedNetworkId;
}
public String getAssociatedNetworkName() {
return associatedNetworkName;
}
public void setAssociatedNetworkName(String associatedNetworkName) {
this.associatedNetworkName = associatedNetworkName;
}
public String getVpcId() {
return vpcId;
}
public void setVpcId(String vpcId) {
this.vpcId = vpcId;
}
public String getVpcName() {
return vpcName;
}
public void setVpcName(String vpcName) {
this.vpcName = vpcName;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
}

View File

@ -0,0 +1,154 @@
// 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.api.response;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import org.apache.cloudstack.backup.BackupRepository;
import java.util.Date;
@EntityReference(value = BackupRepository.class)
public class BackupRepositoryResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "the ID of the backup repository")
private String id;
@SerializedName(ApiConstants.ZONE_ID)
@Param(description = "the Zone ID of the backup repository")
private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME)
@Param(description = "the Zone name of the backup repository")
private String zoneName;
@SerializedName(ApiConstants.NAME)
@Param(description = "the name of the backup repository")
private String name;
@SerializedName(ApiConstants.ADDRESS)
@Param(description = "the address / url of the backup repository")
private String address;
@SerializedName(ApiConstants.PROVIDER)
@Param(description = "name of the provider")
private String providerName;
@SerializedName(ApiConstants.TYPE)
@Param(description = "backup type")
private String type;
@SerializedName(ApiConstants.MOUNT_OPTIONS)
@Param(description = "mount options for the backup repository")
private String mountOptions;
@SerializedName(ApiConstants.CAPACITY_BYTES)
@Param(description = "capacity of the backup repository")
private Long capacityBytes;
@SerializedName("created")
@Param(description = "the date and time the backup repository was added")
private Date created;
public BackupRepositoryResponse() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getZoneId() {
return zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getZoneName() {
return zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getMountOptions() {
return mountOptions;
}
public void setMountOptions(String mountOptions) {
this.mountOptions = mountOptions;
}
public String getProviderName() {
return providerName;
}
public void setProviderName(String providerName) {
this.providerName = providerName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Long getCapacityBytes() {
return capacityBytes;
}
public void setCapacityBytes(Long capacityBytes) {
this.capacityBytes = capacityBytes;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
}

View File

@ -0,0 +1,200 @@
// 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.api.response;
import java.util.Date;
import java.util.Map;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import org.apache.cloudstack.network.BgpPeer;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@EntityReference(value = BgpPeer.class)
public class BgpPeerResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "id of the bgp peer")
private String id;
@SerializedName(ApiConstants.IP_ADDRESS)
@Param(description = "IPv4 address of bgp peer")
private String ip4Address;
@SerializedName(ApiConstants.IP6_ADDRESS)
@Param(description = "IPv6 address of bgp peer")
private String ip6Address;
@SerializedName(ApiConstants.AS_NUMBER)
@Param(description = "AS number of bgp peer")
private Long asNumber;
@SerializedName(ApiConstants.PASSWORD)
@Param(description = "password of bgp peer")
private String password;
@SerializedName(ApiConstants.ZONE_ID)
@Param(description = "id of zone to which the bgp peer belongs to." )
private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME)
@Param(description = "name of zone to which the bgp peer belongs to." )
private String zoneName;
@SerializedName(ApiConstants.CREATED)
@Param(description = "date when this bgp peer was created." )
private Date created;
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the account of the bgp peer")
private String accountName;
@SerializedName(ApiConstants.DOMAIN_ID)
@Param(description = "the domain ID of the bgp peer")
private String domainId;
@SerializedName(ApiConstants.DOMAIN)
@Param(description = "the domain name of the bgp peer")
private String domainName;
@SerializedName(ApiConstants.PROJECT_ID)
@Param(description = "the project id of the bgp peer")
private String projectId;
@SerializedName(ApiConstants.PROJECT)
@Param(description = "the project name of the bgp peer")
private String projectName;
@SerializedName(ApiConstants.DETAILS)
@Param(description = "additional key/value details of the bgp peer")
private Map details;
public void setId(String id) {
this.id = id;
}
public void setIp4Address(String ip4Address) {
this.ip4Address = ip4Address;
}
public void setIp6Address(String ip6Address) {
this.ip6Address = ip6Address;
}
public void setAsNumber(Long asNumber) {
this.asNumber = asNumber;
}
public void setPassword(String password) {
this.password = password;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public void setCreated(Date created) {
this.created = created;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public void setDomainId(String domainId) {
this.domainId = domainId;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public void setDetails(Map details) {
this.details = details;
}
public String getId() {
return id;
}
public String getIp4Address() {
return ip4Address;
}
public String getIp6Address() {
return ip6Address;
}
public Long getAsNumber() {
return asNumber;
}
public String getPassword() {
return password;
}
public String getZoneId() {
return zoneId;
}
public String getZoneName() {
return zoneName;
}
public Date getCreated() {
return created;
}
public String getAccountName() {
return accountName;
}
public String getDomainId() {
return domainId;
}
public String getDomainName() {
return domainName;
}
public String getProjectId() {
return projectId;
}
public String getProjectName() {
return projectName;
}
public Map getDetails() {
return details;
}
}

View File

@ -92,6 +92,10 @@ public class CapabilitiesResponse extends BaseResponse {
@Param(description = "true if users can see all accounts within the same domain, false otherwise")
private boolean allowUserViewAllDomainAccounts;
@SerializedName(ApiConstants.ALLOW_USER_FORCE_STOP_VM)
@Param(description = "true if users are allowed to force stop a vm, false otherwise", since = "4.20.0")
private boolean allowUserForceStopVM;
@SerializedName("kubernetesserviceenabled")
@Param(description = "true if Kubernetes Service plugin is enabled, false otherwise")
private boolean kubernetesServiceEnabled;
@ -124,6 +128,14 @@ public class CapabilitiesResponse extends BaseResponse {
@Param(description = "the retention time for Instances disks stats", since = "4.18.0")
private Integer instancesDisksStatsRetentionTime;
@SerializedName(ApiConstants.SHAREDFSVM_MIN_CPU_COUNT)
@Param(description = "the min CPU count for the service offering used by the shared filesystem VM", since = "4.20.0")
private Integer sharedFsVmMinCpuCount;
@SerializedName(ApiConstants.SHAREDFSVM_MIN_RAM_SIZE)
@Param(description = "the min Ram size for the service offering used by the shared filesystem VM", since = "4.20.0")
private Integer sharedFsVmMinRamSize;
public void setSecurityGroupsEnabled(boolean securityGroupsEnabled) {
this.securityGroupsEnabled = securityGroupsEnabled;
}
@ -192,6 +204,10 @@ public class CapabilitiesResponse extends BaseResponse {
this.allowUserViewAllDomainAccounts = allowUserViewAllDomainAccounts;
}
public void setAllowUserForceStopVM(boolean allowUserForceStopVM) {
this.allowUserForceStopVM = allowUserForceStopVM;
}
public void setKubernetesServiceEnabled(boolean kubernetesServiceEnabled) {
this.kubernetesServiceEnabled = kubernetesServiceEnabled;
}
@ -223,4 +239,12 @@ public class CapabilitiesResponse extends BaseResponse {
public void setCustomHypervisorDisplayName(String customHypervisorDisplayName) {
this.customHypervisorDisplayName = customHypervisorDisplayName;
}
public void setSharedFsVmMinCpuCount(Integer sharedFsVmMinCpuCount) {
this.sharedFsVmMinCpuCount = sharedFsVmMinCpuCount;
}
public void setSharedFsVmMinRamSize(Integer sharedFsVmMinRamSize) {
this.sharedFsVmMinRamSize = sharedFsVmMinRamSize;
}
}

View File

@ -91,6 +91,10 @@ public class ClusterResponse extends BaseResponseWithAnnotations {
@Param(description = "Meta data associated with the zone (key/value pairs)")
private Map<String, String> resourceDetails;
@SerializedName(ApiConstants.ARCH)
@Param(description = "CPU Arch of the hosts in the cluster", since = "4.20")
private String arch;
public String getId() {
return id;
}
@ -247,4 +251,12 @@ public class ClusterResponse extends BaseResponseWithAnnotations {
public void setCapacities(List<CapacityResponse> capacities) {
this.capacities = capacities;
}
public void setArch(String arch) {
this.arch = arch;
}
public String getArch() {
return arch;
}
}

View File

@ -0,0 +1,151 @@
// 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.api.response;
import java.util.Date;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@EntityReference(value = DataCenterIpv4GuestSubnet.class)
public class DataCenterIpv4SubnetResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "id of the guest IPv4 subnet")
private String id;
@SerializedName(ApiConstants.SUBNET)
@Param(description = "guest IPv4 subnet")
private String subnet;
@SerializedName(ApiConstants.ZONE_ID)
@Param(description = "id of zone to which the IPv4 subnet belongs to." )
private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME)
@Param(description = "name of zone to which the IPv4 subnet belongs to." )
private String zoneName;
@SerializedName(ApiConstants.CREATED)
@Param(description = "date when this IPv4 subnet was created." )
private Date created;
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the account of the IPv4 subnet")
private String accountName;
@SerializedName(ApiConstants.DOMAIN_ID)
@Param(description = "the domain ID of the IPv4 subnet")
private String domainId;
@SerializedName(ApiConstants.DOMAIN)
@Param(description = "the domain name of the IPv4 subnet")
private String domainName;
@SerializedName(ApiConstants.PROJECT_ID)
@Param(description = "the project id of the IPv4 subnet")
private String projectId;
@SerializedName(ApiConstants.PROJECT)
@Param(description = "the project name of the IPv4 subnet")
private String projectName;
public void setId(String id) {
this.id = id;
}
public void setSubnet(String subnet) {
this.subnet = subnet;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public void setCreated(Date created) {
this.created = created;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public void setDomainId(String domainId) {
this.domainId = domainId;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public String getId() {
return id;
}
public String getSubnet() {
return subnet;
}
public String getZoneId() {
return zoneId;
}
public String getZoneName() {
return zoneName;
}
public Date getCreated() {
return created;
}
public String getAccountName() {
return accountName;
}
public String getDomainId() {
return domainId;
}
public String getDomainName() {
return domainName;
}
public String getProjectId() {
return projectId;
}
public String getProjectName() {
return projectName;
}
}

View File

@ -290,6 +290,10 @@ public class HostResponse extends BaseResponseWithAnnotations {
@Param(description = "true if the host supports instance conversion (using virt-v2v)", since = "4.19.1")
private Boolean instanceConversionSupported;
@SerializedName(ApiConstants.ARCH)
@Param(description = "CPU Arch of the host", since = "4.20")
private String arch;
@Override
public String getObjectId() {
return this.getId();
@ -787,6 +791,14 @@ public class HostResponse extends BaseResponseWithAnnotations {
isTagARule = tagARule;
}
public void setArch(String arch) {
this.arch = arch;
}
public String getArch() {
return arch;
}
public Long getCpuAllocatedValue() {
return cpuAllocatedValue;
}

View File

@ -0,0 +1,59 @@
// 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.api.response;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class Ipv4RouteResponse extends BaseResponse {
@SerializedName(ApiConstants.SUBNET)
@Param(description = "the guest Ipv4 cidr for route")
private String subnet;
@SerializedName(ApiConstants.GATEWAY)
@Param(description = "the outbound Ipv4 gateway")
private String gateway;
public Ipv4RouteResponse() {
}
public Ipv4RouteResponse(String subnet, String gateway) {
this.subnet = subnet;
this.gateway = gateway;
}
public String getSubnet() {
return subnet;
}
public void setSubnet(String subnet) {
this.subnet = subnet;
}
public String getGateway() {
return gateway;
}
public void setGateway(String gateway) {
this.gateway = gateway;
}
}

Some files were not shown because too many files have changed in this diff Show More