mirror of https://github.com/apache/cloudstack.git
Changed RuleTO classes to carry the source VLAN tag. Added guest network gateway to NetworkElementCommand.
This commit is contained in:
parent
f377ac1cf7
commit
1761024fda
|
|
@ -26,6 +26,7 @@ public abstract class NetworkElementCommand extends Command {
|
|||
|
||||
public static final String ACCOUNT_ID = "account.id";
|
||||
public static final String GUEST_NETWORK_CIDR = "guest.network.cidr";
|
||||
public static final String GUEST_NETWORK_GATEWAY = "guest.network.gateway";
|
||||
public static final String GUEST_VLAN_TAG = "guest.vlan.tag";
|
||||
public static final String ROUTER_NAME = "router.name";
|
||||
public static final String ROUTER_IP = "router.ip";
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import com.cloud.utils.net.NetUtils;
|
|||
*/
|
||||
public class FirewallRuleTO {
|
||||
long id;
|
||||
String srcVlanTag;
|
||||
String srcIp;
|
||||
String protocol;
|
||||
int[] srcPortRange;
|
||||
|
|
@ -56,8 +57,9 @@ public class FirewallRuleTO {
|
|||
protected FirewallRuleTO() {
|
||||
}
|
||||
|
||||
public FirewallRuleTO(long id, String srcIp, String protocol, Integer srcPortStart, Integer srcPortEnd, boolean revoked, boolean alreadyAdded, FirewallRule.Purpose purpose) {
|
||||
this.srcIp = srcIp;
|
||||
public FirewallRuleTO(long id, String srcVlanTag, String srcIp, String protocol, Integer srcPortStart, Integer srcPortEnd, boolean revoked, boolean alreadyAdded, FirewallRule.Purpose purpose) {
|
||||
this.srcVlanTag = srcVlanTag;
|
||||
this.srcIp = srcIp;
|
||||
this.protocol = protocol;
|
||||
|
||||
if (srcPortStart != null) {
|
||||
|
|
@ -80,14 +82,18 @@ public class FirewallRuleTO {
|
|||
this.purpose = purpose;
|
||||
}
|
||||
|
||||
public FirewallRuleTO(FirewallRule rule, String srcIp) {
|
||||
this(rule.getId(), srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getState()==State.Revoke, rule.getState()==State.Active, rule.getPurpose());
|
||||
public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp) {
|
||||
this(rule.getId(), srcVlanTag, srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getState()==State.Revoke, rule.getState()==State.Active, rule.getPurpose());
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getSrcVlanTag() {
|
||||
return srcVlanTag;
|
||||
}
|
||||
|
||||
public String getSrcIp() {
|
||||
return srcIp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,15 +39,15 @@ public class PortForwardingRuleTO extends FirewallRuleTO {
|
|||
super();
|
||||
}
|
||||
|
||||
public PortForwardingRuleTO(PortForwardingRule rule, String srcIp) {
|
||||
super(rule, srcIp);
|
||||
public PortForwardingRuleTO(PortForwardingRule rule, String srcVlanTag, String srcIp) {
|
||||
super(rule, srcVlanTag, srcIp);
|
||||
this.dstIp = rule.getDestinationIpAddress().addr();
|
||||
this.dstPortRange = new int[] { rule.getDestinationPortStart(), rule.getDestinationPortEnd() };
|
||||
this.sourceCidrs = rule.getSourceCidrList();
|
||||
}
|
||||
|
||||
protected PortForwardingRuleTO(long id, String srcIp, int srcPortStart, int srcPortEnd, String dstIp, int dstPortStart, int dstPortEnd, String protocol, boolean revoked, boolean brandNew) {
|
||||
super(id, srcIp, protocol, srcPortStart, srcPortEnd, revoked, brandNew, FirewallRule.Purpose.PortForwarding);
|
||||
protected PortForwardingRuleTO(long id, String srcVlanTag, String srcIp, int srcPortStart, int srcPortEnd, String dstIp, int dstPortStart, int dstPortEnd, String protocol, boolean revoked, boolean brandNew) {
|
||||
super(id, srcVlanTag, srcIp, protocol, srcPortStart, srcPortEnd, revoked, brandNew, FirewallRule.Purpose.PortForwarding);
|
||||
this.dstIp = dstIp;
|
||||
this.dstPortRange = new int[] { dstPortStart, dstPortEnd };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,14 +35,14 @@ public class StaticNatRuleTO extends FirewallRuleTO{
|
|||
protected StaticNatRuleTO() {
|
||||
}
|
||||
|
||||
public StaticNatRuleTO(StaticNatRule rule, String scrIp, String dstIp) {
|
||||
super(rule.getId(), scrIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(),rule.getState()==State.Revoke, rule.getState()==State.Active, rule.getPurpose());
|
||||
public StaticNatRuleTO(StaticNatRule rule, String srcVlanTag, String srcIp, String dstIp) {
|
||||
super(rule.getId(), srcVlanTag, srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(),rule.getState()==State.Revoke, rule.getState()==State.Active, rule.getPurpose());
|
||||
this.dstIp = dstIp;
|
||||
}
|
||||
|
||||
|
||||
protected StaticNatRuleTO(long id, String srcIp, int srcPortStart, int srcPortEnd, String dstIp, int dstPortStart, int dstPortEnd, String protocol, boolean revoked, boolean brandNew) {
|
||||
super(id, srcIp, protocol, srcPortStart, srcPortEnd, revoked, brandNew, FirewallRule.Purpose.StaticNat);
|
||||
protected StaticNatRuleTO(long id, String srcVlanTag, String srcIp, int srcPortStart, int srcPortEnd, String dstIp, int dstPortStart, int dstPortEnd, String protocol, boolean revoked, boolean brandNew) {
|
||||
super(id, srcVlanTag, srcIp, protocol, srcPortStart, srcPortEnd, revoked, brandNew, FirewallRule.Purpose.StaticNat);
|
||||
this.dstIp = dstIp;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -214,6 +214,11 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
|
|||
public Ip getDestinationIpAddress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestinationIpAddress(Ip destinationIpAddress) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDestinationPortStart() {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@ public interface PortForwardingRule extends FirewallRule {
|
|||
*/
|
||||
Ip getDestinationIpAddress();
|
||||
|
||||
|
||||
/**
|
||||
* updates the destination ip address.
|
||||
*/
|
||||
void setDestinationIpAddress(Ip destinationIpAddress);
|
||||
|
||||
/**
|
||||
* @return start of destination port.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1859,7 +1859,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
rulesTO = new ArrayList<PortForwardingRuleTO>();
|
||||
for (PortForwardingRule rule : rules) {
|
||||
IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
|
||||
PortForwardingRuleTO ruleTO = new PortForwardingRuleTO(rule, sourceIp.getAddress().addr());
|
||||
PortForwardingRuleTO ruleTO = new PortForwardingRuleTO(rule, null, sourceIp.getAddress().addr());
|
||||
rulesTO.add(ruleTO);
|
||||
}
|
||||
}
|
||||
|
|
@ -1880,7 +1880,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
rulesTO = new ArrayList<StaticNatRuleTO>();
|
||||
for (StaticNatRule rule : rules) {
|
||||
IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
|
||||
StaticNatRuleTO ruleTO = new StaticNatRuleTO(rule, sourceIp.getAddress().addr(), rule.getDestIpAddress());
|
||||
StaticNatRuleTO ruleTO = new StaticNatRuleTO(rule, null, sourceIp.getAddress().addr(), rule.getDestIpAddress());
|
||||
rulesTO.add(ruleTO);
|
||||
}
|
||||
}
|
||||
|
|
@ -2142,7 +2142,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
rulesTO = new ArrayList<FirewallRuleTO>();
|
||||
for (FirewallRule rule : rules) {
|
||||
IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
|
||||
FirewallRuleTO ruleTO = new FirewallRuleTO(rule, sourceIp.getAddress().addr());
|
||||
FirewallRuleTO ruleTO = new FirewallRuleTO(rule, null, sourceIp.getAddress().addr());
|
||||
rulesTO.add(ruleTO);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,11 @@ public class PortForwardingRuleVO extends FirewallRuleVO implements PortForwardi
|
|||
@Override
|
||||
public Ip getDestinationIpAddress() {
|
||||
return destinationIpAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestinationIpAddress(Ip destinationIpAddress) {
|
||||
this.destinationIpAddress = destinationIpAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -82,6 +87,8 @@ public class PortForwardingRuleVO extends FirewallRuleVO implements PortForwardi
|
|||
@Override
|
||||
public long getVirtualMachineId() {
|
||||
return virtualMachineId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue