Skip to content

Commit 842e083

Browse files
OSPF: WIP: adding dynamically routing capability to VPC
1 parent e5f0788 commit 842e083

File tree

45 files changed

+1093
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1093
-252
lines changed

api/src/com/cloud/network/Network.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public static class Service {
5959
public static final Service SecurityGroup = new Service("SecurityGroup");
6060
public static final Service NetworkACL = new Service("NetworkACL", Capability.SupportedProtocols);
6161
public static final Service Connectivity = new Service("Connectivity", Capability.DistributedRouter, Capability.RegionLevelVpc, Capability.StretchedL2Subnet);
62+
public static final Service VPCDynamicRouting = new Service("VPCDynamicRouting");
6263

6364
private final String name;
6465
private final Capability[] caps;
@@ -124,6 +125,7 @@ public static class Provider {
124125
public static final Provider ElasticLoadBalancerVm = new Provider("ElasticLoadBalancerVm", false);
125126
public static final Provider SecurityGroupProvider = new Provider("SecurityGroupProvider", false);
126127
public static final Provider VPCVirtualRouter = new Provider("VpcVirtualRouter", false);
128+
public static final Provider VPCDynamicRouting = new Provider("VPCDynamicRouting", false);
127129
public static final Provider None = new Provider("None", false);
128130
// NiciraNvp is not an "External" provider, otherwise we get in trouble with NetworkServiceImpl.providersConfiguredForExternalNetworking
129131
public static final Provider NiciraNvp = new Provider("NiciraNvp", false);
@@ -213,6 +215,7 @@ public static class Capability {
213215
public static final Capability DistributedRouter = new Capability("DistributedRouter");
214216
public static final Capability StretchedL2Subnet = new Capability("StretchedL2Subnet");
215217
public static final Capability RegionLevelVpc = new Capability("RegionLevelVpc");
218+
public static final Capability DynamicallyRoutedVpc = new Capability("DynamicallyRoutedVpc");
216219

217220
private final String name;
218221

api/src/com/cloud/network/vpc/Vpc.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,10 @@ public enum State {
8787
* @return true if VPC spans multiple zones in the region
8888
*/
8989
boolean isRegionLevelVpc();
90+
91+
/**
92+
*
93+
* @return true if VPC is dynamically routed using ospf
94+
*/
95+
boolean isDynamicallyRouted();
9096
}

api/src/com/cloud/network/vpc/VpcOffering.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public enum State {
2727
public static final String defaultVPCOfferingName = "Default VPC offering";
2828
public static final String defaultVPCNSOfferingName = "Default VPC offering with Netscaler";
2929
public static final String redundantVPCOfferingName = "Redundant VPC offering";
30+
public static final String routedVPCOfferingName = "Default Dynamically Routed VPC offering";
3031

3132
/**
3233
*

api/src/com/cloud/network/vpc/VpcProvisioningService.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
// under the License.
1717
package com.cloud.network.vpc;
1818

19-
2019
import java.util.List;
2120
import java.util.Map;
2221

@@ -26,13 +25,11 @@ public interface VpcProvisioningService {
2625

2726
public VpcOffering getVpcOffering(long vpcOfferingId);
2827

29-
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices,
30-
Map<String, List<String>> serviceProviders,
31-
Map serviceCapabilitystList,
32-
Long serviceOfferingId);
28+
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices, Map<String, List<String>> serviceProviders, Map serviceCapabilitystList,
29+
Long serviceOfferingId);
3330

34-
Pair<List<? extends VpcOffering>,Integer> listVpcOfferings(Long id, String name, String displayText, List<String> supportedServicesStr, Boolean isDefault, String keyword,
35-
String state, Long startIndex, Long pageSizeVal);
31+
Pair<List<? extends VpcOffering>, Integer> listVpcOfferings(Long id, String name, String displayText, List<String> supportedServicesStr, Boolean isDefault, String keyword,
32+
String state, Long startIndex, Long pageSizeVal);
3633

3734
/**
3835
* @param offId
@@ -49,4 +46,6 @@ Pair<List<? extends VpcOffering>,Integer> listVpcOfferings(Long id, String name,
4946
*/
5047
public VpcOffering updateVpcOffering(long vpcOffId, String vpcOfferingName, String displayText, String state);
5148

49+
void quaggaConfig(Long id, String password, String superCIDR, Boolean enabled);
50+
5251
}

api/src/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ public class ApiConstants {
622622
public static final String MAXCAPACITY = "maxcapacity";
623623
public static final String DISTRIBUTED_VPC_ROUTER = "distributedvpcrouter";
624624
public static final String REDUNDANT_VPC_ROUTER = "redundantvpcrouter";
625+
public static final String DYNAMICALLY_ROUTED_VPC_ROUTER = "dynamicallyroutedvpcrouter";
625626
public static final String READ_ONLY = "readonly";
626627
public static final String SUPPORTS_REGION_LEVEL_VPC = "supportsregionLevelvpc";
627628
public static final String SUPPORTS_STRECHED_L2_SUBNET = "supportsstrechedl2subnet";
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.api.command.admin.vpc;
19+
20+
import javax.inject.Inject;
21+
22+
import org.apache.cloudstack.api.APICommand;
23+
import org.apache.cloudstack.api.ApiConstants;
24+
import org.apache.cloudstack.api.BaseCmd;
25+
import org.apache.cloudstack.api.Parameter;
26+
import org.apache.cloudstack.api.response.VPCQuaggaConfigResponse;
27+
import org.apache.cloudstack.api.response.ZoneResponse;
28+
import org.apache.log4j.Logger;
29+
30+
import com.cloud.network.vpc.VpcProvisioningService;
31+
import com.cloud.user.Account;
32+
33+
@APICommand(name = "vpcQuaggaConfigCmd", description = "Captures config informaton for quagga", responseObject = VPCQuaggaConfigResponse.class, since = "4.8.0", requestHasSensitiveInfo = true, responseHasSensitiveInfo = false)
34+
public class VPCQuaggaConfigCmd extends BaseCmd {
35+
public static final Logger s_logger = Logger.getLogger(VPCQuaggaConfigCmd.class.getName());
36+
private static final String s_name = "vpcquaggaconfigresponse";
37+
38+
/////////////////////////////////////////////////////
39+
//////////////// API parameters /////////////////////
40+
/////////////////////////////////////////////////////
41+
42+
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, required = true, description = "the ID of the Zone")
43+
private Long zoneid;
44+
45+
@Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "the password used to secure inter quagga communication")
46+
private String password;
47+
48+
@Parameter(name = ApiConstants.CIDR, type = CommandType.STRING, required = true, description = "the super zone level CIDR for ospf enabled VPCs")
49+
private String cidr;
50+
51+
@Parameter(name = ApiConstants.ENABLED, type = CommandType.BOOLEAN, required = true, description = "flag to enable or disable quagga for this zone")
52+
private Boolean enabled;
53+
54+
@Inject
55+
public VpcProvisioningService _vpcProvSvc;
56+
57+
public Long getId() {
58+
return zoneid;
59+
}
60+
61+
public Boolean getQuaggaEnabled() {
62+
return enabled;
63+
}
64+
65+
public void setQuaggaEnabled(Boolean quaggaEnabled) {
66+
this.enabled = quaggaEnabled;
67+
}
68+
69+
public String getQuaggaPassword() {
70+
return password;
71+
}
72+
73+
public void setQuaggaPassword(String quaggaPassword) {
74+
this.password = quaggaPassword;
75+
}
76+
77+
public String getSuperCIDR() {
78+
return cidr;
79+
}
80+
81+
public void setSuperCIDR(String superCIDR) {
82+
this.cidr = superCIDR;
83+
}
84+
85+
@Override
86+
public void execute() {
87+
_vpcProvSvc.quaggaConfig(getId(), getQuaggaPassword(), getSuperCIDR(), getQuaggaEnabled());
88+
VPCQuaggaConfigResponse response = new VPCQuaggaConfigResponse();
89+
response.setResult(true);
90+
response.setResponseName(getCommandName());
91+
response.setObjectName("quaggaconfig");
92+
setResponseObject(response);
93+
}
94+
95+
@Override
96+
public String getCommandName() {
97+
return s_name;
98+
}
99+
100+
@Override
101+
public long getEntityOwnerId() {
102+
return Account.ACCOUNT_ID_SYSTEM;
103+
}
104+
105+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.api.response;
19+
20+
import org.apache.cloudstack.api.BaseResponse;
21+
import com.cloud.serializer.Param;
22+
import com.google.gson.annotations.SerializedName;
23+
24+
public class VPCQuaggaConfigResponse extends BaseResponse {
25+
26+
@SerializedName("result")
27+
@Param(description = "result of configuring zone level parameters for quagga")
28+
private Boolean result;
29+
30+
31+
public Boolean getResult() {
32+
return result;
33+
}
34+
35+
36+
public void setResult(Boolean result) {
37+
this.result = result;
38+
}
39+
40+
41+
public VPCQuaggaConfigResponse() {
42+
super();
43+
}
44+
45+
}

api/src/org/apache/cloudstack/api/response/VpcResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
123123
@Param(description = "if this VPC has redundant router", since = "4.6")
124124
private boolean redundantRouter;
125125

126+
@SerializedName(ApiConstants.DYNAMICALLY_ROUTED_VPC_ROUTER)
127+
@Param(description = "if this VPC is dynamically routed router", since = "4.8")
128+
private boolean dynamicallyRoutedRouter;
129+
130+
public boolean isDynamicallyRoutedRouter() {
131+
return dynamicallyRoutedRouter;
132+
}
133+
134+
public void setDynamicallyRoutedRouter(boolean dynamicallyRoutedRouter) {
135+
this.dynamicallyRoutedRouter = dynamicallyRoutedRouter;
136+
}
137+
126138
public void setId(final String id) {
127139
this.id = id;
128140
}

api/src/org/apache/cloudstack/usage/UsageTypes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class UsageTypes {
4242
public static final int VM_DISK_BYTES_READ = 23;
4343
public static final int VM_DISK_BYTES_WRITE = 24;
4444
public static final int VM_SNAPSHOT = 25;
45+
public static final int DYNAMIC_ROUTING_POLICY = 16;
4546

4647
public static List<UsageTypeResponse> listUsageTypes() {
4748
List<UsageTypeResponse> responseList = new ArrayList<UsageTypeResponse>();
@@ -56,6 +57,7 @@ public static List<UsageTypeResponse> listUsageTypes() {
5657
responseList.add(new UsageTypeResponse(SNAPSHOT, "Snapshot Usage"));
5758
responseList.add(new UsageTypeResponse(SECURITY_GROUP, "Security Group Usage"));
5859
responseList.add(new UsageTypeResponse(LOAD_BALANCER_POLICY, "Load Balancer Usage"));
60+
responseList.add(new UsageTypeResponse(DYNAMIC_ROUTING_POLICY, "Load Balancer Usage"));
5961
responseList.add(new UsageTypeResponse(PORT_FORWARDING_RULE, "Port Forwarding Usage"));
6062
responseList.add(new UsageTypeResponse(NETWORK_OFFERING, "Network Offering Usage"));
6163
responseList.add(new UsageTypeResponse(VPN_USERS, "VPN users usage"));
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.api.command.admin.vpc;
19+
20+
import java.lang.reflect.Field;
21+
22+
import org.apache.cloudstack.api.ApiConstants;
23+
import org.apache.cloudstack.context.CallContext;
24+
import org.junit.After;
25+
import org.junit.Before;
26+
import org.junit.Test;
27+
import org.junit.runner.RunWith;
28+
import org.mockito.InjectMocks;
29+
import org.mockito.Mock;
30+
import org.mockito.Mockito;
31+
import org.mockito.MockitoAnnotations;
32+
import org.mockito.runners.MockitoJUnitRunner;
33+
import org.springframework.test.util.ReflectionTestUtils;
34+
35+
import com.cloud.network.vpc.VpcProvisioningService;
36+
import junit.framework.TestCase;
37+
38+
@RunWith(MockitoJUnitRunner.class)
39+
public class VPCQuaggaConfigCmdTest extends TestCase {
40+
41+
@Mock
42+
public VpcProvisioningService vpcProvSvc;
43+
44+
@InjectMocks
45+
VPCQuaggaConfigCmd vpcQuaggaConfig = new VPCQuaggaConfigCmd();
46+
47+
@Before
48+
public void setUp() throws Exception {
49+
MockitoAnnotations.initMocks(this);
50+
Field f = VPCQuaggaConfigCmd.class.getDeclaredField("_vpcProvSvc");
51+
f.setAccessible(true);
52+
f.set(vpcQuaggaConfig, vpcProvSvc);
53+
}
54+
55+
@After
56+
public void tearDown() throws Exception {
57+
CallContext.unregister();
58+
}
59+
60+
@Test
61+
public void testInvocation() throws IllegalArgumentException, IllegalAccessException {
62+
ReflectionTestUtils.setField(vpcQuaggaConfig, ApiConstants.ZONE_ID, 1L);
63+
ReflectionTestUtils.setField(vpcQuaggaConfig, ApiConstants.PASSWORD, "sfkjsdkk123");
64+
ReflectionTestUtils.setField(vpcQuaggaConfig, ApiConstants.CIDR, "192.168.100.0/20");
65+
ReflectionTestUtils.setField(vpcQuaggaConfig, ApiConstants.ENABLED, true);
66+
67+
vpcQuaggaConfig.execute();
68+
Mockito.verify(vpcProvSvc, Mockito.times(1)).quaggaConfig(1L, "sfkjsdkk123", "192.168.100.0/20", true);
69+
}
70+
71+
}

0 commit comments

Comments
 (0)