Skip to content

Commit fcdd20c

Browse files
author
Alex Huang
committed
more checkin
1 parent b628c3f commit fcdd20c

28 files changed

Lines changed: 710 additions & 488 deletions

‎api/src/com/cloud/agent/api/routing/SetPortForwardingRulesCommand.java‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,20 @@
2020
import java.util.List;
2121

2222
import com.cloud.agent.api.to.PortForwardingRuleTO;
23+
import com.cloud.network.rules.PortForwardingRule;
2324

2425
public class SetPortForwardingRulesCommand extends RoutingCommand {
2526
PortForwardingRuleTO[] rules;
2627

2728
protected SetPortForwardingRulesCommand() {
2829
}
2930

30-
public SetPortForwardingRulesCommand(List<PortForwardingRuleTO> rules) {
31-
this.rules = rules.toArray(new PortForwardingRuleTO[rules.size()]);
31+
public SetPortForwardingRulesCommand(List<? extends PortForwardingRule> pfRules) {
32+
rules = new PortForwardingRuleTO[pfRules.size()];
33+
int i = 0;
34+
for (PortForwardingRule rule : pfRules) {
35+
rules[i++] = new PortForwardingRuleTO(rule);
36+
}
3237
}
3338

3439
public PortForwardingRuleTO[] getRules() {

‎api/src/com/cloud/agent/api/to/FirewallRuleTO.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ public class FirewallRuleTO {
2222
String protocol;
2323
int[] srcPortRange;
2424
boolean revoked;
25+
boolean brandNew;
2526
String vlanNetmask; // FIXME: Get rid of this!
2627

2728
protected FirewallRuleTO() {
2829
}
2930

30-
public FirewallRuleTO(String srcIp, String protocol, int srcPortStart, int srcPortEnd, boolean revoked) {
31+
public FirewallRuleTO(String srcIp, String protocol, int srcPortStart, int srcPortEnd, boolean revoked, boolean brandNew) {
3132
this.srcIp = srcIp;
3233
this.protocol = protocol;
3334
this.srcPortRange = new int[] {srcPortStart, srcPortEnd};
3435
this.revoked = revoked;
36+
this.brandNew = brandNew;
3537
}
3638

3739
public String getSrcIp() {
@@ -53,4 +55,8 @@ public boolean revoked() {
5355
public String getVlanNetmask() {
5456
return vlanNetmask;
5557
}
58+
59+
public boolean isBrandNew() {
60+
return brandNew;
61+
}
5662
}

‎api/src/com/cloud/agent/api/to/PortForwardingRuleTO.java‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
*/
1818
package com.cloud.agent.api.to;
1919

20+
import com.cloud.network.rules.FirewallRule.State;
21+
import com.cloud.network.rules.PortForwardingRule;
22+
2023
public class PortForwardingRuleTO extends FirewallRuleTO {
2124
String dstIp;
2225
int[] dstPortRange;
@@ -25,8 +28,12 @@ protected PortForwardingRuleTO() {
2528
super();
2629
}
2730

28-
public PortForwardingRuleTO(String srcIp, int srcPortStart, int srcPortEnd, String dstIp, int dstPortStart, int dstPortEnd, String protocol, boolean revoked) {
29-
super(srcIp, protocol, srcPortStart, srcPortEnd, revoked);
31+
public PortForwardingRuleTO(PortForwardingRule rule) {
32+
this(rule.getSourceIpAddress().addr(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getDestinationIpAddress().addr(), rule.getDestinationPortStart(), rule.getDestinationPortEnd(), rule.getProtocol(), rule.getState() == State.Revoke, rule.getState() == State.Add);
33+
}
34+
35+
protected PortForwardingRuleTO(String srcIp, int srcPortStart, int srcPortEnd, String dstIp, int dstPortStart, int dstPortEnd, String protocol, boolean revoked, boolean brandNew) {
36+
super(srcIp, protocol, srcPortStart, srcPortEnd, revoked, brandNew);
3037
this.dstIp = dstIp;
3138
this.dstPortRange = new int[] { dstPortStart, dstPortEnd };
3239
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@ public enum DataCenterNetworkType {
2626
DataCenterNetworkType getNetworkType();
2727
String getInternalDns1();
2828
String getInternalDns2();
29+
String getDnsProvider();
30+
String getGatewayProvider();
31+
String getFirewallProvider();
32+
String getDhcpProvider();
33+
String getLoadBalancerProvider();
34+
2935
}

‎api/src/com/cloud/network/Networks.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
*
2828
*/
2929
public class Networks {
30+
31+
public enum Service {
32+
Dhcp,
33+
Dns,
34+
Gateway,
35+
LoadBalancer,
36+
Firewall
37+
}
38+
3039
/**
3140
* Different ways to assign ip address to this network.
3241
*/

‎api/src/com/cloud/network/configuration/NetworkGuru.java‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,48 +36,48 @@ public interface NetworkGuru extends Adapter {
3636
/**
3737
* allocate a nic in this network. This method implementation cannot take a long time as
3838
* it is meant to allocate for the DB.
39-
* @param config configuration to allocate the nic in.
39+
* @param network configuration to allocate the nic in.
4040
* @param nic user specified
4141
* @param vm virtual machine the network configuraiton will be in.
4242
* @return NicProfile.
4343
* @throws InsufficientVirtualNetworkCapcityException
4444
* @throws InsufficientAddressCapacityException
4545
*/
46-
NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
46+
NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
4747

4848
/**
4949
* Fully implement the network configuration as specified.
50-
* @param config network configuration
50+
* @param network network configuration
5151
* @param offering offering that the network configuration was based on.
5252
* @param destination where were deploying to.
5353
* @return a fully implemented NetworkConfiguration.
5454
*/
55-
Network implement(Network config, NetworkOffering offering, DeployDestination destination, ReservationContext context);
55+
Network implement(Network network, NetworkOffering offering, DeployDestination destination, ReservationContext context);
5656

5757
/**
5858
* reserve a nic for this VM in this network.
5959
* @param nic
60-
* @param config
60+
* @param network
6161
* @param vm
6262
* @param dest
6363
* @return
6464
* @throws InsufficientVirtualNetworkCapcityException
6565
* @throws InsufficientAddressCapacityException
6666
*/
67-
void reserve(NicProfile nic, Network config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
67+
void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
6868

6969
boolean release(NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, String reservationId);
7070

71-
void deallocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm);
71+
void deallocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm);
7272

73-
void destroy(Network config, NetworkOffering offering);
73+
void destroy(Network network, NetworkOffering offering);
7474

7575
/**
7676
* Throw away the design.
77-
* @param config
77+
* @param network
7878
* @param offering
7979
* @param owner
8080
* @return
8181
*/
82-
boolean trash(Network config, NetworkOffering offering, Account owner);
82+
boolean trash(Network network, NetworkOffering offering, Account owner);
8383
}

‎api/src/com/cloud/network/rules/FirewallRule.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enum Purpose {
3131
enum State {
3232
Staged, // Rule been created but has never got through network rule conflict detection. Rules in this state can not be sent to network elements.
3333
Add, // Add means the rule has been created and has gone through network rule conflict detection.
34+
Active, // Rule has been sent to the network elements and reported to be active.
3435
Revoke // Revoke means this rule has been revoked. If this rule has been sent to the network elements, the rule will be deleted from database.
3536
}
3637

‎api/src/com/cloud/user/UserContext.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class UserContext {
3030

3131
private long userId;
3232
private String sessionId;
33-
private Account accountObject;
33+
private Account account;
3434

3535
private boolean apiServer;
3636

@@ -41,7 +41,7 @@ public UserContext() {
4141

4242
public UserContext(long userId, Account accountObject, String sessionId, boolean apiServer) {
4343
this.userId = userId;
44-
this.accountObject = accountObject;
44+
this.account = accountObject;
4545
this.sessionId = sessionId;
4646
this.apiServer = apiServer;
4747
}
@@ -59,11 +59,11 @@ public String getSessionId() {
5959
}
6060

6161
public Account getAccount() {
62-
return accountObject;
62+
return account;
6363
}
6464

6565
public void setAccount(Account accountObject) {
66-
this.accountObject = accountObject;
66+
this.account = accountObject;
6767
}
6868

6969
public void setSessionKey(String sessionId) {

‎server/src/com/cloud/configuration/DefaultComponentLibrary.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ protected void populateDaos() {
164164
info.addParameter("cache.size", "50");
165165
info.addParameter("cache.time.to.live", "600");
166166
addDao("IPAddressDao", IPAddressDaoImpl.class);
167-
addDao("VlanDao", VlanDaoImpl.class);
167+
info = addDao("VlanDao", VlanDaoImpl.class);
168+
info.addParameter("cache.size", "30");
169+
info.addParameter("cache.time.to.live", "3600");
168170
addDao("PodVlanMapDao", PodVlanMapDaoImpl.class);
169171
addDao("AccountVlanMapDao", AccountVlanMapDaoImpl.class);
170172
addDao("VolumeDao", VolumeDaoImpl.class);

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

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,11 @@
7777
import com.cloud.configuration.dao.ConfigurationDao;
7878
import com.cloud.dc.DataCenterVO;
7979
import com.cloud.dc.HostPodVO;
80-
import com.cloud.dc.Vlan.VlanType;
81-
import com.cloud.dc.VlanVO;
8280
import com.cloud.dc.dao.DataCenterDao;
8381
import com.cloud.dc.dao.HostPodDao;
8482
import com.cloud.dc.dao.VlanDao;
8583
import com.cloud.deploy.DataCenterDeployment;
8684
import com.cloud.deploy.DeployDestination;
87-
import com.cloud.domain.DomainVO;
8885
import com.cloud.event.Event;
8986
import com.cloud.event.EventTypes;
9087
import com.cloud.event.EventUtils;
@@ -1174,21 +1171,21 @@ private networkInfo allocPublicIpAddress(long dcId, long podId, String macAddr)
11741171
return net;
11751172
}
11761173

1177-
Pair<String, VlanVO> ipAndVlan = _vlanDao.assignIpAddress(dcId, Account.ACCOUNT_ID_SYSTEM, DomainVO.ROOT_DOMAIN, VlanType.VirtualNetwork,
1178-
true);
1179-
1180-
if (ipAndVlan == null) {
1181-
s_logger.debug("Unable to get public ip address (type=Virtual) for console proxy vm for data center : " + dcId);
1182-
ipAndVlan = _vlanDao.assignPodDirectAttachIpAddress(dcId, podId, Account.ACCOUNT_ID_SYSTEM, DomainVO.ROOT_DOMAIN);
1183-
if (ipAndVlan == null) {
1184-
s_logger.debug("Unable to get public ip address (type=DirectAttach) for console proxy vm for data center : " + dcId);
1185-
}
1186-
}
1187-
if (ipAndVlan != null) {
1188-
VlanVO vlan = ipAndVlan.second();
1189-
networkInfo net = new networkInfo(ipAndVlan.first(), vlan.getVlanNetmask(), vlan.getVlanGateway(), vlan.getId(), vlan.getVlanId());
1190-
return net;
1191-
}
1174+
// Pair<String, VlanVO> ipAndVlan = _vlanDao.assignIpAddress(dcId, Account.ACCOUNT_ID_SYSTEM, DomainVO.ROOT_DOMAIN, VlanType.VirtualNetwork,
1175+
// true);
1176+
//
1177+
// if (ipAndVlan == null) {
1178+
// s_logger.debug("Unable to get public ip address (type=Virtual) for console proxy vm for data center : " + dcId);
1179+
// ipAndVlan = _vlanDao.assignPodDirectAttachIpAddress(dcId, podId, Account.ACCOUNT_ID_SYSTEM, DomainVO.ROOT_DOMAIN);
1180+
// if (ipAndVlan == null) {
1181+
// s_logger.debug("Unable to get public ip address (type=DirectAttach) for console proxy vm for data center : " + dcId);
1182+
// }
1183+
// }
1184+
// if (ipAndVlan != null) {
1185+
// VlanVO vlan = ipAndVlan.second();
1186+
// networkInfo net = new networkInfo(ipAndVlan.first(), vlan.getVlanNetmask(), vlan.getVlanGateway(), vlan.getId(), vlan.getVlanId());
1187+
// return net;
1188+
// }
11921189
return null;
11931190
}
11941191

0 commit comments

Comments
 (0)