Skip to content

Commit 14f80f2

Browse files
author
Alex Huang
committed
domain router up and running...now on to patching through the network between the domain router and the vm
1 parent ea2c493 commit 14f80f2

32 files changed

Lines changed: 574 additions & 147 deletions

api/src/com/cloud/dc/DataCenter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ public interface DataCenter extends Grouping {
1212
long getId();
1313
String getDns1();
1414
String getDns2();
15+
String getGuestNetworkCidr();
1516
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
package com.cloud.exception;
19+
20+
import com.cloud.utils.SerialVersionUID;
21+
import com.cloud.utils.exception.CloudRuntimeException;
22+
23+
public class AccountLimitException extends CloudRuntimeException {
24+
25+
private static final long serialVersionUID = SerialVersionUID.AccountLimitException;
26+
27+
protected AccountLimitException() {
28+
super();
29+
}
30+
31+
public AccountLimitException(String msg) {
32+
super(msg);
33+
}
34+
35+
public AccountLimitException(String msg, Throwable cause) {
36+
super(msg, cause);
37+
}
38+
39+
// TODO: Add the actual thing that causes the exception. Is it ip address, vm, etc?
40+
41+
}

api/src/com/cloud/exception/PermissionDeniedException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ public class PermissionDeniedException extends CloudRuntimeException {
3030

3131
public PermissionDeniedException(String message) {
3232
super(message);
33-
// TODO Auto-generated constructor stub
33+
}
34+
35+
protected PermissionDeniedException() {
36+
super();
3437
}
3538

3639
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
package com.cloud.network;
55

6+
import java.net.URI;
67
import java.util.List;
78
import java.util.Set;
89

@@ -92,7 +93,9 @@ private State(String description) {
9293

9394
long getRelated();
9495

95-
String getBroadcastUri();
96+
URI getBroadcastUri();
9697

97-
String getDns();
98+
String getDns1();
99+
100+
String getDns2();
98101
}

api/src/com/cloud/network/element/NetworkElement.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
package com.cloud.network.element;
55

6+
import com.cloud.deploy.DeployDestination;
67
import com.cloud.exception.ConcurrentOperationException;
78
import com.cloud.exception.InsufficientCapacityException;
89
import com.cloud.exception.ResourceUnavailableException;
@@ -23,11 +24,11 @@ public interface NetworkElement extends Adapter {
2324
* @param offering network offering that originated the network configuration.
2425
* @return true if network configuration is now usable; false if not; null if not handled by this element.
2526
*/
26-
Boolean implement(NetworkConfiguration config, NetworkOffering offering, Account user) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
27+
boolean implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination dest, Account user) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
2728

28-
Boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user) throws ConcurrentOperationException, ResourceUnavailableException;
29+
boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, DeployDestination dest, Account user) throws ConcurrentOperationException, ResourceUnavailableException;
2930

30-
Boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user) throws ConcurrentOperationException, ResourceUnavailableException;
31+
boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, NetworkOffering offering, Account user) throws ConcurrentOperationException, ResourceUnavailableException;
3132

32-
Boolean shutdown(NetworkConfiguration config, NetworkOffering offering, Account user) throws ConcurrentOperationException, ResourceUnavailableException;
33+
boolean shutdown(NetworkConfiguration config, NetworkOffering offering, Account user) throws ConcurrentOperationException, ResourceUnavailableException;
3334
}

client/tomcatconf/commands.properties.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ updateResourceLimit=com.cloud.api.commands.UpdateResourceLimitCmd;3
3333
listResourceLimits=com.cloud.api.commands.ListResourceLimitsCmd;15
3434

3535
#### VM commands
36-
deployVirtualMachine=com.cloud.api.commands.DeployVMCmd;11
36+
deployVirtualMachine=com.cloud.api.commands.DeployVm2Cmd;11
3737
destroyVirtualMachine=com.cloud.api.commands.DestroyVMCmd;15
3838
rebootVirtualMachine=com.cloud.api.commands.RebootVMCmd;15
3939
startVirtualMachine=com.cloud.api.commands.StartVMCmd;15

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
import com.cloud.configuration.dao.ConfigurationDao;
8080
import com.cloud.dc.DataCenterVO;
8181
import com.cloud.dc.HostPodVO;
82-
import com.cloud.dc.VlanVO;
8382
import com.cloud.dc.Vlan.VlanType;
83+
import com.cloud.dc.VlanVO;
8484
import com.cloud.dc.dao.DataCenterDao;
8585
import com.cloud.dc.dao.HostPodDao;
8686
import com.cloud.dc.dao.VlanDao;
@@ -101,8 +101,8 @@
101101
import com.cloud.exception.StorageUnavailableException;
102102
import com.cloud.ha.HighAvailabilityManager;
103103
import com.cloud.host.Host;
104-
import com.cloud.host.HostVO;
105104
import com.cloud.host.Host.Type;
105+
import com.cloud.host.HostVO;
106106
import com.cloud.host.dao.HostDao;
107107
import com.cloud.info.ConsoleProxyConnectionInfo;
108108
import com.cloud.info.ConsoleProxyInfo;
@@ -113,10 +113,10 @@
113113
import com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo;
114114
import com.cloud.maid.StackMaid;
115115
import com.cloud.network.IpAddrAllocator;
116-
import com.cloud.network.NetworkConfigurationVO;
117-
import com.cloud.network.NetworkManager;
118116
import com.cloud.network.IpAddrAllocator.networkInfo;
119117
import com.cloud.network.Network.TrafficType;
118+
import com.cloud.network.NetworkConfigurationVO;
119+
import com.cloud.network.NetworkManager;
120120
import com.cloud.network.dao.IPAddressDao;
121121
import com.cloud.offering.NetworkOffering;
122122
import com.cloud.offerings.NetworkOfferingVO;
@@ -128,9 +128,9 @@
128128
import com.cloud.storage.StorageManager;
129129
import com.cloud.storage.StoragePoolVO;
130130
import com.cloud.storage.VMTemplateHostVO;
131+
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
131132
import com.cloud.storage.VMTemplateVO;
132133
import com.cloud.storage.VolumeVO;
133-
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
134134
import com.cloud.storage.dao.GuestOSDao;
135135
import com.cloud.storage.dao.VMTemplateDao;
136136
import com.cloud.storage.dao.VMTemplateHostDao;
@@ -159,12 +159,12 @@
159159
import com.cloud.vm.State;
160160
import com.cloud.vm.VMInstanceVO;
161161
import com.cloud.vm.VirtualMachine;
162+
import com.cloud.vm.VirtualMachine.Event;
162163
import com.cloud.vm.VirtualMachineGuru;
163164
import com.cloud.vm.VirtualMachineManager;
164165
import com.cloud.vm.VirtualMachineName;
165166
import com.cloud.vm.VirtualMachineProfile;
166167
import com.cloud.vm.VmManager;
167-
import com.cloud.vm.VirtualMachine.Event;
168168
import com.cloud.vm.dao.ConsoleProxyDao;
169169
import com.cloud.vm.dao.VMInstanceDao;
170170
import com.google.gson.Gson;
@@ -529,7 +529,7 @@ private boolean hasPreviousSession(ConsoleProxyVO proxy, VMInstanceVO vm) {
529529
@Override
530530
public ConsoleProxyVO startProxy(long proxyVmId, long startEventId) {
531531
try {
532-
return start(proxyVmId, startEventId);
532+
return start2(proxyVmId, startEventId);
533533
} catch (StorageUnavailableException e) {
534534
s_logger.warn("Exception while trying to start console proxy", e);
535535
return null;
@@ -885,7 +885,7 @@ public ConsoleProxyVO startNewConsoleProxy(long dataCenterId) {
885885
if (s_logger.isDebugEnabled())
886886
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
887887

888-
Map<String, Object> context = createProxyInstance(dataCenterId);
888+
Map<String, Object> context = createProxyInstance2(dataCenterId);
889889

890890
long proxyVmId = (Long) context.get("proxyVmId");
891891
if (proxyVmId == 0) {
@@ -925,7 +925,7 @@ public ConsoleProxyVO startNew(long dataCenterId) {
925925
if (s_logger.isDebugEnabled())
926926
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
927927

928-
Map<String, Object> context = createProxyInstance(dataCenterId);
928+
Map<String, Object> context = createProxyInstance2(dataCenterId);
929929

930930
long proxyVmId = (Long) context.get("proxyVmId");
931931
if (proxyVmId == 0) {
@@ -1467,7 +1467,7 @@ private void checkPendingProxyVMs() {
14671467
try {
14681468
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
14691469
try {
1470-
readyProxy = start(readyProxy.getId(), 0);
1470+
readyProxy = start2(readyProxy.getId(), 0);
14711471
} finally {
14721472
proxyLock.unlock();
14731473
}
@@ -2451,7 +2451,7 @@ public boolean applyCustomCertToNewProxy(StartupProxyCommand cmd){
24512451
if(certList.size()>0){
24522452
CertificateVO cert = certList.get(0);//there will only be 1 cert in db for now
24532453
String certStr = cert.getCertificate();
2454-
long proxyVmId = ((StartupProxyCommand)cmd).getProxyVmId();
2454+
long proxyVmId = (cmd).getProxyVmId();
24552455
ConsoleProxyVO consoleProxy = _consoleProxyDao.findById(proxyVmId);
24562456
//find corresponding host
24572457
if(consoleProxy!=null){

server/src/com/cloud/network/NetworkConfigurationVO.java

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
*/
1818
package com.cloud.network;
1919

20+
import java.net.URI;
21+
2022
import javax.persistence.Column;
2123
import javax.persistence.Entity;
2224
import javax.persistence.EnumType;
2325
import javax.persistence.Enumerated;
2426
import javax.persistence.Id;
2527
import javax.persistence.Table;
2628
import javax.persistence.TableGenerator;
29+
import javax.persistence.Transient;
2730

2831
import com.cloud.network.Network.BroadcastDomainType;
2932
import com.cloud.network.Network.Mode;
@@ -56,7 +59,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
5659
TrafficType trafficType;
5760

5861
@Column(name="broadcast_uri")
59-
String broadcastUri;
62+
URI broadcastUri;
6063

6164
@Column(name="gateway")
6265
String gateway;
@@ -80,19 +83,28 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
8083
@Enumerated(value=EnumType.STRING)
8184
State state;
8285

83-
@Column(name="dns")
84-
String dns;
86+
@Column(name="dns1")
87+
String dns1;
8588

8689
@Column(name="domain_id")
8790
long domainId;
8891

8992
@Column(name="account_id")
9093
long accountId;
9194

92-
@Column(name="mac_address_seq", updatable=false, nullable=false)
93-
@TableGenerator(name="mac_address_seq", table="network_configuration", pkColumnName="id", valueColumnName="mac_address_seq", allocationSize=1)
95+
@Column(name="set_fields")
96+
long setFields;
97+
98+
@TableGenerator(name="mac_address_seq", table="op_network_configurations", pkColumnName="id", valueColumnName="mac_address_seq", allocationSize=1)
99+
@Transient
94100
long macAddress = 1;
95101

102+
@Column(name="guru_data")
103+
String guruData;
104+
105+
@Column(name="dns2")
106+
String dns2;
107+
96108
public NetworkConfigurationVO() {
97109
}
98110

@@ -116,6 +128,10 @@ public NetworkConfigurationVO(TrafficType trafficType, Mode mode, BroadcastDomai
116128

117129
public NetworkConfigurationVO(long id, NetworkConfiguration that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related) {
118130
this(id, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related);
131+
this.gateway = that.getGateway();
132+
this.dns1 = that.getDns1();
133+
this.dns2 = that.getDns2();
134+
this.cidr = that.getCidr();
119135
this.guruName = guruName;
120136
this.state = that.getState();
121137
if (state == null) {
@@ -189,6 +205,14 @@ public BroadcastDomainType getBroadcastDomainType() {
189205
return broadcastDomainType;
190206
}
191207

208+
public String getGuruData() {
209+
return guruData;
210+
}
211+
212+
public void setGuruData(String guruData) {
213+
this.guruData = guruData;
214+
}
215+
192216
public String getGuruName() {
193217
return guruName;
194218
}
@@ -229,11 +253,11 @@ public void setCidr(String cidr) {
229253
}
230254

231255
@Override
232-
public String getBroadcastUri() {
256+
public URI getBroadcastUri() {
233257
return broadcastUri;
234258
}
235259

236-
public void setBroadcastUri(String broadcastUri) {
260+
public void setBroadcastUri(URI broadcastUri) {
237261
this.broadcastUri = broadcastUri;
238262
}
239263

@@ -248,14 +272,25 @@ public long getDataCenterId() {
248272
}
249273

250274
@Override
251-
public String getDns() {
252-
return dns;
275+
public String getDns1() {
276+
return dns1;
253277
}
254278

255-
public void setDns(String dns) {
256-
this.dns = dns;
279+
public void setDns1(String dns) {
280+
this.dns1 = dns;
257281
}
258282

283+
@Override
284+
public String getDns2() {
285+
return dns2;
286+
}
287+
288+
public void setDns2(String dns) {
289+
this.dns2 = dns;
290+
}
291+
292+
293+
259294
@Override
260295
public boolean equals(Object obj) {
261296
if (!(obj instanceof NetworkConfigurationVO)) {
@@ -276,4 +311,8 @@ public boolean equals(Object obj) {
276311

277312
return NetUtils.isNetworkAWithinNetworkB(this.cidr, that.cidr);
278313
}
314+
315+
public boolean isImplemented() {
316+
return broadcastUri != null && cidr != null && gateway != null && mode != null && broadcastDomainType != null;
317+
}
279318
}

server/src/com/cloud/network/NetworkManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.cloud.api.commands.StopRouterCmd;
3737
import com.cloud.api.commands.UpdateLoadBalancerRuleCmd;
3838
import com.cloud.api.commands.UpgradeRouterCmd;
39+
import com.cloud.dc.DataCenter;
3940
import com.cloud.dc.DataCenterVO;
4041
import com.cloud.dc.HostPodVO;
4142
import com.cloud.dc.VlanVO;
@@ -318,4 +319,6 @@ void assignToLoadBalancer(AssignToLoadBalancerRuleCmd cmd) throws NetworkRuleCo
318319
List<NetworkConfigurationVO> getNetworkConfigurationsforOffering(long offeringId, long dataCenterId, long accountId);
319320

320321
List<NetworkConfigurationVO> setupNetworkConfiguration(Account owner, ServiceOfferingVO offering, DeploymentPlan plan);
322+
323+
String assignSourceNatIpAddress(Account account, DataCenter dc) throws InsufficientAddressCapacityException;
321324
}

0 commit comments

Comments
 (0)