Skip to content

Commit 19a1116

Browse files
author
Anthony Xu
committed
Merge branch '4-2-advanced-zone-security-group'
2 parents cfd8056 + b0a9ade commit 19a1116

17 files changed

Lines changed: 1512 additions & 54 deletions

File tree

server/src/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,13 +1787,11 @@ public DataCenter editZone(UpdateZoneCmd cmd) {
17871787
// check if zone has necessary trafficTypes before enabling
17881788
try {
17891789
PhysicalNetwork mgmtPhyNetwork;
1790-
if (NetworkType.Advanced == zone.getNetworkType()) {
1791-
// zone should have a physical network with public and management traffiType
1790+
// zone should have a physical network with management traffiType
1791+
mgmtPhyNetwork = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
1792+
if (NetworkType.Advanced == zone.getNetworkType() && ! zone.isSecurityGroupEnabled() ) {
1793+
// advanced zone without SG should have a physical network with public Thpe
17921794
_networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public);
1793-
mgmtPhyNetwork = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
1794-
} else {
1795-
// zone should have a physical network with management traffiType
1796-
mgmtPhyNetwork = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
17971795
}
17981796

17991797
try {

server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -687,19 +687,28 @@ protected Map<String, Object> createProxyInstance(long dataCenterId, HypervisorT
687687

688688
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
689689

690-
TrafficType defaultTrafficType = TrafficType.Public;
691-
if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) {
692-
defaultTrafficType = TrafficType.Guest;
693-
}
694-
695-
List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType);
690+
NetworkVO defaultNetwork = null;
691+
if (dc.getNetworkType() == NetworkType.Advanced && dc.isSecurityGroupEnabled()) {
692+
List<NetworkVO> networks = _networkDao.listByZoneSecurityGroup(dataCenterId);
693+
if (networks == null || networks.size() == 0) {
694+
throw new CloudRuntimeException("Can not found security enabled network in SG Zone " + dc);
695+
}
696+
defaultNetwork = networks.get(0);
697+
} else {
698+
TrafficType defaultTrafficType = TrafficType.Public;
699+
if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) {
700+
defaultTrafficType = TrafficType.Guest;
701+
}
702+
List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType);
696703

697-
if (defaultNetworks.size() != 1) {
698-
throw new CloudRuntimeException("Found " + defaultNetworks.size() + " networks of type " + defaultTrafficType + " when expect to find 1");
704+
// api should never allow this situation to happen
705+
if (defaultNetworks.size() != 1) {
706+
throw new CloudRuntimeException("Found " + defaultNetworks.size() + " networks of type "
707+
+ defaultTrafficType + " when expect to find 1");
708+
}
709+
defaultNetwork = defaultNetworks.get(0);
699710
}
700711

701-
NetworkVO defaultNetwork = defaultNetworks.get(0);
702-
703712
List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork, NetworkOffering.SystemManagementNetwork);
704713
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
705714
NicProfile defaultNic = new NicProfile();

server/src/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,12 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd)
444444
+ cmd.getHypervisor() + " to a supported ");
445445
}
446446

447+
if (zone.isSecurityGroupEnabled()) {
448+
if( hypervisorType != HypervisorType.KVM && hypervisorType != HypervisorType.XenServer ) {
449+
throw new InvalidParameterValueException("Don't support hypervisor type " + hypervisorType + " in advanced security enabled zone");
450+
}
451+
}
452+
447453
Cluster.ClusterType clusterType = null;
448454
if (cmd.getClusterType() != null && !cmd.getClusterType().isEmpty()) {
449455
clusterType = Cluster.ClusterType.valueOf(cmd.getClusterType());

server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -538,19 +538,27 @@ protected Map<String, Object> createSecStorageVmInstance(long dataCenterId, Seco
538538
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
539539
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
540540

541-
TrafficType defaultTrafficType = TrafficType.Public;
542-
if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) {
543-
defaultTrafficType = TrafficType.Guest;
544-
}
545-
546-
List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType);
547-
548-
//api should never allow this situation to happen
549-
if (defaultNetworks.size() != 1) {
550-
throw new CloudRuntimeException("Found " + defaultNetworks.size() + " networks of type " + defaultTrafficType + " when expect to find 1");
541+
NetworkVO defaultNetwork = null;
542+
if (dc.getNetworkType() == NetworkType.Advanced && dc.isSecurityGroupEnabled()) {
543+
List<NetworkVO> networks = _networkDao.listByZoneSecurityGroup(dataCenterId);
544+
if (networks == null || networks.size() == 0) {
545+
throw new CloudRuntimeException("Can not found security enabled network in SG Zone " + dc);
546+
}
547+
defaultNetwork = networks.get(0);
548+
} else {
549+
TrafficType defaultTrafficType = TrafficType.Public;
550+
551+
if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) {
552+
defaultTrafficType = TrafficType.Guest;
553+
}
554+
List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType);
555+
// api should never allow this situation to happen
556+
if (defaultNetworks.size() != 1) {
557+
throw new CloudRuntimeException("Found " + defaultNetworks.size() + " networks of type "
558+
+ defaultTrafficType + " when expect to find 1");
559+
}
560+
defaultNetwork = defaultNetworks.get(0);
551561
}
552-
553-
NetworkVO defaultNetwork = defaultNetworks.get(0);
554562

555563
List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork, NetworkOfferingVO.SystemStorageNetwork);
556564
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);

setup/db/db/schema-410to420.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1716,4 +1716,5 @@ UPDATE `cloud`.`snapshots` set swift_id=null where swift_id=0;
17161716
-- Re-enable foreign key checking, at the end of the upgrade path
17171717
SET foreign_key_checks = 1;
17181718
UPDATE `cloud`.`snapshot_policy` set uuid=id WHERE uuid is NULL;
1719-
1719+
#update shared sg enabled network with not null name in Advance Security Group enabled network
1720+
UPDATE `cloud`.`networks` set name='Shared SG enabled network', display_text='Shared SG enabled network' WHERE name IS null AND traffic_type='Guest' AND data_center_id IN (select id from data_center where networktype='Advanced' and is_security_group_enabled=1) AND acl_type='Domain';

setup/dev/advancedsg.cfg

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
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+
{
19+
"zones": [
20+
{
21+
"name": "Sandbox-Simulator",
22+
"dns1": "10.147.28.6",
23+
"physical_networks": [
24+
{
25+
"name": "Sandbox-pnet",
26+
"tags": [
27+
"cloud-simulator-pnet"
28+
],
29+
"broadcastdomainrange": "Zone",
30+
"providers": [
31+
{
32+
"broadcastdomainrange": "ZONE",
33+
"name": "VirtualRouter"
34+
},
35+
{
36+
"broadcastdomainrange": "ZONE",
37+
"name": "SecurityGroupProvider"
38+
}
39+
],
40+
"traffictypes": [
41+
{
42+
"typ": "Guest"
43+
},
44+
{
45+
"typ": "Management",
46+
"simulator": "cloud-simulator-mgmt"
47+
}
48+
],
49+
"isolationmethods": [
50+
"VLAN"
51+
]
52+
}
53+
],
54+
"securitygroupenabled": "true",
55+
"ipranges": [
56+
{
57+
"startip": "10.147.31.150",
58+
"endip": "10.147.31.159",
59+
"netmask": "255.255.255.0",
60+
"vlan": "31",
61+
"gateway": "10.147.31.1"
62+
}
63+
],
64+
"networktype": "Advanced",
65+
"pods": [
66+
{
67+
"endip": "10.147.29.159",
68+
"name": "POD0",
69+
"startip": "10.147.29.150",
70+
"netmask": "255.255.255.0",
71+
"clusters": [
72+
{
73+
"clustername": "C0",
74+
"hypervisor": "Simulator",
75+
"hosts": [
76+
{
77+
"username": "root",
78+
"url": "http://simulator0",
79+
"password": "password"
80+
}
81+
],
82+
"clustertype": "CloudManaged",
83+
"primaryStorages": [
84+
{
85+
"url": "nfs://10.147.28.6:/export/home/sandbox/primary",
86+
"name": "PS0"
87+
}
88+
]
89+
}
90+
],
91+
"gateway": "10.147.29.1"
92+
}
93+
],
94+
"internaldns1": "10.147.28.6",
95+
"secondaryStorages": [
96+
{
97+
"url": "nfs://10.147.28.6:/export/home/sandbox/sstor"
98+
}
99+
]
100+
}
101+
],
102+
"dbSvr": {
103+
"dbSvr": "localhost",
104+
"passwd": "cloud",
105+
"db": "cloud",
106+
"port": 3306,
107+
"user": "cloud"
108+
},
109+
"logger": [
110+
{
111+
"name": "TestClient",
112+
"file": "testclient.log"
113+
},
114+
{
115+
"name": "TestCase",
116+
"file": "testcase.log"
117+
}
118+
],
119+
"globalConfig": [
120+
{
121+
"name": "storage.cleanup.interval",
122+
"value": "300"
123+
},
124+
{
125+
"name": "direct.agent.load.size",
126+
"value": "1000"
127+
},
128+
{
129+
"name": "default.page.size",
130+
"value": "10000"
131+
},
132+
{
133+
"name": "instance.name",
134+
"value": "QA"
135+
},
136+
{
137+
"name": "workers",
138+
"value": "10"
139+
},
140+
{
141+
"name": "vm.op.wait.interval",
142+
"value": "5"
143+
},
144+
{
145+
"name": "account.cleanup.interval",
146+
"value": "600"
147+
},
148+
{
149+
"name": "guest.domain.suffix",
150+
"value": "sandbox.simulator"
151+
},
152+
{
153+
"name": "expunge.delay",
154+
"value": "60"
155+
},
156+
{
157+
"name": "vm.allocation.algorithm",
158+
"value": "random"
159+
},
160+
{
161+
"name": "expunge.interval",
162+
"value": "60"
163+
},
164+
{
165+
"name": "expunge.workers",
166+
"value": "3"
167+
},
168+
{
169+
"name": "secstorage.allowed.internal.sites",
170+
"value": "10.147.28.0/24"
171+
},
172+
{
173+
"name": "check.pod.cidrs",
174+
"value": "true"
175+
}
176+
],
177+
"mgtSvr": [
178+
{
179+
"mgtSvrIp": "localhost",
180+
"passwd": "password",
181+
"user": "root",
182+
"port": 8096
183+
}
184+
]
185+
}

0 commit comments

Comments
 (0)