mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
feature: Dynamic and Static Routing (#9470)
This PR contains 3 features - IPv4 Static Routing (Routed mode) #9346 Design document: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=306153967 - AS Numbers Management #9410 Design Document: https://cwiki.apache.org/confluence/display/CLOUDSTACK/BGP+AS+Numbers+Management - Dynamic routing Design Document: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=315492858 - Document: https://github.com/apache/cloudstack-documentation/pull/419 Rename nsx mode to routing mode by ``` git grep -l nsx_mode |xargs sed -i "s/nsx_mode/routing_mode/g" git grep -l nsxmode |xargs sed -i "s/nsxmode/routingmode/g" git grep -l nsxMode |xargs sed -i "s/nsxMode/routingMode/g" git grep -l NsxMode |xargs sed -i "s/NsxMode/RoutingMode/g" ``` - re-organize sql changes - fix NPE as rules do not have public ip - fix missing destination cidr in ingress rules - disable network usage for routed network - fix DB exception as network_id is -1 during network creation - apply ingress/egress routing rules - VR changes to configure nft rules for isolated network - VR: setup nft rule for control network - VR: flush all iptables rules - fix NPE which is because ingress rules do not have public ip associated - fix dest cidr is missing in nft tables - add ip4 routing and ip4 routes to list network and list vpc response - fix ingress rule is missing when vr is restarted - fix icmp types in nft rules - add tab to manage routing firewall rules - fix ingress rules are not applied when VR is restarted - add default rules in FORWARD chain - fix create vpc offerings - fix public ip is not assigned to vpc - fix network offering is not listed when create vpc tier - add is_routing to boot args of vpc vr - remove table ip4_firewall in vpc vr - release or remove subnet when remove a network - implemenent fw_vpcrouter_routing - fix wrong ip familty when flush ipv4 rules - fix acl rules are not applied due to wrong version (should be 6 which means ip6 rules are removed) - add default rules for vpc tiers so that tcp connections (e.g. ssh) work - append policy rules after default rules - remove /usr/local/cloud/systemvm/ in routers - throw an exception when allocate subnet with cidrsize - fix some TODOs - add new parameters to update API - return type Ipv4GuestSubnetNetworkMap when get or create subnet - fix firewall rules are broken - add domain_id and account_id to db - add domain/account/project to ipv4 subnet response - create ipv4 subnet for domain/account/project - check conflict when update ipv4 subnet - ui changes - add parent subnet to response - add list for ipv4 subnet - implement some methods - fix list subnets for guest networks by zoneid - UI changes - fix delete ipv4 subnet for network - fix ipv4 subnet is set to zone guest network cidr if cidrsize is specified - add zone info to response if parent subnet is null but network is not - fix gateway/cidr is not set when create network with cidrsize - fix order of nft rules in the VRs * Routed v24 - add classes in marvin base.py * Routed v25 - add test_01_subnet_zone - fix dedicate to domain/account failure - list subnets for network by keyword and subnet * Routed v26: implement subnet auto-allocation - add utils for split ip ranges into small subnets - add utils to get start/end ip of a cidr - implement subnet auto-generation - add global settings * Routed 27: add subnet for VPC - add db column for vpc_id - add db record for vpc - remove db record when delete a vpc - add checkConflicts methods - remove duplicated settings - check ipv4 cidr when create subnet * Routed v28: update smoke tests - update test_ipv4_routing.py - search subnets by networkid * Routed 29: fix vpc and add more tests - fix createnetwork in vpc - add vpc id/name to response - fix zone id/name are not displayed in some cases - add smoke test for vpc - add smoke tests for failed cases - add smoke test for connectivity checks - marvin: add "-q" to ssh command * Routed 31: ui and smoke tests - UI: add link to network in list view - add nftables rules check in VRs * Routed 32: add chain OUTPUT and more rules - fix the issue 80/443/8080 is not reachable from VR itself ``` 2024-06-27 10:21:52,121 INFO Executing: systemctl start cloud-password-server@172.31.1.1 2024-06-27 10:21:52,128 INFO Service cloud-password-server@172.31.1.1 start 2024-06-27 10:21:52,129 INFO Executing: ps aux 2024-06-27 10:24:02,175 ERROR Failed to update password server due to: <urlopen error [Errno 110] Connection timed out> ``` * Routed: fix dns search from VMs in Isolated networks * Routed: fix VPC dns issue due to gateway IP is missing in cloud.conf This is caused by NSX integration, and fixed by https://github.com/apache/cloudstack/pull/9102/ * Routed: rename routing_mode to network_mode * Routed: replace centos5.5 template in smoke test as dhclient does not work in the vms // this does not work refer to https://dominikrys.com/posts/disable-udp-checksum-validation/#ignoring-udp-checksums-with-nftables and https://forum.openwrt.org/t/udp-checksum-with-nftables/161522/11 the vm should have checksum offloading disabled * Routed: fix smoke test due to wrong cidrlist of egress rules and missing ingress rule from VR * PR 9346: fix lint error schema-41910to42000.sql * PR 9346: ui polish v1 * PR 9346: create VPC with cidrsize * Routed: fix test failures with test_network_ipv6 and test_vpc_ipv6 due to 'ssh -q' * Routed: fix /usr/local/cloud/systemvm/ are removed after SSVM/CPVM reboot * Routed: fix IP of additional nics of VPC VR is not gateway * PR 9346: fix cidrsize check when create VPC with cidrsize * Routed: fix test/integration/smoke/test_ipv4_routing.py:279:16: E713 test for membership should be 'not in' * PR9346: fix/Update api * PR 9346: set response object name * PR9346: UI refactor and small fixes * PR9346: change return type of getNetworkMode * PR9346: move IPv4 subnet to seperated tab * PR9346: revert IpRangesTabGuest.vue back to original * PR9346: fix remove ipv4 subnet on UI * PR9346: fix test_ipv4_routing.py * AS Number Range Management * Create AS Number Range for a Zone * Fix build * Add ListASNRange and fix create ASN range * Add List AS numbers * Add UI for AS Numbers * Fix UI and filter AS Numbers * Add AS Number on Isolated network creation and refactor UI and response * Release AS Number * Add network offering new columns * Add UI support to view and add AS number and configure network offering * Automatically assign AS Number if not specify AS number * update variable name * Fix routing mode check * UI: Only allow selecting AS number when routing mode is Dynamic and specifyAsNumber is true * UI: Only pass AS number when supported by the network offering * Release AS number on network deletion * Add deleteASNRange command (#81) * API: List ASNumbers by asnumber (#83) --------- Co-authored-by: Pearl Dsilva <pearl1594@gmail.com> * AS number management extensions * Support AS number on VPC tier creation based on the offering * Fix delete AS Range * Fix UI values * UI: Minor fix for releasing AS number * UI: Move management of AS Range to Zone details view * Fix specify_as_number column in network_offering table to set the default false * Add events for AS number operations * Allow users to list AS Numbers and fix network form for Normal users * Add AS number details to list networks response * Fix Allocated time format * Fix Allocated time format * support in details view too * Fix: Do not release AS number if acquired network requires AS number * Fix: Do not release AS number if acquired network requires AS number * Fix typo * Fix allocated release * Fix event type * UI: Add Routing mode and Specify AS to the network offering details * UI: Add Routing mode and Specify AS to the network offering details * Address comment * Fix release AS number of network deletion * Fix release AS number of network deletion * Fix * Restore release to its place based on the boolean * Rename boolean * API: Add networkId as listASNumber parameter * Add Network name to the search view filter for AS numbers * Present allocated time in human readable format - Pubilc IP / AS Numbers * Add account / domain filter for AS numbers * Add support for AS numbers on VPC offerings * Refactor AS number allocation to VPC and non VPC isolated networks * Checkstyle * Add support for AS numbers on VPC offerings * extend vpc offering view and vpcoffering response * merge https://github.com/shapeblue/cloudstack-playtika/pull/115 and change network_id of as_numbers to include vpc_id * Display AS number of VPC tiers as the AS number of the VPC * extend asnumber response and ui support * improve UI and as number response to view VPC details * List only dynamic offerings for vpc tiers with specify as numbers * Fix release AS number * Fix AS number displayed as 0 when no AS number assigned * Fix VPC offering creation without specify AS --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Fix release AS number on VPC deletion * Update server/src/main/java/com/cloud/dc/BGPServiceImpl.java * Update server/src/main/java/com/cloud/dc/BGPServiceImpl.java * Fix missing column on asnumber table * Fix listASNumbers API to support vpcid and obtain AS number from vpc for tiers * Prevent listing 0 AS number for VPC * Fix create Isolated Network form * Update server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java * Update server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java * Dynamic: move routingmode/specifyasn after networkmode in AddNetworkOffering.vue on UI * Dynamic: fix ip4routing in network response * Dynamic/systemvm: add FRR to systemvm template * Dynamic: BGP peers (DB,VO,Dao) * Dynamic: BGP peers (VR/server) * Dynamic: v3 - remove BgpPeer class - fix vpc vr has bgp peers of only 1 tier - rename ip4_cidr to guest_ip4_cidr - rename ip6_cidr to guest_ip6_cidr - generate /etc/frr/frr.conf - apply BGP peers on Dynamic-Routed network even if there is no BGP peers * Dynamic v4: fix vpc vr - fix duplicated guest cidr in frr.conf in vpc vr todo - restart frr / reload frr (reload will cause bgp session to Policy state) - apis for bgp peers - assign/release bgp peer from/to network * Dynamic v5: add apis for bgp peers * Dynamic v6: fix bugs - set response object name - remove required as number when update - fix checks when update - allow regular users to list bgp peers * Dynamic v7: move apis to bgp sub-dir * Dynamic v8: add tab for manage BGP peers on UI * Dynamic v9: fix update bgp with same config * Dynamiv v10: add changeBgpPeersForNetworkCmd * Dynamic v11: create network with bgppeerids - create network with bgppeerids - add marvin classes - add smoke tests - remove uuid from bgp_peer_network_map - fix created/removed in bgp_peer_network_map - remove bgppeers when remove a network - UI: fix delete bgp peer * Dynamic v12: add test for vpc tiers * Dynamic v13: bug fixes - fix change BGP peers for network in Allocated state - fix listing network returns removed record - fix all vpc tiers have the same settings - remove BGP peers as part of network removal - remove FRR settings for vpc tiers without any BGP peers - UI: fix no error msg when change BGP peers * Dynamic v14: assign BGP Peers for VPC instead of VPC tiers - create vpc with bgppeerids - do not allow create/update vpc tier with bgppeerids - apply all bgp peers when create/delete a vpc tier - UI: change bgp peers for vpc - test: update tests on vpc * Dynamic: fix build errors after merging as number PR * Dynamic: fix TODOs * Dynamic: fix smoke test on VPC * Allow creation of networks by users with as numbers * Address review comments * Move BGPService to bgp package and inject it on BaseCmd * Revert changes for CKS and address more comments * Display left side menu option for AS number only for root admin * Dynamic: create/update BGP peer with details refer to https://docs.frrouting.org/en/latest/bgp.html * Dynamic: fix build error and remove access to ListBgpPeers cmd for regular users * Dynamic: assign all zone BGP peers to user networks * Dynamic: show BGP peer info of networks only for root admin * AS number: disable specifyasnumber for non-NSX offerings * Dynamic: pass bgppeer details to command and fix typo with ip6 addr * Dynamic: list BGP peers by isdedicated, and fix change bgppeers for network/vpc * Dynamic: add UI labels * Dynamic: add bgp peers to vpc response * Dynamic: list bgp peers by keyword, fix list by asnumber * Dynamic: fix list bgppeers by keyword and db schema * Dynamic: fix list bgppeers do not return dedicated peers * Dynamic: update UI when create network/vpc offering * Update server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com> * Update tools/marvin/setup.py * Dynamic: network mode must be same when update a network with new offering * Dynamic: add method networkModel.isAnyServiceSupportedInNetwork * Dynamic: rename APIs and classes * Dynamic: fix unit tests due to previous changes * Dynamic: validateNetworkCidrSize when auto-create subnet * Dynamic: check AS number overlap * Dynamic: add ActionEvent * Dynamic: small code optimization * Dynamic: fix ui bugs after api rename * Dynamic: add marvin and test for ASN ranges and AS numbers * Dynamic: add account setting use.system.bgp.peers also - change the default value of routed.ipv4.vpc.max.cidr.size and routed.ipv4.vpc.min.cidr.size - change the category of settings * static: fix ui error when delete zone ipv4 subnets * static: small UI polish * Dynamic: throw exception when as number is required but not passed * Dynamic: fix typo when create FRR directory which causes network deletion failures * Dynamic: connect to ALL (or ALL dedicated) BGP peers if no BGP peer mapping for the network/vpc * Dynamic: throw exception when as number is required for VPC but not passed * Dynamic: list bgp peers by useSystemBgpPeers * Dynamic: fix frr config in VPC VR when change bgp peers * Dynamic: create frr config even if there is no VPC tiers * Dynamic: list bgp peers by zoneid (required for account) and account * Dynamic: only apply FRR config for vpc tiers with dynamic routing * Dynamic: donot send commands to router if commands size is 0 * Dynamic: fix 'new IPv6 address is not valid' when update bgp peer without IPv6 * Dynamic: throw exception if fail to allocate AS number when create network/vpc with dynamic routing * Dynamic: enable ipv6 unicast and 'ip nht resolve-via-default' * Dynamic: delete network/vpc if fail to allocate AS number when create network/vpc with dynamic routing * test: add unit tests for ASN APIs * test: add unit tests for core module * test: add unit tests for API responses * test: add unit tests for BgpPeerTO * test: add minor changes * test: add tests for create/delete/update/list RoutingFirewallRuleCmd * Static: show ip4 routes for vpc tiers * test: fix smoke test failure caused by type change of as number * test: add test for Ipv4SubnetForZoneCmd * test: add test for Ipv4SubnetForGuestNetworkCmd and BgpPeerCmd * UI: do not show redundant router when network mode is ROUTED as RVR is not supported * UI: hide 'Conserve mode' when networkmode is ROUTED * test: add unit tests for ListASNumbersCmdTest * Static: remove allocated IPv4 subnet when delete a network or vpc * test: add unit tests for BgpPeersRules * Dynamic: set ipv4routing from network offering * server: list as numbers and ipv4 subnets by keyword * server: remove dedicated bgp peers and ipv4 subnets when delete an account or domain * server: fix dedicated ipv4 subnet is allocated to other accounts * UI: fix allocated time format * server: ignore project is projectid is -1 so bgppeers/ipv4subnets works in project view * UI: add project column to bgp peers and ipv4 subnets * server: fix list AS numbers by domain admin or normal user * server: fix network creation when ipv4 subnet is dedicated * UI: polish network.js * Dynamic: fix frr config for ipv6 routing * Static routing: support cks cluster * Static: get/create IPv4 subnet from dedicated subnets at first * Dynamic: add BGP peers tab * Static: remove redundant loops * api: add since to api and response * server: add unit tests --------- Co-authored-by: Nicolas Vazquez <nicovazquez90@gmail.com> Co-authored-by: Pearl Dsilva <pearl1594@gmail.com> Co-authored-by: Harikrishna Patnala <harikrishna.patnala@gmail.com> Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com> Co-authored-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
85765c3125
commit
679ce1a639
@ -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,
|
||||
|
||||
38
api/src/main/java/com/cloud/bgp/ASNumber.java
Normal file
38
api/src/main/java/com/cloud/bgp/ASNumber.java
Normal 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();
|
||||
}
|
||||
31
api/src/main/java/com/cloud/bgp/ASNumberRange.java
Normal file
31
api/src/main/java/com/cloud/bgp/ASNumberRange.java
Normal 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();
|
||||
}
|
||||
39
api/src/main/java/com/cloud/bgp/BGPService.java
Normal file
39
api/src/main/java/com/cloud/bgp/BGPService.java
Normal 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;
|
||||
}
|
||||
@ -28,7 +28,10 @@ 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;
|
||||
@ -394,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";
|
||||
@ -745,6 +753,25 @@ 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";
|
||||
@ -1217,6 +1244,23 @@ public class EventTypes {
|
||||
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);
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -29,11 +29,17 @@ 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 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";
|
||||
@ -47,6 +53,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";
|
||||
@ -88,6 +96,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";
|
||||
@ -171,6 +181,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";
|
||||
@ -315,7 +326,7 @@ 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 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";
|
||||
@ -356,6 +367,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";
|
||||
@ -441,6 +453,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";
|
||||
@ -519,6 +532,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";
|
||||
@ -547,6 +561,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";
|
||||
@ -688,6 +703,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";
|
||||
@ -703,6 +720,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";
|
||||
@ -964,6 +983,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";
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -22,8 +22,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.cloudstack.api.response.BackupRepositoryResponse;
|
||||
import org.apache.cloudstack.backup.BackupRepository;
|
||||
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;
|
||||
@ -33,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;
|
||||
@ -142,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;
|
||||
@ -556,6 +561,10 @@ public interface ResponseGenerator {
|
||||
|
||||
BucketResponse createBucketResponse(Bucket bucket);
|
||||
|
||||
ASNRangeResponse createASNumberRangeResponse(ASNumberRange asnRange);
|
||||
|
||||
ASNumberResponse createASNumberResponse(ASNumber asn);
|
||||
|
||||
BackupRepositoryResponse createBackupRepositoryResponse(BackupRepository repository);
|
||||
|
||||
SharedFSResponse createSharedFSResponse(ResponseView view, SharedFS sharedFS);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -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,
|
||||
|
||||
@ -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///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -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///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,199 @@
|
||||
// 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.network.Ipv4GuestSubnetNetworkMap;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@EntityReference(value = Ipv4GuestSubnetNetworkMap.class)
|
||||
public class Ipv4SubnetForGuestNetworkResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID)
|
||||
@Param(description = "id of the IPv4 subnet for guest network")
|
||||
private String id;
|
||||
|
||||
@SerializedName(ApiConstants.PARENT_ID)
|
||||
@Param(description = "id of the data center IPv4 subnet")
|
||||
private String parentId;
|
||||
|
||||
@SerializedName(ApiConstants.PARENT_SUBNET)
|
||||
@Param(description = "subnet of the data center IPv4 subnet")
|
||||
private String parentSubnet;
|
||||
|
||||
@SerializedName(ApiConstants.SUBNET)
|
||||
@Param(description = "subnet of the IPv4 network")
|
||||
private String subnet;
|
||||
|
||||
@SerializedName(ApiConstants.STATE)
|
||||
@Param(description = "state of subnet of the IPv4 network")
|
||||
private String state;
|
||||
|
||||
@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 = "id of zone to which the IPv4 subnet belongs to." )
|
||||
private String zoneName;
|
||||
|
||||
@SerializedName(ApiConstants.NETWORK_ID)
|
||||
@Param(description = "id of network which the IPv4 subnet is associated with." )
|
||||
private String networkId;
|
||||
|
||||
@SerializedName(ApiConstants.NETWORK_NAME)
|
||||
@Param(description = "name of network which the IPv4 subnet is associated with." )
|
||||
private String networkName;
|
||||
|
||||
@SerializedName(ApiConstants.VPC_ID)
|
||||
@Param(description = "Id of the VPC which the IPv4 subnet is associated with.")
|
||||
private String vpcId;
|
||||
|
||||
@SerializedName(ApiConstants.VPC_NAME)
|
||||
@Param(description = "Name of the VPC which the IPv4 subnet is associated with.")
|
||||
private String vpcName;
|
||||
|
||||
@SerializedName(ApiConstants.CREATED)
|
||||
@Param(description = "date when this IPv4 subnet was created." )
|
||||
private Date created;
|
||||
|
||||
@SerializedName(ApiConstants.REMOVED)
|
||||
@Param(description = "date when this IPv4 subnet was removed." )
|
||||
private Date removed;
|
||||
|
||||
@SerializedName(ApiConstants.ALLOCATED_TIME)
|
||||
@Param(description = "date when this IPv4 subnet was allocated." )
|
||||
private Date allocatedTime;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public void setParentSubnet(String parentSubnet) {
|
||||
this.parentSubnet = parentSubnet;
|
||||
}
|
||||
|
||||
public void setSubnet(String subnet) {
|
||||
this.subnet = subnet;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void setNetworkId(String networkId) {
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
public void setNetworkName(String networkName) {
|
||||
this.networkName = networkName;
|
||||
}
|
||||
|
||||
public void setVpcId(String vpcId) {
|
||||
this.vpcId = vpcId;
|
||||
}
|
||||
|
||||
public void setVpcName(String vpcName) {
|
||||
this.vpcName = vpcName;
|
||||
}
|
||||
|
||||
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 setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
public void setAllocatedTime(Date allocatedTime) {
|
||||
this.allocatedTime = allocatedTime;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public String getParentSubnet() {
|
||||
return parentSubnet;
|
||||
}
|
||||
|
||||
public String getSubnet() {
|
||||
return subnet;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public String getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
public String getNetworkName() {
|
||||
return networkName;
|
||||
}
|
||||
|
||||
public String getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
public String getVpcName() {
|
||||
return vpcName;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
public Date getAllocatedTime() {
|
||||
return allocatedTime;
|
||||
}
|
||||
}
|
||||
@ -107,9 +107,9 @@ public class NetworkOfferingResponse extends BaseResponseWithAnnotations {
|
||||
@Param(description = "true if network offering can be used by Tungsten-Fabric networks only")
|
||||
private Boolean forTungsten;
|
||||
|
||||
@SerializedName(ApiConstants.NSX_MODE)
|
||||
@Param(description = "Mode in which the network will operate. This parameter is only relevant for NSX offerings")
|
||||
private String nsxMode;
|
||||
@SerializedName(ApiConstants.NETWORK_MODE)
|
||||
@Param(description = "Mode in which the network will operate. The valid values are NATTED and ROUTED")
|
||||
private String networkMode;
|
||||
|
||||
@SerializedName(ApiConstants.IS_PERSISTENT)
|
||||
@Param(description = "true if network offering supports persistent networks, false otherwise")
|
||||
@ -159,6 +159,14 @@ public class NetworkOfferingResponse extends BaseResponseWithAnnotations {
|
||||
@Param(description = "the internet protocol of the network offering")
|
||||
private String internetProtocol;
|
||||
|
||||
@SerializedName(ApiConstants.SPECIFY_AS_NUMBER)
|
||||
@Param(description = "true if network offering supports choosing AS numbers")
|
||||
private Boolean specifyAsNumber;
|
||||
|
||||
@SerializedName(ApiConstants.ROUTING_MODE)
|
||||
@Param(description = "the routing mode for the network offering, supported types are Static or Dynamic.")
|
||||
private String routingMode;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
@ -235,8 +243,8 @@ public class NetworkOfferingResponse extends BaseResponseWithAnnotations {
|
||||
this.forTungsten = forTungsten;
|
||||
}
|
||||
|
||||
public void setNsxMode(String nsxMode) {
|
||||
this.nsxMode = nsxMode;
|
||||
public void setNetworkMode(String networkMode) {
|
||||
this.networkMode = networkMode;
|
||||
}
|
||||
|
||||
public void setIsPersistent(Boolean isPersistent) {
|
||||
@ -306,4 +314,20 @@ public class NetworkOfferingResponse extends BaseResponseWithAnnotations {
|
||||
public void setInternetProtocol(String internetProtocol) {
|
||||
this.internetProtocol = internetProtocol;
|
||||
}
|
||||
|
||||
public Boolean getSpecifyAsNumber() {
|
||||
return specifyAsNumber;
|
||||
}
|
||||
|
||||
public void setSpecifyAsNumber(Boolean specifyAsNumber) {
|
||||
this.specifyAsNumber = specifyAsNumber;
|
||||
}
|
||||
|
||||
public String getRoutingMode() {
|
||||
return routingMode;
|
||||
}
|
||||
|
||||
public void setRoutingMode(String routingMode) {
|
||||
this.routingMode = routingMode;
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -135,6 +136,14 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
|
||||
@Param(description = "The vlan of the network. This parameter is visible to ROOT admins only")
|
||||
private String vlan;
|
||||
|
||||
@SerializedName(ApiConstants.AS_NUMBER_ID)
|
||||
@Param(description = "UUID of AS NUMBER", since = "4.20.0")
|
||||
private String asNumberId;
|
||||
|
||||
@SerializedName(ApiConstants.AS_NUMBER)
|
||||
@Param(description = "AS NUMBER", since = "4.20.0")
|
||||
private Long asNumber;
|
||||
|
||||
@SerializedName(ApiConstants.ACL_TYPE)
|
||||
@Param(description = "acl type - access type to the network")
|
||||
private String aclType;
|
||||
@ -292,7 +301,7 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
|
||||
private String internetProtocol;
|
||||
|
||||
@SerializedName(ApiConstants.IPV6_ROUTING)
|
||||
@Param(description = "The routing mode of network offering", since = "4.17.0")
|
||||
@Param(description = "The Ipv6 routing type of network offering", since = "4.17.0")
|
||||
private String ipv6Routing;
|
||||
|
||||
@SerializedName(ApiConstants.IPV6_ROUTES)
|
||||
@ -315,6 +324,18 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
|
||||
@Param(description = "the second IPv6 DNS for the network", since = "4.18.0")
|
||||
private String ipv6Dns2;
|
||||
|
||||
@SerializedName(ApiConstants.IPV4_ROUTING)
|
||||
@Param(description = "The IPv4 routing type of network", since = "4.20.0")
|
||||
private String ipv4Routing;
|
||||
|
||||
@SerializedName(ApiConstants.IPV4_ROUTES)
|
||||
@Param(description = "The routes for the network to ease adding route in upstream router", since = "4.20.0")
|
||||
private Set<Ipv4RouteResponse> ipv4Routes;
|
||||
|
||||
@SerializedName(ApiConstants.BGP_PEERS)
|
||||
@Param(description = "The BGP peers for the network", since = "4.20.0")
|
||||
private Set<BgpPeerResponse> bgpPeers;
|
||||
|
||||
public NetworkResponse() {}
|
||||
|
||||
public Boolean getDisplayNetwork() {
|
||||
@ -415,6 +436,14 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
|
||||
this.vlan = vlan;
|
||||
}
|
||||
|
||||
public void setAsNumber(long asNumber) {
|
||||
this.asNumber = asNumber;
|
||||
}
|
||||
|
||||
public void setAsNumberId(String asNumberId) {
|
||||
this.asNumberId = asNumberId;
|
||||
}
|
||||
|
||||
public void setIsSystem(Boolean isSystem) {
|
||||
this.isSystem = isSystem;
|
||||
}
|
||||
@ -624,6 +653,18 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
|
||||
this.internetProtocol = internetProtocol;
|
||||
}
|
||||
|
||||
public void setIpv4Routing(String ipv4Routing) {
|
||||
this.ipv4Routing = ipv4Routing;
|
||||
}
|
||||
|
||||
public void setIpv4Routes(Set<Ipv4RouteResponse> ipv4Routes) {
|
||||
this.ipv4Routes = ipv4Routes;
|
||||
}
|
||||
|
||||
public void addIpv4Route(Ipv4RouteResponse ipv4Route) {
|
||||
this.ipv4Routes.add(ipv4Route);
|
||||
}
|
||||
|
||||
public void setIpv6Routing(String ipv6Routing) {
|
||||
this.ipv6Routing = ipv6Routing;
|
||||
}
|
||||
@ -636,6 +677,17 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
|
||||
this.ipv6Routes.add(ipv6Route);
|
||||
}
|
||||
|
||||
public void setBgpPeers(Set<BgpPeerResponse> bgpPeers) {
|
||||
this.bgpPeers = bgpPeers;
|
||||
}
|
||||
|
||||
public void addBgpPeer(BgpPeerResponse bgpPeer) {
|
||||
if (this.bgpPeers == null) {
|
||||
this.setBgpPeers(new LinkedHashSet<>());
|
||||
}
|
||||
this.bgpPeers.add(bgpPeer);
|
||||
}
|
||||
|
||||
public Integer getPublicMtu() {
|
||||
return publicMtu;
|
||||
}
|
||||
|
||||
@ -70,9 +70,9 @@ public class VpcOfferingResponse extends BaseResponse {
|
||||
@Param(description = "true if vpc offering can be used by NSX networks only")
|
||||
private Boolean forNsx;
|
||||
|
||||
@SerializedName(ApiConstants.NSX_MODE)
|
||||
@Param(description = "Mode in which the network will operate. This parameter is only relevant for NSX offerings")
|
||||
private String nsxMode;
|
||||
@SerializedName(ApiConstants.NETWORK_MODE)
|
||||
@Param(description = "Mode in which the network will operate. The valid values are NATTED and ROUTED")
|
||||
private String networkMode;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||
@Param(description = "the domain ID(s) this disk offering belongs to. Ignore this information as it is not currently applicable.")
|
||||
@ -94,6 +94,14 @@ public class VpcOfferingResponse extends BaseResponse {
|
||||
@Param(description = "the internet protocol of the vpc offering")
|
||||
private String internetProtocol;
|
||||
|
||||
@SerializedName(ApiConstants.SPECIFY_AS_NUMBER)
|
||||
@Param(description = "true if network offering supports choosing AS numbers")
|
||||
private Boolean specifyAsNumber;
|
||||
|
||||
@SerializedName(ApiConstants.ROUTING_MODE)
|
||||
@Param(description = "the routing mode for the network offering, supported types are Static or Dynamic.")
|
||||
private String routingMode;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
@ -150,8 +158,8 @@ public class VpcOfferingResponse extends BaseResponse {
|
||||
this.forNsx = forNsx;
|
||||
}
|
||||
|
||||
public void setNsxMode(String nsxMode) {
|
||||
this.nsxMode = nsxMode;
|
||||
public void setNetworkMode(String networkMode) {
|
||||
this.networkMode = networkMode;
|
||||
}
|
||||
|
||||
public String getZoneId() {
|
||||
@ -177,4 +185,20 @@ public class VpcOfferingResponse extends BaseResponse {
|
||||
public void setInternetProtocol(String internetProtocol) {
|
||||
this.internetProtocol = internetProtocol;
|
||||
}
|
||||
|
||||
public Boolean getSpecifyAsNumber() {
|
||||
return specifyAsNumber;
|
||||
}
|
||||
|
||||
public void setSpecifyAsNumber(Boolean specifyAsNumber) {
|
||||
this.specifyAsNumber = specifyAsNumber;
|
||||
}
|
||||
|
||||
public String getRoutingMode() {
|
||||
return routingMode;
|
||||
}
|
||||
|
||||
public void setRoutingMode(String routingMode) {
|
||||
this.routingMode = routingMode;
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -160,6 +161,26 @@ public class VpcResponse extends BaseResponseWithAnnotations implements Controll
|
||||
@Param(description = "the second IPv6 DNS for the VPC", since = "4.18.0")
|
||||
private String ipv6Dns2;
|
||||
|
||||
@SerializedName(ApiConstants.IPV4_ROUTING)
|
||||
@Param(description = "The IPv4 routing mode of VPC", since = "4.20.0")
|
||||
private String ipv4Routing;
|
||||
|
||||
@SerializedName(ApiConstants.IPV4_ROUTES)
|
||||
@Param(description = "The routes for the VPC to ease adding route in upstream router", since = "4.20.0")
|
||||
private Set<Ipv4RouteResponse> ipv4Routes;
|
||||
|
||||
@SerializedName(ApiConstants.AS_NUMBER_ID)
|
||||
@Param(description = "UUID of AS NUMBER", since = "4.20.0")
|
||||
private String asNumberId;
|
||||
|
||||
@SerializedName(ApiConstants.AS_NUMBER)
|
||||
@Param(description = "AS NUMBER", since = "4.20.0")
|
||||
private Long asNumber;
|
||||
|
||||
@SerializedName(ApiConstants.BGP_PEERS)
|
||||
@Param(description = "The BGP peers for the VPC", since = "4.20.0")
|
||||
private Set<BgpPeerResponse> bgpPeers;
|
||||
|
||||
public void setId(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
@ -279,6 +300,18 @@ public class VpcResponse extends BaseResponseWithAnnotations implements Controll
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public void setIpv4Routing(String ipv4Routing) {
|
||||
this.ipv4Routing = ipv4Routing;
|
||||
}
|
||||
|
||||
public void setIpv4Routes(Set<Ipv4RouteResponse> ipv4Routes) {
|
||||
this.ipv4Routes = ipv4Routes;
|
||||
}
|
||||
|
||||
public void addIpv4Route(Ipv4RouteResponse ipv4Route) {
|
||||
this.ipv4Routes.add(ipv4Route);
|
||||
}
|
||||
|
||||
public void setIpv6Routes(Set<Ipv6RouteResponse> ipv6Routes) {
|
||||
this.ipv6Routes = ipv6Routes;
|
||||
}
|
||||
@ -306,4 +339,23 @@ public class VpcResponse extends BaseResponseWithAnnotations implements Controll
|
||||
public void setIpv6Dns2(String ipv6Dns2) {
|
||||
this.ipv6Dns2 = ipv6Dns2;
|
||||
}
|
||||
|
||||
public void setAsNumber(long asNumber) {
|
||||
this.asNumber = asNumber;
|
||||
}
|
||||
|
||||
public void setAsNumberId(String asNumberId) {
|
||||
this.asNumberId = asNumberId;
|
||||
}
|
||||
|
||||
public void setBgpPeers(Set<BgpPeerResponse> bgpPeers) {
|
||||
this.bgpPeers = bgpPeers;
|
||||
}
|
||||
|
||||
public void addBgpPeer(BgpPeerResponse bgpPeer) {
|
||||
if (this.bgpPeers == null) {
|
||||
this.setBgpPeers(new LinkedHashSet<>());
|
||||
}
|
||||
this.bgpPeers.add(bgpPeer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,6 +149,10 @@ public class ZoneResponse extends BaseResponseWithAnnotations implements SetReso
|
||||
@Param(description = "true, if zone is NSX enabled", since = "4.20.0")
|
||||
private boolean nsxEnabled = false;
|
||||
|
||||
@SerializedName(ApiConstants.ASN_RANGE)
|
||||
@Param(description = "AS Number Range")
|
||||
private String asnRange;
|
||||
|
||||
public ZoneResponse() {
|
||||
tags = new LinkedHashSet<ResourceTagResponse>();
|
||||
}
|
||||
@ -392,4 +396,12 @@ public class ZoneResponse extends BaseResponseWithAnnotations implements SetReso
|
||||
public void setNsxEnabled(boolean nsxEnabled) {
|
||||
this.nsxEnabled = nsxEnabled;
|
||||
}
|
||||
|
||||
public void setAsnRange(String asnRange) {
|
||||
this.asnRange = asnRange;
|
||||
}
|
||||
|
||||
public String getAsnRange() {
|
||||
return asnRange;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
// 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.datacenter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.cloudstack.acl.InfrastructureEntity;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
public interface DataCenterIpv4GuestSubnet extends InfrastructureEntity, InternalIdentity, Identity {
|
||||
Long getDataCenterId();
|
||||
|
||||
String getSubnet();
|
||||
|
||||
Long getDomainId();
|
||||
|
||||
Long getAccountId();
|
||||
|
||||
Date getCreated();
|
||||
}
|
||||
50
api/src/main/java/org/apache/cloudstack/network/BgpPeer.java
Normal file
50
api/src/main/java/org/apache/cloudstack/network/BgpPeer.java
Normal 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 org.apache.cloudstack.network;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface BgpPeer extends Identity, InternalIdentity {
|
||||
|
||||
Long getDomainId();
|
||||
|
||||
Long getAccountId();
|
||||
|
||||
enum State {
|
||||
Active, Add, Revoke
|
||||
}
|
||||
|
||||
enum Detail {
|
||||
EBGP_MultiHop
|
||||
}
|
||||
|
||||
long getDataCenterId();
|
||||
|
||||
String getIp4Address();
|
||||
|
||||
String getIp6Address();
|
||||
|
||||
Long getAsNumber();
|
||||
|
||||
String getPassword();
|
||||
|
||||
Date getCreated();
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
// 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.network;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class BgpPeerTO {
|
||||
Long peerId;
|
||||
Long peerAsNumber;
|
||||
String ip4Address;
|
||||
String ip6Address;
|
||||
String peerPassword;
|
||||
Long networkId;
|
||||
Long networkAsNumber;
|
||||
String guestIp4Cidr;
|
||||
String guestIp6Cidr;
|
||||
|
||||
Map<BgpPeer.Detail, String> details;
|
||||
|
||||
public BgpPeerTO(Long peerId, String ip4Address, String ip6Address, Long peerAsNumber, String peerPassword,
|
||||
Long networkId, Long networkAsNumber, String guestIp4Cidr, String guestIp6Cidr, Map<BgpPeer.Detail, String> details) {
|
||||
this.peerId = peerId;
|
||||
this.ip4Address = ip4Address;
|
||||
this.ip6Address = ip6Address;
|
||||
this.peerAsNumber = peerAsNumber;
|
||||
this.peerPassword = peerPassword;
|
||||
this.networkId = networkId;
|
||||
this.networkAsNumber = networkAsNumber;
|
||||
this.guestIp4Cidr = guestIp4Cidr;
|
||||
this.guestIp6Cidr = guestIp6Cidr;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public BgpPeerTO(Long networkId) {
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
public Long getPeerId() {
|
||||
return peerId;
|
||||
}
|
||||
|
||||
public String getIp4Address() {
|
||||
return ip4Address;
|
||||
}
|
||||
|
||||
public String getIp6Address() {
|
||||
return ip6Address;
|
||||
}
|
||||
|
||||
public Long getPeerAsNumber() {
|
||||
return peerAsNumber;
|
||||
}
|
||||
|
||||
public String getPeerPassword() {
|
||||
return peerPassword;
|
||||
}
|
||||
|
||||
public Long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
public Long getNetworkAsNumber() {
|
||||
return networkAsNumber;
|
||||
}
|
||||
|
||||
public String getGuestIp4Cidr() {
|
||||
return guestIp4Cidr;
|
||||
}
|
||||
|
||||
public String getGuestIp6Cidr() {
|
||||
return guestIp6Cidr;
|
||||
}
|
||||
|
||||
public Map<BgpPeer.Detail, String> getDetails() {
|
||||
return details;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
// 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.network;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface Ipv4GuestSubnetNetworkMap extends Identity, InternalIdentity {
|
||||
Date getAllocated();
|
||||
|
||||
Date getCreated();
|
||||
|
||||
enum State {
|
||||
Allocating, // The subnet will be assigned to a network
|
||||
Allocated, // The subnet is in use.
|
||||
Releasing, // The subnet is being released.
|
||||
Free // The subnet is ready to be allocated.
|
||||
}
|
||||
|
||||
Long getParentId();
|
||||
|
||||
String getSubnet();
|
||||
|
||||
Long getVpcId();
|
||||
|
||||
Long getNetworkId();
|
||||
|
||||
State getState();
|
||||
|
||||
}
|
||||
@ -0,0 +1,199 @@
|
||||
// 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.network;
|
||||
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.network.vpc.VpcOffering;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.network.CreateIpv4SubnetForZoneCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.CreateIpv4SubnetForGuestNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.DedicateIpv4SubnetForZoneCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.DeleteIpv4SubnetForZoneCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.DeleteIpv4SubnetForGuestNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.ListIpv4SubnetsForZoneCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.ListIpv4SubnetsForGuestNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.ReleaseDedicatedIpv4SubnetForZoneCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.UpdateIpv4SubnetForZoneCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.bgp.ChangeBgpPeersForNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.bgp.ChangeBgpPeersForVpcCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.bgp.CreateBgpPeerCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.bgp.DedicateBgpPeerCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.bgp.DeleteBgpPeerCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.bgp.ListBgpPeersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.bgp.ReleaseDedicatedBgpPeerCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.bgp.UpdateBgpPeerCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.routing.CreateRoutingFirewallRuleCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.routing.ListRoutingFirewallRulesCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.routing.UpdateRoutingFirewallRuleCmd;
|
||||
import org.apache.cloudstack.api.response.BgpPeerResponse;
|
||||
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
|
||||
import org.apache.cloudstack.api.response.Ipv4SubnetForGuestNetworkResponse;
|
||||
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RoutedIpv4Manager extends PluggableService, Configurable {
|
||||
|
||||
ConfigKey<Integer> RoutedNetworkIPv4MaxCidrSize = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Integer.class,
|
||||
"routed.network.ipv4.max.cidr.size", "30", "The maximum value of the cidr size for isolated networks in ROUTED mode",
|
||||
true, ConfigKey.Scope.Account);
|
||||
|
||||
ConfigKey<Integer> RoutedNetworkIPv4MinCidrSize = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Integer.class,
|
||||
"routed.network.ipv4.min.cidr.size", "24", "The minimum value of the cidr size for isolated networks in ROUTED mode",
|
||||
true, ConfigKey.Scope.Account);
|
||||
|
||||
ConfigKey<Integer> RoutedVpcIPv4MaxCidrSize = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Integer.class,
|
||||
"routed.ipv4.vpc.max.cidr.size", "28", "The maximum value of the cidr size for VPC in ROUTED mode",
|
||||
true, ConfigKey.Scope.Account);
|
||||
|
||||
ConfigKey<Integer> RoutedVpcIPv4MinCidrSize = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Integer.class,
|
||||
"routed.ipv4.vpc.min.cidr.size", "22", "The minimum value of the cidr size for VPC in ROUTED mode",
|
||||
true, ConfigKey.Scope.Account);
|
||||
|
||||
ConfigKey<Boolean> RoutedIPv4NetworkCidrAutoAllocationEnabled = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Boolean.class,
|
||||
"routed.ipv4.network.cidr.auto.allocation.enabled",
|
||||
"true",
|
||||
"Indicates whether the auto-allocation of network CIDR for routed network is enabled or not.",
|
||||
true,
|
||||
ConfigKey.Scope.Account);
|
||||
|
||||
ConfigKey<Boolean> UseSystemBgpPeers = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Boolean.class,
|
||||
"use.system.bgp.peers",
|
||||
"true",
|
||||
"If true, when account has dedicated bgp peers(s), the guest networks with dynamic routing will use both system and dedicated bgp peers. If false, only dedicated bgp peers will be used.",
|
||||
true,
|
||||
ConfigKey.Scope.Account);
|
||||
|
||||
// Methods for DataCenterIpv4GuestSubnet APIs
|
||||
DataCenterIpv4GuestSubnet createDataCenterIpv4GuestSubnet(CreateIpv4SubnetForZoneCmd createIpv4SubnetForZoneCmd);
|
||||
|
||||
DataCenterIpv4SubnetResponse createDataCenterIpv4SubnetResponse(DataCenterIpv4GuestSubnet result);
|
||||
|
||||
boolean deleteDataCenterIpv4GuestSubnet(DeleteIpv4SubnetForZoneCmd deleteIpv4SubnetForZoneCmd);
|
||||
|
||||
DataCenterIpv4GuestSubnet updateDataCenterIpv4GuestSubnet(UpdateIpv4SubnetForZoneCmd updateIpv4SubnetForZoneCmd);
|
||||
|
||||
List<DataCenterIpv4GuestSubnet> listDataCenterIpv4GuestSubnets(ListIpv4SubnetsForZoneCmd listIpv4SubnetsForZoneCmd);
|
||||
|
||||
DataCenterIpv4GuestSubnet dedicateDataCenterIpv4GuestSubnet(DedicateIpv4SubnetForZoneCmd dedicateIpv4SubnetForZoneCmd);
|
||||
|
||||
DataCenterIpv4GuestSubnet releaseDedicatedDataCenterIpv4GuestSubnet(ReleaseDedicatedIpv4SubnetForZoneCmd releaseDedicatedIpv4SubnetForZoneCmd);
|
||||
|
||||
// Methods for Ipv4SubnetForGuestNetwork APIs
|
||||
Ipv4GuestSubnetNetworkMap createIpv4SubnetForGuestNetwork(CreateIpv4SubnetForGuestNetworkCmd createIpv4SubnetForGuestNetworkCmd);
|
||||
|
||||
boolean deleteIpv4SubnetForGuestNetwork(DeleteIpv4SubnetForGuestNetworkCmd deleteIpv4SubnetForGuestNetworkCmd);
|
||||
|
||||
void releaseIpv4SubnetForGuestNetwork(long networkId);
|
||||
|
||||
void releaseIpv4SubnetForVpc(long vpcId);
|
||||
|
||||
List<Ipv4GuestSubnetNetworkMap> listIpv4GuestSubnetsForGuestNetwork(ListIpv4SubnetsForGuestNetworkCmd listIpv4SubnetsForGuestNetworkCmd);
|
||||
|
||||
Ipv4SubnetForGuestNetworkResponse createIpv4SubnetForGuestNetworkResponse(Ipv4GuestSubnetNetworkMap subnet);
|
||||
|
||||
// Methods for internal calls
|
||||
void getOrCreateIpv4SubnetForGuestNetwork(Network network, String networkCidr);
|
||||
|
||||
Ipv4GuestSubnetNetworkMap getOrCreateIpv4SubnetForGuestNetwork(Long domainId, Long accountId, Long zoneId, Integer networkCidrSize);
|
||||
|
||||
void getOrCreateIpv4SubnetForVpc(Vpc vpc, String networkCidr);
|
||||
|
||||
Ipv4GuestSubnetNetworkMap getOrCreateIpv4SubnetForVpc(Vpc vpc, Integer vpcCidrSize);
|
||||
|
||||
void assignIpv4SubnetToNetwork(Network network);
|
||||
|
||||
void assignIpv4SubnetToVpc(Vpc vpc);
|
||||
|
||||
// Methods for Routing firewall rules
|
||||
FirewallRule createRoutingFirewallRule(CreateRoutingFirewallRuleCmd createRoutingFirewallRuleCmd) throws NetworkRuleConflictException;
|
||||
|
||||
Pair<List<? extends FirewallRule>, Integer> listRoutingFirewallRules(ListRoutingFirewallRulesCmd listRoutingFirewallRulesCmd);
|
||||
|
||||
FirewallRule updateRoutingFirewallRule(UpdateRoutingFirewallRuleCmd updateRoutingFirewallRuleCmd);
|
||||
|
||||
boolean revokeRoutingFirewallRule(Long id);
|
||||
|
||||
boolean applyRoutingFirewallRule(long id);
|
||||
|
||||
boolean isVirtualRouterGateway(Network network);
|
||||
|
||||
boolean isVirtualRouterGateway(NetworkOffering networkOffering);
|
||||
|
||||
boolean isRoutedNetwork(Network network);
|
||||
|
||||
boolean isDynamicRoutedNetwork(Network network);
|
||||
|
||||
boolean isDynamicRoutedNetwork(NetworkOffering networkOffering);
|
||||
|
||||
boolean isRoutedVpc(Vpc vpc);
|
||||
|
||||
boolean isVpcVirtualRouterGateway(VpcOffering vpcOffering);
|
||||
|
||||
BgpPeer createBgpPeer(CreateBgpPeerCmd createBgpPeerCmd);
|
||||
|
||||
BgpPeerResponse createBgpPeerResponse(BgpPeer result);
|
||||
|
||||
boolean deleteBgpPeer(DeleteBgpPeerCmd deleteBgpPeerCmd);
|
||||
|
||||
BgpPeer updateBgpPeer(UpdateBgpPeerCmd updateBgpPeerCmd);
|
||||
|
||||
BgpPeer dedicateBgpPeer(DedicateBgpPeerCmd dedicateBgpPeerCmd);
|
||||
|
||||
BgpPeer releaseDedicatedBgpPeer(ReleaseDedicatedBgpPeerCmd releaseDedicatedBgpPeerCmd);
|
||||
|
||||
List<BgpPeer> listBgpPeers(ListBgpPeersCmd listBgpPeersCmd);
|
||||
|
||||
Network changeBgpPeersForNetwork(ChangeBgpPeersForNetworkCmd changeBgpPeersForNetworkCmd);
|
||||
|
||||
Network removeBgpPeersFromNetwork(Network network);
|
||||
|
||||
void validateBgpPeers(Account owner, Long zoneId, List<Long> bgpPeerIds);
|
||||
|
||||
void persistBgpPeersForGuestNetwork(long networkId, List<Long> bgpPeerIds);
|
||||
|
||||
void releaseBgpPeersForGuestNetwork(long networkId);
|
||||
|
||||
boolean isDynamicRoutedVpc(Vpc vpc);
|
||||
|
||||
boolean isDynamicRoutedVpc(VpcOffering vpcOff);
|
||||
|
||||
void persistBgpPeersForVpc(long vpcId, List<Long> bgpPeerIds);
|
||||
|
||||
void releaseBgpPeersForVpc(long vpcId);
|
||||
|
||||
Vpc changeBgpPeersForVpc(ChangeBgpPeersForVpcCmd changeBgpPeersForVpcCmd);
|
||||
|
||||
List<Long> getBgpPeerIdsForAccount(Account owner, long zoneIdd);
|
||||
|
||||
void removeIpv4SubnetsForZoneByAccountId(long accountId);
|
||||
|
||||
void removeIpv4SubnetsForZoneByDomainId(long domainId);
|
||||
|
||||
void removeBgpPeersByAccountId(long accountId);
|
||||
|
||||
void removeBgpPeersByDomainId(long domainId);
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
// 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.bgp.BGPService;
|
||||
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.response.ASNRangeResponse;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CreateASNRangeCmdTest {
|
||||
|
||||
BGPService bgpService = Mockito.spy(BGPService.class);
|
||||
ResponseGenerator _responseGenerator = Mockito.spy(ResponseGenerator.class);
|
||||
|
||||
@Test
|
||||
public void testCreateASNRangeCmd() {
|
||||
Long zoneId = 1L;
|
||||
Long startASNumber = 110000L;
|
||||
Long endASNumber = 120000L;
|
||||
|
||||
CreateASNRangeCmd cmd = new CreateASNRangeCmd();
|
||||
ReflectionTestUtils.setField(cmd, "zoneId", zoneId);
|
||||
ReflectionTestUtils.setField(cmd, "startASNumber", startASNumber);
|
||||
ReflectionTestUtils.setField(cmd, "endASNumber", endASNumber);
|
||||
ReflectionTestUtils.setField(cmd,"bgpService", bgpService);
|
||||
ReflectionTestUtils.setField(cmd,"_responseGenerator", _responseGenerator);
|
||||
|
||||
Assert.assertEquals(zoneId, cmd.getZoneId());
|
||||
Assert.assertEquals(startASNumber, cmd.getStartASNumber());
|
||||
Assert.assertEquals(endASNumber, cmd.getEndASNumber());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
|
||||
ASNumberRange asnRange = Mockito.mock(ASNumberRange.class);
|
||||
Mockito.when(bgpService.createASNumberRange(zoneId, startASNumber, endASNumber)).thenReturn(asnRange);
|
||||
|
||||
ASNRangeResponse response = Mockito.mock(ASNRangeResponse.class);
|
||||
Mockito.when(_responseGenerator.createASNumberRangeResponse(asnRange)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
// 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.BGPService;
|
||||
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DeleteASNRangeCmdTest {
|
||||
|
||||
BGPService bgpService = Mockito.spy(BGPService.class);
|
||||
|
||||
@Test
|
||||
public void testDeleteASNRangeCmd() {
|
||||
Long id = 200L;
|
||||
|
||||
DeleteASNRangeCmd cmd = new DeleteASNRangeCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd,"bgpService", bgpService);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
|
||||
Mockito.when(bgpService.deleteASRange(id)).thenReturn(true);
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Object response = cmd.getResponseObject();
|
||||
Assert.assertTrue(response instanceof SuccessResponse);
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
// 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.bgp.BGPService;
|
||||
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.response.ASNRangeResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ListASNRangesCmdTest {
|
||||
|
||||
BGPService bgpService = Mockito.spy(BGPService.class);
|
||||
ResponseGenerator _responseGenerator = Mockito.spy(ResponseGenerator.class);
|
||||
|
||||
@Test
|
||||
public void testListASNRangesCmdTest() {
|
||||
Long zoneId = 1L;
|
||||
|
||||
ListASNRangesCmd cmd = new ListASNRangesCmd();
|
||||
ReflectionTestUtils.setField(cmd, "zoneId", zoneId);
|
||||
ReflectionTestUtils.setField(cmd,"bgpService", bgpService);
|
||||
ReflectionTestUtils.setField(cmd,"_responseGenerator", _responseGenerator);
|
||||
|
||||
Assert.assertEquals(zoneId, cmd.getZoneId());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
|
||||
List<ASNumberRange> ranges = new ArrayList<>();
|
||||
ASNumberRange asnRange = Mockito.mock(ASNumberRange.class);
|
||||
ranges.add(asnRange);
|
||||
|
||||
ASNRangeResponse asnRangeResponse = Mockito.mock(ASNRangeResponse.class);
|
||||
Mockito.when(_responseGenerator.createASNumberRangeResponse(asnRange)).thenReturn(asnRangeResponse);
|
||||
|
||||
Mockito.when(bgpService.listASNumberRanges(zoneId)).thenReturn(ranges);
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Object response = cmd.getResponseObject();
|
||||
Assert.assertTrue(response instanceof ListResponse);
|
||||
ListResponse listResponse = (ListResponse) response;
|
||||
Assert.assertEquals(1L, (long) listResponse.getCount());
|
||||
Assert.assertTrue(listResponse.getResponses().get(0) instanceof ASNRangeResponse);
|
||||
ASNRangeResponse firstResponse = (ASNRangeResponse) listResponse.getResponses().get(0);
|
||||
Assert.assertEquals(asnRangeResponse, firstResponse);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
// 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.BGPService;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ReleaseASNumberCmdTest {
|
||||
|
||||
BGPService bgpService = Mockito.spy(BGPService.class);
|
||||
|
||||
@Test
|
||||
public void testReleaseASNumberCmd() {
|
||||
Long zoneId = 1L;
|
||||
Long asNumber = 10000L;
|
||||
|
||||
ReleaseASNumberCmd cmd = new ReleaseASNumberCmd();
|
||||
ReflectionTestUtils.setField(cmd, "zoneId", zoneId);
|
||||
ReflectionTestUtils.setField(cmd, "asNumber", asNumber);
|
||||
ReflectionTestUtils.setField(cmd,"bgpService", bgpService);
|
||||
|
||||
Assert.assertEquals(zoneId, cmd.getZoneId());
|
||||
Assert.assertEquals(asNumber, cmd.getAsNumber());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
|
||||
Pair<Boolean, String> resultPair = Mockito.mock(Pair.class);
|
||||
Mockito.when(resultPair.first()).thenReturn(true);
|
||||
Mockito.when(bgpService.releaseASNumber(zoneId, asNumber, false)).thenReturn(resultPair);
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Object response = cmd.getResponseObject();
|
||||
Assert.assertTrue(response instanceof SuccessResponse);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
|
||||
import org.apache.cloudstack.api.response.Ipv4SubnetForGuestNetworkResponse;
|
||||
import org.apache.cloudstack.network.Ipv4GuestSubnetNetworkMap;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CreateIpv4SubnetForGuestNetworkCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testCreateIpv4SubnetForGuestNetworkCmd() {
|
||||
Long parentId = 1L;
|
||||
String subnet = "192.168.1.0/24";
|
||||
Integer cidrSize = 26;
|
||||
|
||||
CreateIpv4SubnetForGuestNetworkCmd cmd = new CreateIpv4SubnetForGuestNetworkCmd();
|
||||
ReflectionTestUtils.setField(cmd, "parentId", parentId);
|
||||
ReflectionTestUtils.setField(cmd, "subnet", subnet);
|
||||
ReflectionTestUtils.setField(cmd, "cidrSize", cidrSize);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(parentId, cmd.getParentId());
|
||||
Assert.assertEquals(subnet, cmd.getSubnet());
|
||||
Assert.assertEquals(cidrSize, cmd.getCidrSize());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_IP4_GUEST_SUBNET_CREATE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Creating guest IPv4 subnet %s in zone subnet=%s", subnet, parentId), cmd.getEventDescription());
|
||||
|
||||
Ipv4GuestSubnetNetworkMap ipv4GuestSubnetNetworkMap = Mockito.mock(Ipv4GuestSubnetNetworkMap.class);
|
||||
Mockito.when(routedIpv4Manager.createIpv4SubnetForGuestNetwork(cmd)).thenReturn(ipv4GuestSubnetNetworkMap);
|
||||
|
||||
Ipv4SubnetForGuestNetworkResponse response = Mockito.mock(Ipv4SubnetForGuestNetworkResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createIpv4SubnetForGuestNetworkResponse(ipv4GuestSubnetNetworkMap)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
|
||||
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
|
||||
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CreateIpv4SubnetForZoneCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testCreateIpv4SubnetForZoneCmd() {
|
||||
Long zoneId = 1L;
|
||||
String subnet = "192.168.1.0/24";
|
||||
String accountName = "user";
|
||||
Long projectId = 10L;
|
||||
Long domainId = 11L;
|
||||
|
||||
CreateIpv4SubnetForZoneCmd cmd = new CreateIpv4SubnetForZoneCmd();
|
||||
ReflectionTestUtils.setField(cmd, "zoneId", zoneId);
|
||||
ReflectionTestUtils.setField(cmd, "subnet", subnet);
|
||||
ReflectionTestUtils.setField(cmd, "accountName", accountName);
|
||||
ReflectionTestUtils.setField(cmd,"projectId", projectId);
|
||||
ReflectionTestUtils.setField(cmd,"domainId", domainId);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(zoneId, cmd.getZoneId());
|
||||
Assert.assertEquals(subnet, cmd.getSubnet());
|
||||
Assert.assertEquals(accountName, cmd.getAccountName());
|
||||
Assert.assertEquals(projectId, cmd.getProjectId());
|
||||
Assert.assertEquals(domainId, cmd.getDomainId());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_ZONE_IP4_SUBNET_CREATE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Creating guest IPv4 subnet %s for zone=%s", subnet, zoneId), cmd.getEventDescription());
|
||||
|
||||
DataCenterIpv4GuestSubnet zoneSubnet = Mockito.mock(DataCenterIpv4GuestSubnet.class);
|
||||
Mockito.when(routedIpv4Manager.createDataCenterIpv4GuestSubnet(cmd)).thenReturn(zoneSubnet);
|
||||
|
||||
DataCenterIpv4SubnetResponse response = Mockito.mock(DataCenterIpv4SubnetResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createDataCenterIpv4SubnetResponse(zoneSubnet)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
|
||||
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DedicateIpv4SubnetForZoneCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testDedicateIpv4SubnetForZoneCmd() {
|
||||
Long id = 1L;
|
||||
String accountName = "user";
|
||||
Long projectId = 10L;
|
||||
Long domainId = 11L;
|
||||
|
||||
DedicateIpv4SubnetForZoneCmd cmd = new DedicateIpv4SubnetForZoneCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd, "accountName", accountName);
|
||||
ReflectionTestUtils.setField(cmd,"projectId", projectId);
|
||||
ReflectionTestUtils.setField(cmd,"domainId", domainId);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(accountName, cmd.getAccountName());
|
||||
Assert.assertEquals(projectId, cmd.getProjectId());
|
||||
Assert.assertEquals(domainId, cmd.getDomainId());
|
||||
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_ZONE_IP4_SUBNET_DEDICATE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Dedicating zone IPv4 subnet %s", id), cmd.getEventDescription());
|
||||
|
||||
DataCenterIpv4GuestSubnet zoneSubnet = Mockito.mock(DataCenterIpv4GuestSubnet.class);
|
||||
Mockito.when(routedIpv4Manager.dedicateDataCenterIpv4GuestSubnet(cmd)).thenReturn(zoneSubnet);
|
||||
|
||||
DataCenterIpv4SubnetResponse response = Mockito.mock(DataCenterIpv4SubnetResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createDataCenterIpv4SubnetResponse(zoneSubnet)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DeleteIpv4SubnetForGuestNetworkCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testDeleteIpv4SubnetForGuestNetworkCmd() {
|
||||
Long id = 1L;
|
||||
|
||||
DeleteIpv4SubnetForGuestNetworkCmd cmd = new DeleteIpv4SubnetForGuestNetworkCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_IP4_GUEST_SUBNET_DELETE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Deleting guest IPv4 subnet %s", id), cmd.getEventDescription());
|
||||
|
||||
Mockito.when(routedIpv4Manager.deleteIpv4SubnetForGuestNetwork(cmd)).thenReturn(true);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertTrue(cmd.getResponseObject() instanceof SuccessResponse);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DeleteIpv4SubnetForZoneCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testDeleteIpv4SubnetForZoneCmd() {
|
||||
Long id = 1L;
|
||||
|
||||
DeleteIpv4SubnetForZoneCmd cmd = new DeleteIpv4SubnetForZoneCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_ZONE_IP4_SUBNET_DELETE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Deleting zone IPv4 subnet %s", id), cmd.getEventDescription());
|
||||
|
||||
Mockito.when(routedIpv4Manager.deleteDataCenterIpv4GuestSubnet(cmd)).thenReturn(true);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertTrue(cmd.getResponseObject() instanceof SuccessResponse);
|
||||
}
|
||||
}
|
||||
@ -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.network;
|
||||
|
||||
import org.apache.cloudstack.api.response.Ipv4SubnetForGuestNetworkResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.network.Ipv4GuestSubnetNetworkMap;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ListIpv4SubnetsForGuestNetworkCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testListIpv4SubnetsForGuestNetworkCmd() {
|
||||
Long id = 1L;
|
||||
Long zoneId = 2L;
|
||||
Long parentId = 2L;
|
||||
String subnet = "192.168.1.0/24";
|
||||
Long networkId = 10L;
|
||||
Long vpcId = 11L;
|
||||
|
||||
ListIpv4SubnetsForGuestNetworkCmd cmd = new ListIpv4SubnetsForGuestNetworkCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd, "zoneId", zoneId);
|
||||
ReflectionTestUtils.setField(cmd, "subnet", subnet);
|
||||
ReflectionTestUtils.setField(cmd, "parentId", parentId);
|
||||
ReflectionTestUtils.setField(cmd,"networkId", networkId);
|
||||
ReflectionTestUtils.setField(cmd,"vpcId", vpcId);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(zoneId, cmd.getZoneId());
|
||||
Assert.assertEquals(subnet, cmd.getSubnet());
|
||||
Assert.assertEquals(networkId, cmd.getNetworkId());
|
||||
Assert.assertEquals(vpcId, cmd.getVpcId());
|
||||
Assert.assertEquals(parentId, cmd.getParentId());
|
||||
|
||||
Assert.assertEquals(0L, cmd.getEntityOwnerId());
|
||||
|
||||
Ipv4GuestSubnetNetworkMap ipv4GuestSubnetNetworkMap = Mockito.mock(Ipv4GuestSubnetNetworkMap.class);
|
||||
List<Ipv4GuestSubnetNetworkMap> ipv4GuestSubnetNetworkMaps = Arrays.asList(ipv4GuestSubnetNetworkMap);
|
||||
Mockito.when(routedIpv4Manager.listIpv4GuestSubnetsForGuestNetwork(cmd)).thenReturn(ipv4GuestSubnetNetworkMaps);
|
||||
|
||||
Ipv4SubnetForGuestNetworkResponse response = Mockito.mock(Ipv4SubnetForGuestNetworkResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createIpv4SubnetForGuestNetworkResponse(ipv4GuestSubnetNetworkMap)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertTrue(cmd.getResponseObject() instanceof ListResponse);
|
||||
ListResponse listResponse = (ListResponse) cmd.getResponseObject();
|
||||
Assert.assertEquals(1, (int) listResponse.getCount());
|
||||
Assert.assertEquals(response, listResponse.getResponses().get(0));
|
||||
}
|
||||
}
|
||||
@ -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.network;
|
||||
|
||||
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ListIpv4SubnetsForZoneCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testListIpv4SubnetsForZoneCmd() {
|
||||
Long id = 1L;
|
||||
Long zoneId = 2L;
|
||||
String subnet = "192.168.1.0/24";
|
||||
String accountName = "user";
|
||||
Long projectId = 10L;
|
||||
Long domainId = 11L;
|
||||
|
||||
ListIpv4SubnetsForZoneCmd cmd = new ListIpv4SubnetsForZoneCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd, "zoneId", zoneId);
|
||||
ReflectionTestUtils.setField(cmd, "subnet", subnet);
|
||||
ReflectionTestUtils.setField(cmd, "accountName", accountName);
|
||||
ReflectionTestUtils.setField(cmd,"projectId", projectId);
|
||||
ReflectionTestUtils.setField(cmd,"domainId", domainId);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(zoneId, cmd.getZoneId());
|
||||
Assert.assertEquals(subnet, cmd.getSubnet());
|
||||
Assert.assertEquals(accountName, cmd.getAccountName());
|
||||
Assert.assertEquals(projectId, cmd.getProjectId());
|
||||
Assert.assertEquals(domainId, cmd.getDomainId());
|
||||
|
||||
Assert.assertEquals(0L, cmd.getEntityOwnerId());
|
||||
|
||||
DataCenterIpv4GuestSubnet zoneSubnet = Mockito.mock(DataCenterIpv4GuestSubnet.class);
|
||||
List<DataCenterIpv4GuestSubnet> zoneSubnets = Arrays.asList(zoneSubnet);
|
||||
Mockito.when(routedIpv4Manager.listDataCenterIpv4GuestSubnets(cmd)).thenReturn(zoneSubnets);
|
||||
|
||||
DataCenterIpv4SubnetResponse response = Mockito.mock(DataCenterIpv4SubnetResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createDataCenterIpv4SubnetResponse(zoneSubnet)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertTrue(cmd.getResponseObject() instanceof ListResponse);
|
||||
ListResponse listResponse = (ListResponse) cmd.getResponseObject();
|
||||
Assert.assertEquals(1, (int) listResponse.getCount());
|
||||
Assert.assertEquals(response, listResponse.getResponses().get(0));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
|
||||
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ReleaseDedicatedIpv4SubnetForZoneCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testReleaseDedicatedIpv4SubnetForZoneCmd() {
|
||||
Long id = 1L;
|
||||
|
||||
ReleaseDedicatedIpv4SubnetForZoneCmd cmd = new ReleaseDedicatedIpv4SubnetForZoneCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_ZONE_IP4_SUBNET_RELEASE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Releasing a dedicated zone IPv4 subnet %s", id), cmd.getEventDescription());
|
||||
|
||||
DataCenterIpv4GuestSubnet zoneSubnet = Mockito.mock(DataCenterIpv4GuestSubnet.class);
|
||||
Mockito.when(routedIpv4Manager.releaseDedicatedDataCenterIpv4GuestSubnet(cmd)).thenReturn(zoneSubnet);
|
||||
|
||||
DataCenterIpv4SubnetResponse response = Mockito.mock(DataCenterIpv4SubnetResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createDataCenterIpv4SubnetResponse(zoneSubnet)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
|
||||
import org.apache.cloudstack.api.response.DataCenterIpv4SubnetResponse;
|
||||
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class UpdateIpv4SubnetForZoneCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testUpdateIpv4SubnetForZoneCmd() {
|
||||
Long id = 1L;
|
||||
String subnet = "192.168.1.0/24";
|
||||
|
||||
UpdateIpv4SubnetForZoneCmd cmd = new UpdateIpv4SubnetForZoneCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd, "subnet", subnet);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(subnet, cmd.getSubnet());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_ZONE_IP4_SUBNET_UPDATE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Updating zone IPv4 subnet %s", id), cmd.getEventDescription());
|
||||
|
||||
DataCenterIpv4GuestSubnet zoneSubnet = Mockito.mock(DataCenterIpv4GuestSubnet.class);
|
||||
Mockito.when(routedIpv4Manager.updateDataCenterIpv4GuestSubnet(cmd)).thenReturn(zoneSubnet);
|
||||
|
||||
DataCenterIpv4SubnetResponse response = Mockito.mock(DataCenterIpv4SubnetResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createDataCenterIpv4SubnetResponse(zoneSubnet)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.ResponseObject;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ChangeBgpPeersForNetworkCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
ResponseGenerator _responseGenerator = Mockito.spy(ResponseGenerator.class);
|
||||
|
||||
@Test
|
||||
public void testChangeBgpPeersForNetworkCmd() {
|
||||
Long networkId = 10L;
|
||||
List<Long> bgpPeerIds = Arrays.asList(20L, 21L);
|
||||
|
||||
ChangeBgpPeersForNetworkCmd cmd = new ChangeBgpPeersForNetworkCmd();
|
||||
ReflectionTestUtils.setField(cmd, "networkId", networkId);
|
||||
ReflectionTestUtils.setField(cmd, "bgpPeerIds", bgpPeerIds);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
ReflectionTestUtils.setField(cmd,"_responseGenerator", _responseGenerator);
|
||||
|
||||
Assert.assertEquals(networkId, cmd.getNetworkId());
|
||||
Assert.assertEquals(bgpPeerIds, cmd.getBgpPeerIds());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_NETWORK_BGP_PEER_UPDATE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Changing Bgp Peers for network %s", networkId), cmd.getEventDescription());
|
||||
|
||||
Network network = Mockito.mock(Network.class);
|
||||
Mockito.when(routedIpv4Manager.changeBgpPeersForNetwork(cmd)).thenReturn(network);
|
||||
|
||||
NetworkResponse response = Mockito.mock(NetworkResponse.class);
|
||||
Mockito.when(_responseGenerator.createNetworkResponse(ResponseObject.ResponseView.Full, network)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.ResponseObject;
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ChangeBgpPeersForVpcCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
ResponseGenerator _responseGenerator = Mockito.spy(ResponseGenerator.class);
|
||||
|
||||
@Test
|
||||
public void testChangeBgpPeersForVpcCmd() {
|
||||
Long VpcId = 10L;
|
||||
List<Long> bgpPeerIds = Arrays.asList(20L, 21L);
|
||||
|
||||
ChangeBgpPeersForVpcCmd cmd = new ChangeBgpPeersForVpcCmd();
|
||||
ReflectionTestUtils.setField(cmd, "vpcId", VpcId);
|
||||
ReflectionTestUtils.setField(cmd, "bgpPeerIds", bgpPeerIds);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
ReflectionTestUtils.setField(cmd,"_responseGenerator", _responseGenerator);
|
||||
|
||||
Assert.assertEquals(VpcId, cmd.getVpcId());
|
||||
Assert.assertEquals(bgpPeerIds, cmd.getBgpPeerIds());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_VPC_BGP_PEER_UPDATE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Changing Bgp Peers for VPC %s", VpcId), cmd.getEventDescription());
|
||||
|
||||
Vpc Vpc = Mockito.mock(Vpc.class);
|
||||
Mockito.when(routedIpv4Manager.changeBgpPeersForVpc(cmd)).thenReturn(Vpc);
|
||||
|
||||
VpcResponse response = Mockito.mock(VpcResponse.class);
|
||||
Mockito.when(_responseGenerator.createVpcResponse(ResponseObject.ResponseView.Full, Vpc)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
|
||||
import org.apache.cloudstack.api.response.BgpPeerResponse;
|
||||
import org.apache.cloudstack.network.BgpPeer;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CreateBgpPeerCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testCreateBgpPeerCmd() {
|
||||
Long zoneId = 1L;
|
||||
String accountName = "user";
|
||||
Long projectId = 10L;
|
||||
Long domainId = 11L;
|
||||
String ip4Address = "ip4-address";
|
||||
String ip6Address = "ip6-address";
|
||||
Long peerAsNumber = 15000L;
|
||||
String peerPassword = "peer-password";
|
||||
|
||||
CreateBgpPeerCmd cmd = new CreateBgpPeerCmd();
|
||||
ReflectionTestUtils.setField(cmd, "zoneId", zoneId);
|
||||
ReflectionTestUtils.setField(cmd, "ip4Address", ip4Address);
|
||||
ReflectionTestUtils.setField(cmd, "ip6Address", ip6Address);
|
||||
ReflectionTestUtils.setField(cmd, "asNumber", peerAsNumber);
|
||||
ReflectionTestUtils.setField(cmd, "password", peerPassword);
|
||||
ReflectionTestUtils.setField(cmd, "accountName", accountName);
|
||||
ReflectionTestUtils.setField(cmd,"projectId", projectId);
|
||||
ReflectionTestUtils.setField(cmd,"domainId", domainId);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(zoneId, cmd.getZoneId());
|
||||
Assert.assertEquals(ip4Address, cmd.getIp4Address());
|
||||
Assert.assertEquals(ip6Address, cmd.getIp6Address());
|
||||
Assert.assertEquals(peerAsNumber, cmd.getAsNumber());
|
||||
Assert.assertEquals(peerPassword, cmd.getPassword());
|
||||
Assert.assertEquals(accountName, cmd.getAccountName());
|
||||
Assert.assertEquals(projectId, cmd.getProjectId());
|
||||
Assert.assertEquals(domainId, cmd.getDomainId());
|
||||
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_BGP_PEER_CREATE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Creating Bgp Peer %s for zone=%s", peerAsNumber, zoneId), cmd.getEventDescription());
|
||||
|
||||
BgpPeer bgpPeer = Mockito.mock(BgpPeer.class);
|
||||
Mockito.when(routedIpv4Manager.createBgpPeer(cmd)).thenReturn(bgpPeer);
|
||||
|
||||
BgpPeerResponse response = Mockito.mock(BgpPeerResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createBgpPeerResponse(bgpPeer)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
import org.apache.cloudstack.api.response.BgpPeerResponse;
|
||||
import org.apache.cloudstack.network.BgpPeer;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DedicateBgpPeerCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testDedicateBgpPeerCmd() {
|
||||
Long id = 1L;
|
||||
String accountName = "user";
|
||||
Long projectId = 10L;
|
||||
Long domainId = 11L;
|
||||
|
||||
DedicateBgpPeerCmd cmd = new DedicateBgpPeerCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd, "accountName", accountName);
|
||||
ReflectionTestUtils.setField(cmd,"projectId", projectId);
|
||||
ReflectionTestUtils.setField(cmd,"domainId", domainId);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(accountName, cmd.getAccountName());
|
||||
Assert.assertEquals(projectId, cmd.getProjectId());
|
||||
Assert.assertEquals(domainId, cmd.getDomainId());
|
||||
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_BGP_PEER_DEDICATE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Dedicating Bgp Peer %s", id), cmd.getEventDescription());
|
||||
|
||||
BgpPeer bgpPeer = Mockito.mock(BgpPeer.class);
|
||||
Mockito.when(routedIpv4Manager.dedicateBgpPeer(cmd)).thenReturn(bgpPeer);
|
||||
|
||||
BgpPeerResponse response = Mockito.mock(BgpPeerResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createBgpPeerResponse(bgpPeer)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DeleteBgpPeerCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testDeleteBgpPeerCmd() {
|
||||
Long id = 1L;
|
||||
|
||||
DeleteBgpPeerCmd cmd = new DeleteBgpPeerCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_BGP_PEER_DELETE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Deleting Bgp Peer %s", id), cmd.getEventDescription());
|
||||
|
||||
Mockito.when(routedIpv4Manager.deleteBgpPeer(cmd)).thenReturn(true);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertTrue(cmd.getResponseObject() instanceof SuccessResponse);
|
||||
}
|
||||
}
|
||||
@ -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.admin.network.bgp;
|
||||
|
||||
import org.apache.cloudstack.api.response.BgpPeerResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.network.BgpPeer;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ListBgpPeersCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testIsDedicated() {
|
||||
ListBgpPeersCmd cmd = new ListBgpPeersCmd();
|
||||
|
||||
Assert.assertNull(cmd.getDedicated());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "isDedicated", Boolean.TRUE);
|
||||
Assert.assertTrue(cmd.getDedicated());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "isDedicated", Boolean.FALSE);
|
||||
Assert.assertFalse(cmd.getDedicated());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListBgpPeersCmd() {
|
||||
Long id = 1L;
|
||||
Long zoneId = 2L;
|
||||
Long peerAsNumber = 15000L;
|
||||
String accountName = "user";
|
||||
Long projectId = 10L;
|
||||
Long domainId = 11L;
|
||||
|
||||
ListBgpPeersCmd cmd = new ListBgpPeersCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd, "zoneId", zoneId);
|
||||
ReflectionTestUtils.setField(cmd, "asNumber", peerAsNumber);
|
||||
ReflectionTestUtils.setField(cmd, "accountName", accountName);
|
||||
ReflectionTestUtils.setField(cmd,"projectId", projectId);
|
||||
ReflectionTestUtils.setField(cmd,"domainId", domainId);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(zoneId, cmd.getZoneId());
|
||||
Assert.assertEquals(peerAsNumber, cmd.getAsNumber());
|
||||
Assert.assertEquals(accountName, cmd.getAccountName());
|
||||
Assert.assertEquals(projectId, cmd.getProjectId());
|
||||
Assert.assertEquals(domainId, cmd.getDomainId());
|
||||
|
||||
Assert.assertEquals(0L, cmd.getEntityOwnerId());
|
||||
|
||||
BgpPeer bgpPeer = Mockito.mock(BgpPeer.class);
|
||||
List<BgpPeer> bgpPeers = Arrays.asList(bgpPeer);
|
||||
Mockito.when(routedIpv4Manager.listBgpPeers(cmd)).thenReturn(bgpPeers);
|
||||
|
||||
BgpPeerResponse response = Mockito.mock(BgpPeerResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createBgpPeerResponse(bgpPeer)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertTrue(cmd.getResponseObject() instanceof ListResponse);
|
||||
ListResponse listResponse = (ListResponse) cmd.getResponseObject();
|
||||
Assert.assertEquals(1, (int) listResponse.getCount());
|
||||
Assert.assertEquals(response, listResponse.getResponses().get(0));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
import org.apache.cloudstack.api.response.BgpPeerResponse;
|
||||
import org.apache.cloudstack.network.BgpPeer;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ReleaseDedicatedBgpPeerCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testReleaseDedicatedBgpPeerCmd() {
|
||||
Long id = 1L;
|
||||
|
||||
ReleaseDedicatedBgpPeerCmd cmd = new ReleaseDedicatedBgpPeerCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_BGP_PEER_RELEASE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Releasing a dedicated Bgp Peer %s", id), cmd.getEventDescription());
|
||||
|
||||
BgpPeer bgpPeer = Mockito.mock(BgpPeer.class);
|
||||
Mockito.when(routedIpv4Manager.releaseDedicatedBgpPeer(cmd)).thenReturn(bgpPeer);
|
||||
|
||||
BgpPeerResponse response = Mockito.mock(BgpPeerResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createBgpPeerResponse(bgpPeer)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
|
||||
import org.apache.cloudstack.api.response.BgpPeerResponse;
|
||||
import org.apache.cloudstack.network.BgpPeer;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class UpdateBgpPeerCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
@Test
|
||||
public void testUpdateBgpPeerCmd() {
|
||||
Long id = 1L;
|
||||
String ip4Address = "ip4-address";
|
||||
String ip6Address = "ip6-address";
|
||||
Long peerAsNumber = 15000L;
|
||||
String peerPassword = "peer-password";
|
||||
|
||||
UpdateBgpPeerCmd cmd = new UpdateBgpPeerCmd();
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd, "ip4Address", ip4Address);
|
||||
ReflectionTestUtils.setField(cmd, "ip6Address", ip6Address);
|
||||
ReflectionTestUtils.setField(cmd, "asNumber", peerAsNumber);
|
||||
ReflectionTestUtils.setField(cmd, "password", peerPassword);
|
||||
ReflectionTestUtils.setField(cmd,"routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Assert.assertEquals(id, cmd.getId());
|
||||
Assert.assertEquals(ip4Address, cmd.getIp4Address());
|
||||
Assert.assertEquals(ip6Address, cmd.getIp6Address());
|
||||
Assert.assertEquals(peerAsNumber, cmd.getAsNumber());
|
||||
Assert.assertEquals(peerPassword, cmd.getPassword());
|
||||
Assert.assertEquals(1L, cmd.getEntityOwnerId());
|
||||
Assert.assertEquals(EventTypes.EVENT_BGP_PEER_UPDATE, cmd.getEventType());
|
||||
Assert.assertEquals(String.format("Updating Bgp Peer %s", id), cmd.getEventDescription());
|
||||
|
||||
BgpPeer bgpPeer = Mockito.mock(BgpPeer.class);
|
||||
Mockito.when(routedIpv4Manager.updateBgpPeer(cmd)).thenReturn(bgpPeer);
|
||||
|
||||
BgpPeerResponse response = Mockito.mock(BgpPeerResponse.class);
|
||||
Mockito.when(routedIpv4Manager.createBgpPeerResponse(bgpPeer)).thenReturn(response);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(response, cmd.getResponseObject());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateBgpPeerCleanupDetails() {
|
||||
UpdateBgpPeerCmd cmd = new UpdateBgpPeerCmd();
|
||||
Assert.assertFalse(cmd.isCleanupDetails());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "cleanupDetails", Boolean.TRUE);
|
||||
Assert.assertTrue(cmd.isCleanupDetails());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "cleanupDetails", Boolean.FALSE);
|
||||
Assert.assertFalse(cmd.isCleanupDetails());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
// 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.vpc;
|
||||
|
||||
import com.cloud.network.vpc.VpcService;
|
||||
import com.cloud.user.AccountService;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CreateVPCCmdByAdminTest extends TestCase {
|
||||
|
||||
@Mock
|
||||
public VpcService _vpcService;
|
||||
@Mock
|
||||
public EntityManager _entityMgr;
|
||||
@Mock
|
||||
public AccountService _accountService;
|
||||
private ResponseGenerator responseGenerator;
|
||||
@InjectMocks
|
||||
CreateVPCCmdByAdmin cmd = new CreateVPCCmdByAdmin();
|
||||
|
||||
@Test
|
||||
public void testBgpPeerIds() {
|
||||
List<Long> bgpPeerIds = Mockito.mock(List.class);
|
||||
ReflectionTestUtils.setField(cmd, "bgpPeerIds", bgpPeerIds);
|
||||
Assert.assertEquals(bgpPeerIds, cmd.getBgpPeerIds());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
// 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.bgp.BGPService;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.response.ASNumberResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ListASNumbersCmdTest {
|
||||
|
||||
BGPService bgpService = Mockito.spy(BGPService.class);
|
||||
ResponseGenerator _responseGenerator = Mockito.spy(ResponseGenerator.class);
|
||||
|
||||
@Test
|
||||
public void testListASNumbersCmdTest() {
|
||||
Long zoneId = 1L;
|
||||
Long asNumberRangeId = 2L;
|
||||
Integer asNumber = 10;
|
||||
Long networkId = 11L;
|
||||
Long vpcId = 12L;
|
||||
String account = "account";
|
||||
Long domainId = 13L;
|
||||
|
||||
ListASNumbersCmd cmd = new ListASNumbersCmd();
|
||||
ReflectionTestUtils.setField(cmd, "zoneId", zoneId);
|
||||
ReflectionTestUtils.setField(cmd, "asNumberRangeId", asNumberRangeId);
|
||||
ReflectionTestUtils.setField(cmd, "asNumber", asNumber);
|
||||
ReflectionTestUtils.setField(cmd, "networkId", networkId);
|
||||
ReflectionTestUtils.setField(cmd, "vpcId", vpcId);
|
||||
ReflectionTestUtils.setField(cmd, "account", account);
|
||||
ReflectionTestUtils.setField(cmd, "domainId", domainId);
|
||||
ReflectionTestUtils.setField(cmd, "allocated", Boolean.TRUE);
|
||||
|
||||
ReflectionTestUtils.setField(cmd,"bgpService", bgpService);
|
||||
ReflectionTestUtils.setField(cmd,"_responseGenerator", _responseGenerator);
|
||||
|
||||
Assert.assertEquals(zoneId, cmd.getZoneId());
|
||||
Assert.assertEquals(asNumberRangeId, cmd.getAsNumberRangeId());
|
||||
Assert.assertEquals(asNumber, cmd.getAsNumber());
|
||||
Assert.assertEquals(networkId, cmd.getNetworkId());
|
||||
Assert.assertEquals(vpcId, cmd.getVpcId());
|
||||
Assert.assertEquals(account, cmd.getAccount());
|
||||
Assert.assertEquals(domainId, cmd.getDomainId());
|
||||
Assert.assertTrue(cmd.getAllocated());
|
||||
|
||||
List<ASNumber> asNumbers = new ArrayList<>();
|
||||
ASNumber asn = Mockito.mock(ASNumber.class);
|
||||
asNumbers.add(asn);
|
||||
Pair<List<ASNumber>, Integer> pair = new Pair<>(asNumbers, 1);
|
||||
|
||||
ASNumberResponse asNumberResponse = Mockito.mock(ASNumberResponse.class);
|
||||
Mockito.when(_responseGenerator.createASNumberResponse(asn)).thenReturn(asNumberResponse);
|
||||
|
||||
Mockito.when(bgpService.listASNumbers(cmd)).thenReturn(pair);
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Object response = cmd.getResponseObject();
|
||||
Assert.assertTrue(response instanceof ListResponse);
|
||||
ListResponse listResponse = (ListResponse) response;
|
||||
Assert.assertEquals(1L, (long) listResponse.getCount());
|
||||
Assert.assertTrue(listResponse.getResponses().get(0) instanceof ASNumberResponse);
|
||||
ASNumberResponse firstResponse = (ASNumberResponse) listResponse.getResponses().get(0);
|
||||
Assert.assertEquals(asNumberResponse, firstResponse);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,251 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.firewall.FirewallService;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
import org.apache.cloudstack.api.ApiCommandResourceType;
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.response.FirewallResponse;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CreateRoutingFirewallRuleCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
FirewallService _firewallService = Mockito.spy(FirewallService.class);
|
||||
|
||||
ResponseGenerator _responseGenerator = Mockito.spy(ResponseGenerator.class);
|
||||
|
||||
@Test
|
||||
public void testIsDisplay() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
assertTrue(cmd.isDisplay());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "display", Boolean.TRUE);
|
||||
assertTrue(cmd.isDisplay());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "display", Boolean.FALSE);
|
||||
assertFalse(cmd.isDisplay());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProtocolValid() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
assertEquals("", cmd.getProtocol());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "protocol", "1");
|
||||
assertEquals(NetUtils.ICMP_PROTO, cmd.getProtocol());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "protocol", "icmp");
|
||||
assertEquals(NetUtils.ICMP_PROTO, cmd.getProtocol());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "protocol", "6");
|
||||
assertEquals(NetUtils.TCP_PROTO, cmd.getProtocol());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "protocol", "tcp");
|
||||
assertEquals(NetUtils.TCP_PROTO, cmd.getProtocol());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "protocol", "17");
|
||||
assertEquals(NetUtils.UDP_PROTO, cmd.getProtocol());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "protocol", "udp");
|
||||
assertEquals(NetUtils.UDP_PROTO, cmd.getProtocol());
|
||||
}
|
||||
|
||||
@Test(expected = InvalidParameterValueException.class)
|
||||
public void testGetProtocolInValid() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "protocol", "100");
|
||||
cmd.getProtocol();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSourceCidrListNull() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
|
||||
List<String> result = cmd.getSourceCidrList();
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.size());
|
||||
assertEquals(NetUtils.ALL_IP4_CIDRS, result.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSourceCidrList() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
|
||||
List<String> cidrList = Arrays.asList("192.168.0.0/24", "10.0.0.0/8");
|
||||
cmd.sourceCidrList = cidrList;
|
||||
List<String> result = cmd.getSourceCidrList();
|
||||
assertNotNull(result);
|
||||
assertEquals(cidrList, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDestinationCidrListNull() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
|
||||
List<String> result = cmd.getDestinationCidrList();
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.size());
|
||||
assertEquals(NetUtils.ALL_IP4_CIDRS, result.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDestinationCidrList() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
|
||||
List<String> cidrList = Arrays.asList("192.168.0.0/24", "10.0.0.0/8");
|
||||
cmd.destinationCidrlist = cidrList;
|
||||
List<String> result = cmd.getDestinationCidrList();
|
||||
assertNotNull(result);
|
||||
assertEquals(cidrList, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTrafficTypeValid() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
assertEquals(FirewallRule.TrafficType.Ingress, cmd.getTrafficType());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "trafficType", "ingress");
|
||||
assertEquals(FirewallRule.TrafficType.Ingress, cmd.getTrafficType());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "trafficType", "egress");
|
||||
assertEquals(FirewallRule.TrafficType.Egress, cmd.getTrafficType());
|
||||
}
|
||||
|
||||
@Test(expected = InvalidParameterValueException.class)
|
||||
public void testGetTrafficTypeInValid() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "trafficType", "invalid");
|
||||
cmd.getTrafficType();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSourcePortStartEnd() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
assertNull(cmd.getSourcePortStart());
|
||||
assertNull(cmd.getSourcePortEnd());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "publicStartPort", 1111);
|
||||
assertEquals(1111, (int) cmd.getSourcePortStart());
|
||||
assertEquals(1111, (int) cmd.getSourcePortEnd());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "publicEndPort", 2222);
|
||||
assertEquals(1111, (int) cmd.getSourcePortStart());
|
||||
assertEquals(2222, (int) cmd.getSourcePortEnd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNetworkId() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "networkId", 1111L);
|
||||
assertEquals(1111L, (long) cmd.getNetworkId());
|
||||
|
||||
assertEquals(1111L, (long) cmd.getApiResourceId());
|
||||
assertEquals(ApiCommandResourceType.Network, cmd.getApiResourceType());
|
||||
assertEquals(EventTypes.EVENT_ROUTING_IPV4_FIREWALL_RULE_CREATE, cmd.getEventType());
|
||||
assertEquals("Creating ipv4 firewall rule for routed network", cmd.getEventDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIcmpCodeAndType() {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
ReflectionTestUtils.setField(cmd, "protocol", "tcp");
|
||||
assertNull(cmd.getIcmpType());
|
||||
assertNull(cmd.getIcmpCode());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "protocol", "icmp");
|
||||
assertEquals(-1, (int) cmd.getIcmpType());
|
||||
assertEquals(-1, (int) cmd.getIcmpCode());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "icmpType", 1111);
|
||||
ReflectionTestUtils.setField(cmd, "icmpCode", 2222);
|
||||
assertEquals(1111, (int) cmd.getIcmpType());
|
||||
assertEquals(2222, (int) cmd.getIcmpCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
ReflectionTestUtils.setField(cmd, "routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Long id = 1L;
|
||||
String uuid = "uuid";
|
||||
FirewallRule firewallRule = Mockito.spy(FirewallRule.class);
|
||||
Mockito.when(firewallRule.getId()).thenReturn(id);
|
||||
Mockito.when(firewallRule.getUuid()).thenReturn(uuid);
|
||||
Mockito.when(routedIpv4Manager.createRoutingFirewallRule(cmd)).thenReturn(firewallRule);
|
||||
|
||||
try {
|
||||
cmd.create();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
assertEquals(id, cmd.getEntityId());
|
||||
assertEquals(uuid, cmd.getEntityUuid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() throws Exception {
|
||||
CreateRoutingFirewallRuleCmd cmd = new CreateRoutingFirewallRuleCmd();
|
||||
ReflectionTestUtils.setField(cmd, "routedIpv4Manager", routedIpv4Manager);
|
||||
ReflectionTestUtils.setField(cmd, "_firewallService", _firewallService);
|
||||
ReflectionTestUtils.setField(cmd, "_responseGenerator", _responseGenerator);
|
||||
|
||||
Long id = 1L;
|
||||
FirewallRule firewallRule = Mockito.spy(FirewallRule.class);
|
||||
Mockito.when(firewallRule.getId()).thenReturn(id);
|
||||
Mockito.when(_firewallService.getFirewallRule(id)).thenReturn(firewallRule);
|
||||
Mockito.when(routedIpv4Manager.applyRoutingFirewallRule(id)).thenReturn(true);
|
||||
|
||||
FirewallResponse ruleResponse = Mockito.mock(FirewallResponse.class);
|
||||
Mockito.when(_responseGenerator.createFirewallResponse(firewallRule)).thenReturn(ruleResponse);
|
||||
|
||||
try {
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(ruleResponse, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -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.network.routing;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.firewall.FirewallService;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
|
||||
import org.apache.cloudstack.api.ApiCommandResourceType;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DeleteRoutingFirewallRuleCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
FirewallService _firewallService = Mockito.spy(FirewallService.class);
|
||||
|
||||
@Test
|
||||
public void testProperties() {
|
||||
DeleteRoutingFirewallRuleCmd cmd = new DeleteRoutingFirewallRuleCmd();
|
||||
ReflectionTestUtils.setField(cmd, "_firewallService", _firewallService);
|
||||
|
||||
long id = 1L;
|
||||
long accountId = 2L;
|
||||
long networkId = 3L;
|
||||
|
||||
FirewallRule firewallRule = Mockito.spy(FirewallRule.class);
|
||||
Mockito.when(firewallRule.getAccountId()).thenReturn(accountId);
|
||||
Mockito.when(firewallRule.getNetworkId()).thenReturn(networkId);
|
||||
Mockito.when(_firewallService.getFirewallRule(id)).thenReturn(firewallRule);
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
assertEquals(id, (long) cmd.getId());
|
||||
assertEquals(accountId, cmd.getEntityOwnerId());
|
||||
assertEquals(networkId, (long) cmd.getApiResourceId());
|
||||
assertEquals(ApiCommandResourceType.Network, cmd.getApiResourceType());
|
||||
assertEquals(EventTypes.EVENT_ROUTING_IPV4_FIREWALL_RULE_DELETE, cmd.getEventType());
|
||||
assertEquals(String.format("Deleting ipv4 routing firewall rule ID=%s", id), cmd.getEventDescription());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExecute() throws Exception {
|
||||
DeleteRoutingFirewallRuleCmd cmd = new DeleteRoutingFirewallRuleCmd();
|
||||
ReflectionTestUtils.setField(cmd, "routedIpv4Manager", routedIpv4Manager);
|
||||
|
||||
Long id = 1L;
|
||||
Mockito.when(routedIpv4Manager.revokeRoutingFirewallRule(id)).thenReturn(true);
|
||||
|
||||
try {
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertTrue(cmd.getResponseObject() instanceof SuccessResponse);
|
||||
}
|
||||
}
|
||||
@ -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 com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.response.FirewallResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ListRoutingFirewallRulesCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
ResponseGenerator _responseGenerator = Mockito.spy(ResponseGenerator.class);
|
||||
|
||||
@Test
|
||||
public void testIsDisplay() {
|
||||
ListRoutingFirewallRulesCmd cmd = new ListRoutingFirewallRulesCmd();
|
||||
assertTrue(cmd.getDisplay());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "display", Boolean.TRUE);
|
||||
assertTrue(cmd.getDisplay());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "display", Boolean.FALSE);
|
||||
assertFalse(cmd.getDisplay());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrafficType() {
|
||||
ListRoutingFirewallRulesCmd cmd = new ListRoutingFirewallRulesCmd();
|
||||
assertNull(cmd.getTrafficType());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "trafficType", "Ingress");
|
||||
assertEquals(FirewallRule.TrafficType.Ingress, cmd.getTrafficType());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "trafficType", "Egress");
|
||||
assertEquals(FirewallRule.TrafficType.Egress, cmd.getTrafficType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOtherProperties() {
|
||||
ListRoutingFirewallRulesCmd cmd = new ListRoutingFirewallRulesCmd();
|
||||
|
||||
long id = 1L;
|
||||
long networkId = 3L;
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
ReflectionTestUtils.setField(cmd, "networkId", networkId);
|
||||
|
||||
assertEquals(id, (long) cmd.getId());
|
||||
assertEquals(networkId, (long) cmd.getNetworkId());
|
||||
assertNull(cmd.getIpAddressId());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExecute() throws Exception {
|
||||
ListRoutingFirewallRulesCmd cmd = new ListRoutingFirewallRulesCmd();
|
||||
ReflectionTestUtils.setField(cmd, "routedIpv4Manager", routedIpv4Manager);
|
||||
ReflectionTestUtils.setField(cmd, "_responseGenerator", _responseGenerator);
|
||||
|
||||
Long id = 1L;
|
||||
FirewallRule firewallRule = Mockito.spy(FirewallRule.class);
|
||||
List<FirewallRule> firewallRules = Arrays.asList(firewallRule);
|
||||
Pair<List<? extends FirewallRule>, Integer> result = new Pair<>(firewallRules, 1);
|
||||
|
||||
Mockito.when(routedIpv4Manager.listRoutingFirewallRules(cmd)).thenReturn(result);
|
||||
|
||||
FirewallResponse ruleResponse = Mockito.mock(FirewallResponse.class);
|
||||
Mockito.when(_responseGenerator.createFirewallResponse(firewallRule)).thenReturn(ruleResponse);
|
||||
|
||||
try {
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertTrue(cmd.getResponseObject() instanceof ListResponse);
|
||||
ListResponse listResponse = (ListResponse) cmd.getResponseObject();
|
||||
Assert.assertEquals(1, (int) listResponse.getCount());
|
||||
Assert.assertEquals(ruleResponse, listResponse.getResponses().get(0));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
// 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 com.cloud.event.EventTypes;
|
||||
import com.cloud.network.firewall.FirewallService;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
|
||||
import org.apache.cloudstack.api.ApiCommandResourceType;
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.response.FirewallResponse;
|
||||
import org.apache.cloudstack.network.RoutedIpv4Manager;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class UpdateRoutingFirewallRuleCmdTest {
|
||||
|
||||
RoutedIpv4Manager routedIpv4Manager = Mockito.spy(RoutedIpv4Manager.class);
|
||||
|
||||
FirewallService _firewallService = Mockito.spy(FirewallService.class);
|
||||
|
||||
ResponseGenerator _responseGenerator = Mockito.spy(ResponseGenerator.class);
|
||||
|
||||
@Test
|
||||
public void testIsDisplay() {
|
||||
UpdateRoutingFirewallRuleCmd cmd = new UpdateRoutingFirewallRuleCmd();
|
||||
assertTrue(cmd.isDisplay());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "display", Boolean.TRUE);
|
||||
assertTrue(cmd.isDisplay());
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "display", Boolean.FALSE);
|
||||
assertFalse(cmd.isDisplay());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOtherProperties() {
|
||||
UpdateRoutingFirewallRuleCmd cmd = new UpdateRoutingFirewallRuleCmd();
|
||||
ReflectionTestUtils.setField(cmd, "_firewallService", _firewallService);
|
||||
|
||||
long id = 1L;
|
||||
long accountId = 2L;
|
||||
long networkId = 3L;
|
||||
|
||||
FirewallRule firewallRule = Mockito.spy(FirewallRule.class);
|
||||
Mockito.when(firewallRule.getAccountId()).thenReturn(accountId);
|
||||
Mockito.when(firewallRule.getNetworkId()).thenReturn(networkId);
|
||||
Mockito.when(_firewallService.getFirewallRule(id)).thenReturn(firewallRule);
|
||||
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
assertEquals(id, (long) cmd.getId());
|
||||
assertEquals(accountId, cmd.getEntityOwnerId());
|
||||
assertEquals(networkId, (long) cmd.getApiResourceId());
|
||||
assertEquals(ApiCommandResourceType.Network, cmd.getApiResourceType());
|
||||
assertEquals(EventTypes.EVENT_ROUTING_IPV4_FIREWALL_RULE_UPDATE, cmd.getEventType());
|
||||
assertEquals("Updating ipv4 routing firewall rule", cmd.getEventDescription());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExecute() throws Exception {
|
||||
UpdateRoutingFirewallRuleCmd cmd = new UpdateRoutingFirewallRuleCmd();
|
||||
ReflectionTestUtils.setField(cmd, "routedIpv4Manager", routedIpv4Manager);
|
||||
ReflectionTestUtils.setField(cmd, "_firewallService", _firewallService);
|
||||
ReflectionTestUtils.setField(cmd, "_responseGenerator", _responseGenerator);
|
||||
|
||||
Long id = 1L;
|
||||
FirewallRule firewallRule = Mockito.spy(FirewallRule.class);
|
||||
Mockito.when(routedIpv4Manager.updateRoutingFirewallRule(cmd)).thenReturn(firewallRule);
|
||||
|
||||
FirewallResponse ruleResponse = Mockito.mock(FirewallResponse.class);
|
||||
Mockito.when(_responseGenerator.createFirewallResponse(firewallRule)).thenReturn(ruleResponse);
|
||||
|
||||
try {
|
||||
ReflectionTestUtils.setField(cmd, "id", id);
|
||||
cmd.execute();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Assert.assertEquals(ruleResponse, cmd.getResponseObject());
|
||||
}
|
||||
}
|
||||
@ -86,6 +86,20 @@ public class CreateVPCCmdTest extends TestCase {
|
||||
Assert.assertEquals(cmd.getCidr(), cidr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCidrSize() {
|
||||
int cidrSize = 24;
|
||||
ReflectionTestUtils.setField(cmd, "cidrSize", cidrSize);
|
||||
Assert.assertEquals(cidrSize, (int) cmd.getCidrSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsNumber() {
|
||||
long asNumber = 10000;
|
||||
ReflectionTestUtils.setField(cmd, "asNumber", asNumber);
|
||||
Assert.assertEquals(asNumber, (long) cmd.getAsNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDisplayText() {
|
||||
String displayText = "VPC Network";
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
// 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.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public final class ASNRangeResponseTest {
|
||||
|
||||
private static String uuid = "uuid";
|
||||
private static String zoneId = "zoneid";
|
||||
private static long startASNumber = 10;
|
||||
private static long endASNumber = 20;
|
||||
private static Date created = new Date();
|
||||
|
||||
@Test
|
||||
public void testASNRangeResponse() {
|
||||
final ASNRangeResponse response = new ASNRangeResponse();
|
||||
|
||||
response.setId(uuid);
|
||||
response.setZoneId(zoneId);
|
||||
response.setStartASNumber(startASNumber);
|
||||
response.setEndASNumber(endASNumber);
|
||||
response.setCreated(created);
|
||||
|
||||
Assert.assertEquals(uuid, response.getId());
|
||||
Assert.assertEquals(zoneId, response.getZoneId());
|
||||
Assert.assertEquals(startASNumber, (long) response.getStartASNumber());
|
||||
Assert.assertEquals(endASNumber, (long) response.getEndASNumber());
|
||||
Assert.assertEquals(created, response.getCreated());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
// 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.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public final class ASNumberResponseTest {
|
||||
|
||||
private static String uuid = "uuid";
|
||||
private static String accountId = "account-id";
|
||||
private static String accountName = "account-name";
|
||||
private static String domainId = "domain-uuid";
|
||||
private static String domainName = "domain-name";
|
||||
private static Long asNumber = 15000L;
|
||||
private static String asNumberRangeId = "as-number-range-uuid";
|
||||
private static String asNumberRange = "10000-20000";
|
||||
private static String zoneId = "zone-id";
|
||||
private static String zoneName = "zone-name";
|
||||
private static Date allocated = new Date();
|
||||
private static String allocationState = "allocated";
|
||||
|
||||
private static String associatedNetworkId = "network-id";
|
||||
|
||||
private static String associatedNetworkName = "network-name";
|
||||
|
||||
private static String vpcId = "vpc-uuid";
|
||||
private static String vpcName = "vpc-name";
|
||||
private static Date created = new Date();
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testASNumberResponse() {
|
||||
final ASNumberResponse response = new ASNumberResponse();
|
||||
|
||||
response.setId(uuid);
|
||||
response.setAccountId(accountId);
|
||||
response.setAccountName(accountName);
|
||||
response.setDomainId(domainId);
|
||||
response.setDomainName(domainName);
|
||||
response.setAsNumber(asNumber);
|
||||
response.setAsNumberRangeId(asNumberRangeId);
|
||||
response.setAsNumberRange(asNumberRange);
|
||||
response.setZoneId(zoneId);
|
||||
response.setZoneName(zoneName);
|
||||
response.setAllocated(allocated);
|
||||
response.setAllocationState(allocationState);
|
||||
response.setAssociatedNetworkId(associatedNetworkId);
|
||||
response.setAssociatedNetworkName(associatedNetworkName);
|
||||
response.setVpcId(vpcId);
|
||||
response.setVpcName(vpcName);
|
||||
response.setCreated(created);
|
||||
|
||||
Assert.assertEquals(uuid, response.getId());
|
||||
Assert.assertEquals(accountId, response.getAccountId());
|
||||
Assert.assertEquals(accountName, response.getAccountName());
|
||||
Assert.assertEquals(domainId, response.getDomainId());
|
||||
Assert.assertEquals(domainName, response.getDomainName());
|
||||
Assert.assertEquals(asNumber, response.getAsNumber());
|
||||
Assert.assertEquals(asNumberRangeId, response.getAsNumberRangeId());
|
||||
Assert.assertEquals(asNumberRange, response.getAsNumberRange());
|
||||
Assert.assertEquals(zoneId, response.getZoneId());
|
||||
Assert.assertEquals(zoneName, response.getZoneName());
|
||||
Assert.assertEquals(allocated, response.getAllocated());
|
||||
Assert.assertEquals(allocationState, response.getAllocationState());
|
||||
Assert.assertEquals(associatedNetworkId, response.getAssociatedNetworkId());
|
||||
Assert.assertEquals(associatedNetworkName, response.getAssociatedNetworkName());
|
||||
Assert.assertEquals(vpcId, response.getVpcId());
|
||||
Assert.assertEquals(vpcName, response.getVpcName());
|
||||
Assert.assertEquals(created, response.getCreated());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
// 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.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public final class BgpPeerResponseTest {
|
||||
|
||||
private static String uuid = "uuid";
|
||||
private static String ip4Address = "ip4-address";
|
||||
private static String ip6Address = "ip6-address";
|
||||
private static Long asNumber = 15000L;
|
||||
private static String password = "password";
|
||||
private static String accountName = "account-name";
|
||||
private static String domainId = "domain-uuid";
|
||||
private static String domainName = "domain-name";
|
||||
private static String projectId = "project-uuid";
|
||||
private static String projectName = "project-name";
|
||||
private static String zoneId = "zone-id";
|
||||
private static String zoneName = "zone-name";
|
||||
private static Date created = new Date();
|
||||
|
||||
@Test
|
||||
public void testBgpPeerResponse() {
|
||||
final BgpPeerResponse response = new BgpPeerResponse();
|
||||
|
||||
response.setId(uuid);
|
||||
response.setIp4Address(ip4Address);
|
||||
response.setIp6Address(ip6Address);
|
||||
response.setAsNumber(asNumber);
|
||||
response.setPassword(password);
|
||||
response.setAccountName(accountName);
|
||||
response.setDomainId(domainId);
|
||||
response.setDomainName(domainName);
|
||||
response.setProjectId(projectId);
|
||||
response.setProjectName(projectName);
|
||||
response.setZoneId(zoneId);
|
||||
response.setZoneName(zoneName);
|
||||
response.setCreated(created);
|
||||
Map<String, String> details = new HashMap<>();
|
||||
details.put("key", "value");
|
||||
response.setDetails(details);
|
||||
|
||||
Assert.assertEquals(uuid, response.getId());
|
||||
Assert.assertEquals(ip4Address, response.getIp4Address());
|
||||
Assert.assertEquals(ip6Address, response.getIp6Address());
|
||||
Assert.assertEquals(asNumber, response.getAsNumber());
|
||||
Assert.assertEquals(password, response.getPassword());
|
||||
Assert.assertEquals(accountName, response.getAccountName());
|
||||
Assert.assertEquals(domainId, response.getDomainId());
|
||||
Assert.assertEquals(domainName, response.getDomainName());
|
||||
Assert.assertEquals(projectId, response.getProjectId());
|
||||
Assert.assertEquals(projectName, response.getProjectName());
|
||||
Assert.assertEquals(zoneId, response.getZoneId());
|
||||
Assert.assertEquals(zoneName, response.getZoneName());
|
||||
Assert.assertEquals(created, response.getCreated());
|
||||
Assert.assertEquals(details, response.getDetails());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
// 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.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public final class DataCenterIpv4SubnetResponseTest {
|
||||
|
||||
private static String uuid = "uuid";
|
||||
private static String subnet = "10.10.10.0/26";
|
||||
private static String accountName = "account-name";
|
||||
private static String domainId = "domain-uuid";
|
||||
private static String domainName = "domain-name";
|
||||
private static String projectId = "project-uuid";
|
||||
private static String projectName = "project-name";
|
||||
private static String zoneId = "zone-id";
|
||||
private static String zoneName = "zone-name";
|
||||
private static Date created = new Date();
|
||||
|
||||
@Test
|
||||
public void testDataCenterIpv4SubnetResponse() {
|
||||
final DataCenterIpv4SubnetResponse response = new DataCenterIpv4SubnetResponse();
|
||||
|
||||
response.setId(uuid);
|
||||
response.setSubnet(subnet);
|
||||
response.setAccountName(accountName);
|
||||
response.setDomainId(domainId);
|
||||
response.setDomainName(domainName);
|
||||
response.setProjectId(projectId);
|
||||
response.setProjectName(projectName);
|
||||
response.setZoneId(zoneId);
|
||||
response.setZoneName(zoneName);
|
||||
response.setCreated(created);
|
||||
|
||||
Assert.assertEquals(uuid, response.getId());
|
||||
Assert.assertEquals(subnet, response.getSubnet());
|
||||
Assert.assertEquals(accountName, response.getAccountName());
|
||||
Assert.assertEquals(domainId, response.getDomainId());
|
||||
Assert.assertEquals(domainName, response.getDomainName());
|
||||
Assert.assertEquals(projectId, response.getProjectId());
|
||||
Assert.assertEquals(projectName, response.getProjectName());
|
||||
Assert.assertEquals(zoneId, response.getZoneId());
|
||||
Assert.assertEquals(zoneName, response.getZoneName());
|
||||
Assert.assertEquals(created, response.getCreated());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
// 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.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public final class Ipv4RouteResponseTest {
|
||||
|
||||
private static String subnet = "10.10.10.0/24";
|
||||
private static String gateway = "10.10.10.1";
|
||||
|
||||
@Test
|
||||
public void testIpv4RouteResponse() {
|
||||
final Ipv4RouteResponse response = new Ipv4RouteResponse(subnet, gateway);
|
||||
|
||||
Assert.assertEquals(subnet, response.getSubnet());
|
||||
Assert.assertEquals(gateway, response.getGateway());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIpv4RouteResponse2() {
|
||||
final Ipv4RouteResponse response = new Ipv4RouteResponse();
|
||||
|
||||
response.setSubnet(subnet);
|
||||
response.setGateway(gateway);
|
||||
|
||||
Assert.assertEquals(subnet, response.getSubnet());
|
||||
Assert.assertEquals(gateway, response.getGateway());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
// 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.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public final class Ipv4SubnetForGuestNetworkResponseTest {
|
||||
|
||||
private static String uuid = "uuid";
|
||||
private static String parentId = "parent-id";
|
||||
private static String parentSubnet = "10.10.0.0/20";
|
||||
private static String subnet = "10.10.0.0/24";
|
||||
private static String state = "Allocating";
|
||||
|
||||
private static String zoneId = "zone-id";
|
||||
private static String zoneName = "zone-name";
|
||||
private static Date allocated = new Date();
|
||||
private static String networkId = "network-id";
|
||||
private static String networkName = "network-name";
|
||||
private static String vpcId = "vpc-uuid";
|
||||
private static String vpcName = "vpc-name";
|
||||
private static Date created = new Date();
|
||||
private static Date removed = new Date();
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testIpv4SubnetForGuestNetworkResponse() {
|
||||
final Ipv4SubnetForGuestNetworkResponse response = new Ipv4SubnetForGuestNetworkResponse();
|
||||
|
||||
response.setId(uuid);
|
||||
response.setSubnet(subnet);
|
||||
response.setParentId(parentId);
|
||||
response.setParentSubnet(parentSubnet);
|
||||
response.setState(state);
|
||||
response.setZoneId(zoneId);
|
||||
response.setZoneName(zoneName);
|
||||
response.setAllocatedTime(allocated);
|
||||
response.setNetworkId(networkId);
|
||||
response.setNetworkName(networkName);
|
||||
response.setVpcId(vpcId);
|
||||
response.setVpcName(vpcName);
|
||||
response.setCreated(created);
|
||||
response.setRemoved(removed);
|
||||
|
||||
Assert.assertEquals(uuid, response.getId());
|
||||
Assert.assertEquals(subnet, response.getSubnet());
|
||||
Assert.assertEquals(parentId, response.getParentId());
|
||||
Assert.assertEquals(parentSubnet, response.getParentSubnet());
|
||||
Assert.assertEquals(state, response.getState());
|
||||
Assert.assertEquals(zoneId, response.getZoneId());
|
||||
Assert.assertEquals(zoneName, response.getZoneName());
|
||||
Assert.assertEquals(allocated, response.getAllocatedTime());
|
||||
Assert.assertEquals(networkId, response.getNetworkId());
|
||||
Assert.assertEquals(networkName, response.getNetworkName());
|
||||
Assert.assertEquals(vpcId, response.getVpcId());
|
||||
Assert.assertEquals(vpcName, response.getVpcName());
|
||||
Assert.assertEquals(created, response.getCreated());
|
||||
Assert.assertEquals(removed, response.getRemoved());
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user