This commit is contained in:
Sebastien Goasguen 2013-06-07 02:59:48 -04:00
commit 4f07679d49
19 changed files with 122 additions and 109 deletions

View File

@ -37,6 +37,7 @@ COMMIT
-A INPUT -i eth0 -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -i eth1 -p tcp -m state --state NEW --dport 3922 -j ACCEPT
-A INPUT -i eth0 -p tcp -m state --state NEW --dport 80 -j ACCEPT
-A INPUT -i eth0 -p tcp -m state --state NEW --dport 8080 -j ACCEPT
-A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i eth2 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i eth0 -o eth0 -m state --state NEW -j ACCEPT

View File

@ -485,7 +485,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
if (add && (!reservedIpAddressesForGuestNetwork.contains(network.getGateway()))) {
// Insert a new NIC for this guest network to reserve the gateway address
_networkMgr.savePlaceholderNic(network, network.getGateway(), null);
_networkMgr.savePlaceholderNic(network, network.getGateway(), null, null);
}
// Delete any mappings used for inline external load balancers in this network

View File

@ -774,7 +774,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
// If a NIC doesn't exist for the load balancing IP address, create one
loadBalancingIpNic = _nicDao.findByIp4AddressAndNetworkId(loadBalancingIpAddress, network.getId());
if (loadBalancingIpNic == null) {
loadBalancingIpNic = _networkMgr.savePlaceholderNic(network, loadBalancingIpAddress, null);
loadBalancingIpNic = _networkMgr.savePlaceholderNic(network, loadBalancingIpAddress, null, null);
}
// Save a mapping between the source IP address and the load balancing IP address NIC
@ -1019,7 +1019,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
if (add) {
// Insert a new NIC for this guest network to reserve the self IP
_networkMgr.savePlaceholderNic(guestConfig, selfIp, null);
_networkMgr.savePlaceholderNic(guestConfig, selfIp, null, null);
} else {
// release the self-ip obtained from guest network
Nic selfipNic = getPlaceholderNic(guestConfig);

View File

@ -381,7 +381,7 @@ public interface NetworkManager {
String allocatePublicIpForGuestNic(Long networkId, DataCenter dc, Pod pod, Account caller, String requestedIp) throws InsufficientAddressCapacityException;
NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType);
NicVO savePlaceholderNic(Network network, String ip4Address, String ip6Address, Type vmType);
DhcpServiceProvider getDhcpServiceProvider(Network network);

View File

@ -1481,23 +1481,6 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
s_logger.debug("Found existing network configuration for offering " + offering + ": " + configs.get(0));
}
if (errorIfAlreadySetup) {
InvalidParameterValueException ex = new InvalidParameterValueException("Found existing network configuration (with specified id) for offering (with specified id)");
ex.addProxyObject(offering.getUuid(), "offeringId");
ex.addProxyObject(configs.get(0).getUuid(), "networkConfigId");
throw ex;
} else {
return configs;
}
}
} else if (predefined != null && predefined.getCidr() != null && predefined.getBroadcastUri() == null && vpcId == null) {
// don't allow to have 2 networks with the same cidr in the same zone for the account
List<NetworkVO> configs = _networksDao.listBy(owner.getId(), plan.getDataCenterId(), predefined.getCidr(), true);
if (configs.size() > 0) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Found existing network configuration for offering " + offering + ": " + configs.get(0));
}
if (errorIfAlreadySetup) {
InvalidParameterValueException ex = new InvalidParameterValueException("Found existing network configuration (with specified id) for offering (with specified id)");
ex.addProxyObject(offering.getUuid(), "offeringId");
@ -4342,9 +4325,10 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
@Override
public NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType) {
public NicVO savePlaceholderNic(Network network, String ip4Address, String ip6Address, Type vmType) {
NicVO nic = new NicVO(null, null, network.getId(), null);
nic.setIp4Address(ip4Address);
nic.setIp6Address(ip6Address);
nic.setReservationStrategy(ReservationStrategy.PlaceHolder);
nic.setState(Nic.State.Reserved);
nic.setVmType(vmType);

View File

@ -2065,17 +2065,24 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
public NicVO getPlaceholderNicForRouter(Network network, Long podId) {
List<NicVO> nics = _nicDao.listPlaceholderNicsByNetworkIdAndVmType(network.getId(), VirtualMachine.Type.DomainRouter);
for (NicVO nic : nics) {
if (nic.getReserver() == null && nic.getIp4Address() != null) {
if (nic.getReserver() == null && (nic.getIp4Address() != null || nic.getIp6Address() != null)) {
if (podId == null) {
return nic;
} else {
//return nic only when its ip address belong to the pod range (for the Basic zone case)
List<? extends Vlan> vlans = _vlanDao.listVlansForPod(podId);
for (Vlan vlan : vlans) {
IpAddress ip = _ipAddressDao.findByIpAndNetworkId(network.getId(), nic.getIp4Address());
if (ip != null && ip.getVlanId() == vlan.getId()) {
return nic;
}
if (nic.getIp4Address() != null) {
IpAddress ip = _ipAddressDao.findByIpAndNetworkId(network.getId(), nic.getIp4Address());
if (ip != null && ip.getVlanId() == vlan.getId()) {
return nic;
}
} else {
UserIpv6AddressVO ipv6 = _ipv6Dao.findByNetworkIdAndIp(network.getId(), nic.getIp6Address());
if (ipv6 != null && ipv6.getVlanId() == vlan.getId()) {
return nic;
}
}
}
}
}

View File

@ -3044,6 +3044,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
_accountGuestVlanMapDao.update(guestVlanMapId, accountGuestVlanMapVO);
} else {
Transaction txn = Transaction.currentTxn();
txn.start();
accountGuestVlanMapVO = new AccountGuestVlanMapVO(vlanOwner.getAccountId(), physicalNetworkId);
accountGuestVlanMapVO.setGuestVlanRange(startVlan + "-" + endVlan);
_accountGuestVlanMapDao.persist(accountGuestVlanMapVO);

View File

@ -221,7 +221,6 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
//FIXME - save ipv6 informaiton in the placeholder nic
Transaction txn = Transaction.currentTxn();
txn.start();
_networkMgr.allocateDirectIp(nic, dc, vm, network, requestedIp4Addr, requestedIp6Addr);
@ -229,8 +228,8 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
if (vm.getType() == VirtualMachine.Type.DomainRouter) {
Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, null);
if (placeholderNic == null) {
s_logger.debug("Saving placeholder nic with ip4 address " + nic.getIp4Address() + " and ipv6 address " + requestedIp6Addr + " for the network " + network);
_networkMgr.savePlaceholderNic(network, nic.getIp4Address(), VirtualMachine.Type.DomainRouter);
s_logger.debug("Saving placeholder nic with ip4 address " + nic.getIp4Address() + " and ipv6 address " + nic.getIp6Address() + " for the network " + network);
_networkMgr.savePlaceholderNic(network, nic.getIp4Address(), nic.getIp6Address(), VirtualMachine.Type.DomainRouter);
}
}
txn.commit();

View File

@ -203,7 +203,7 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, pod.getId());
if (placeholderNic == null) {
s_logger.debug("Saving placeholder nic with ip4 address " + nic.getIp4Address() + " for the network " + network);
_networkMgr.savePlaceholderNic(network, nic.getIp4Address(), VirtualMachine.Type.DomainRouter);
_networkMgr.savePlaceholderNic(network, nic.getIp4Address(), null, VirtualMachine.Type.DomainRouter);
}
}
txn.commit();

View File

@ -1740,30 +1740,34 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
s_logger.debug("Adding nic for Virtual Router in Guest network " + guestNetwork);
String defaultNetworkStartIp = null, defaultNetworkStartIpv6 = null;
if (!setupPublicNetwork) {
Nic placeholder = _networkModel.getPlaceholderNicForRouter(guestNetwork, plan.getPodId());
if (guestNetwork.getCidr() != null) {
Nic placeholder = _networkModel.getPlaceholderNicForRouter(guestNetwork, plan.getPodId());
if (placeholder != null) {
s_logger.debug("Requesting ip address " + placeholder.getIp4Address() + " stored in placeholder nic for the network " + guestNetwork);
defaultNetworkStartIp = placeholder.getIp4Address();
} else {
String startIp = _networkModel.getStartIpAddress(guestNetwork.getId());
if (startIp != null && _ipAddressDao.findByIpAndSourceNetworkId(guestNetwork.getId(), startIp).getAllocatedTime() == null) {
defaultNetworkStartIp = startIp;
} else if (s_logger.isDebugEnabled()){
s_logger.debug("First ip " + startIp + " in network id=" + guestNetwork.getId() +
" is already allocated, can't use it for domain router; will get random ip address from the range");
}
}
if (placeholder != null && placeholder.getIp4Address() != null) {
s_logger.debug("Requesting ipv4 address " + placeholder.getIp4Address() + " stored in placeholder nic for the network " + guestNetwork);
defaultNetworkStartIp = placeholder.getIp4Address();
} else {
String startIp = _networkModel.getStartIpAddress(guestNetwork.getId());
if (startIp != null && _ipAddressDao.findByIpAndSourceNetworkId(guestNetwork.getId(), startIp).getAllocatedTime() == null) {
defaultNetworkStartIp = startIp;
} else if (s_logger.isDebugEnabled()){
s_logger.debug("First ipv4 " + startIp + " in network id=" + guestNetwork.getId() +
" is already allocated, can't use it for domain router; will get random ip address from the range");
}
}
}
//FIXME - get ipv6 stored in the placeholder
if (guestNetwork.getIp6Cidr() != null) {
String startIpv6 = _networkModel.getStartIpv6Address(guestNetwork.getId());
if (startIpv6 != null && _ipv6Dao.findByNetworkIdAndIp(guestNetwork.getId(), startIpv6) == null) {
defaultNetworkStartIpv6 = startIpv6;
} else if (s_logger.isDebugEnabled()){
s_logger.debug("First ipv6 " + startIpv6 + " in network id=" + guestNetwork.getId() +
" is already allocated, can't use it for domain router; will get random ipv6 address from the range");
if (placeholder != null && placeholder.getIp6Address() != null) {
s_logger.debug("Requesting ipv6 address " + placeholder.getIp6Address() + " stored in placeholder nic for the network " + guestNetwork);
defaultNetworkStartIpv6 = placeholder.getIp6Address();
} else {
String startIpv6 = _networkModel.getStartIpv6Address(guestNetwork.getId());
if (startIpv6 != null && _ipv6Dao.findByNetworkIdAndIp(guestNetwork.getId(), startIpv6) == null) {
defaultNetworkStartIpv6 = startIpv6;
} else if (s_logger.isDebugEnabled()){
s_logger.debug("First ipv6 " + startIpv6 + " in network id=" + guestNetwork.getId() +
" is already allocated, can't use it for domain router; will get random ipv6 address from the range");
}
}
}
}

View File

@ -949,9 +949,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
if (router.getVpcId() != null) {
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.NetworkACL, Provider.VPCVirtualRouter)) {
List<NetworkACLItemVO> networkACLs = _networkACLMgr.listNetworkACLItems(guestNetworkId);
s_logger.debug("Found " + networkACLs.size() + " network ACLs to apply as a part of VPC VR " + router
+ " start for guest network id=" + guestNetworkId);
if (!networkACLs.isEmpty()) {
if ((networkACLs != null) && !networkACLs.isEmpty()) {
s_logger.debug("Found " + networkACLs.size() + " network ACLs to apply as a part of VPC VR " + router
+ " start for guest network id=" + guestNetworkId);
createNetworkACLsCommands(networkACLs, router, cmds, guestNetworkId, false);
}
}

View File

@ -294,6 +294,9 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana
@Override
public List<NetworkACLItemVO> listNetworkACLItems(long guestNtwkId) {
Network network = _networkMgr.getNetwork(guestNtwkId);
if(network.getNetworkACLId() == null){
return null;
}
return _networkACLItemDao.listByACL(network.getNetworkACLId());
}

View File

@ -303,28 +303,30 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
}
//Validate Protocol
//Check if protocol is a number
if(StringUtils.isNumeric(protocol)){
int protoNumber = Integer.parseInt(protocol);
if(protoNumber < 0 || protoNumber > 255){
throw new InvalidParameterValueException("Invalid protocol number: " + protoNumber);
if(protocol != null){
//Check if protocol is a number
if(StringUtils.isNumeric(protocol)){
int protoNumber = Integer.parseInt(protocol);
if(protoNumber < 0 || protoNumber > 255){
throw new InvalidParameterValueException("Invalid protocol number: " + protoNumber);
}
} else {
//Protocol is not number
//Check for valid protocol strings
String supportedProtocols = "tcp,udp,icmp,all";
if(!supportedProtocols.contains(protocol.toLowerCase())){
throw new InvalidParameterValueException("Invalid protocol: " + protocol);
}
}
} else {
//Protocol is not number
//Check for valid protocol strings
String supportedProtocols = "tcp,udp,icmp,all";
if(!supportedProtocols.contains(protocol.toLowerCase())){
throw new InvalidParameterValueException("Invalid protocol: " + protocol);
// icmp code and icmp type can't be passed in for any other protocol rather than icmp
if (!protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO) && (icmpCode != null || icmpType != null)) {
throw new InvalidParameterValueException("Can specify icmpCode and icmpType for ICMP protocol only");
}
}
// icmp code and icmp type can't be passed in for any other protocol rather than icmp
if (!protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO) && (icmpCode != null || icmpType != null)) {
throw new InvalidParameterValueException("Can specify icmpCode and icmpType for ICMP protocol only");
}
if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO) && (portStart != null || portEnd != null)) {
throw new InvalidParameterValueException("Can't specify start/end port when protocol is ICMP");
if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO) && (portStart != null || portEnd != null)) {
throw new InvalidParameterValueException("Can't specify start/end port when protocol is ICMP");
}
}
//validate icmp code and type

View File

@ -66,15 +66,8 @@ import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.utils.Pair;
import com.cloud.utils.component.ManagerBase;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.NicVO;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.*;
import com.cloud.vm.VirtualMachine.Type;
import com.cloud.vm.VirtualMachineProfile;
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
@ -924,7 +917,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
@Override
public NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType) {
public NicVO savePlaceholderNic(Network network, String ip4Address, String ip6Address, Type vmType) {
// TODO Auto-generated method stub
return null;
}

View File

@ -1393,7 +1393,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
@Override
public NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType) {
public NicVO savePlaceholderNic(Network network, String ip4Address, String ip6Address, Type vmType) {
// TODO Auto-generated method stub
return null;
}

View File

@ -591,6 +591,8 @@ class TestVolumes(cloudstackTestCase):
if hosts[0].hypervisor == "XenServer":
self.virtual_machine.stop(self.apiClient)
elif hosts[0].hypervisor.lower() == "vmware":
self.skipTest("Resize Volume is unsupported on VmWare")
self.apiClient.resizeVolume(cmd)
count = 0
@ -638,6 +640,9 @@ class TestVolumes(cloudstackTestCase):
if hosts[0].hypervisor == "XenServer":
self.virtual_machine.stop(self.apiClient)
elif hosts[0].hypervisor.lower() == "vmware":
self.skipTest("Resize Volume is unsupported on VmWare")
self.debug("Resize Volume ID: %s" % self.volume.id)
cmd = resizeVolume.resizeVolumeCmd()

View File

@ -5388,9 +5388,9 @@
label: 'label.name',
validation: { required: true }
},
url: {
label: 'label.url',
validation: { required: false }
vcenter: {
label: 'vcenter',
validation: { required: true }
},
username: {
label: 'label.username',
@ -5406,14 +5406,10 @@
action: function(args) {
var data = {
zoneid: args.context.physicalResources[0].id,
name: args.data.name
};
name: args.data.name,
vcenter: args.data.vcenter
};
if(args.data.url != null && args.data.url.length > 0) {
$.extend(data, {
url: args.data.url
})
}
if(args.data.username != null && args.data.username.length > 0) {
$.extend(data, {
username: args.data.username

View File

@ -359,6 +359,8 @@
fields: {
name: { label: 'label.name' },
sourceipaddress: { label: 'Source IP Address' },
sourceport: { label: 'Source Port' },
instanceport: { label: 'Instance Port' },
algorithm: { label: 'label.algorithm' }
},
dataProvider: function(args) {
@ -369,8 +371,15 @@
},
success: function(json) {
var items = json.listloadbalancerssresponse.loadbalancer;
args.response.success({ data: items });
if(items != null) {
for(var i = 0; i < items.length; i++) {
var item = items[i];
//there is only one element in loadbalancerrul array property.
item.sourceport = item.loadbalancerrule[0].sourceport;
item.instanceport = item.loadbalancerrule[0].instanceport;
}
}
args.response.success({ data: items });
}
});
},
@ -642,7 +651,21 @@
listView: $.extend(true, {}, cloudStack.sections.instances.listView, {
type: 'checkbox',
filters: false,
dataProvider: function(args) {
dataProvider: function(args) {
var assignedInstances;
$.ajax({
url: createURL('listLoadBalancers'),
data: {
id: args.context.internalLoadBalancers[0].id
},
async: false,
success: function(json) {
assignedInstances = json.listloadbalancerssresponse.loadbalancer[0].loadbalancerinstance;
if(assignedInstances == null)
assignedInstances = [];
}
});
$.ajax({
url: createURL('listVirtualMachines'),
data: {
@ -654,11 +677,9 @@
// Pre-select existing instances in LB rule
$(instances).map(function(index, instance) {
instance._isSelected = $.grep(
args.context.internalLoadBalancers[0].loadbalancerinstance,
function(lbInstance) {
return lbInstance.id == instance.id;
instance._isSelected = $.grep(assignedInstances,
function(assignedInstance) {
return assignedInstance.id == instance.id;
}
).length ? true : false;
});
@ -667,7 +688,7 @@
var items = [];
if(instances != null) {
for(var i = 0; i < instances.length; i++) {
if(instances[i]._isSelected = true)
if(instances[i]._isSelected == true)
continue;
else
items.push(instances[i]);
@ -701,11 +722,7 @@
var jid = data.assigntoloadbalancerruleresponse.jobid;
args.response.success({
_custom: {
jobId: jid,
getUpdatedItem: function(json) {
$('.list-view').listView('refresh');
//return json.queryasyncjobresultresponse.jobresult.volume;
}
jobId: jid
}
});
}

View File

@ -3366,10 +3366,11 @@
zoneId: args.data.returnedZone.id,
username: args.data.cluster.vCenterUsername,
password: args.data.cluster.vCenterPassword,
name: args.data.cluster.vCenterDatacenter
name: args.data.cluster.vCenterDatacenter,
vcenter: args.data.cluster.vCenterHost
};
$.ajax({
url: createURL('addVmwareDc&url=' + todb(url)),
url: createURL('addVmwareDc'),
data: vmwareData,
success: function(json) {
var item = json.addvmwaredcresponse.vmwaredc;