From 96e83fe97fdd54db1dad0432b66ce3320984c300 Mon Sep 17 00:00:00 2001 From: alena Date: Thu, 17 Mar 2011 13:55:35 -0700 Subject: [PATCH] bug 8146: Elastic IP support in Basic zone. Following was done as a part of checkin: 1) NetworkOffering/Network: * add PF service support for default Guest network offering. * Add one more additional network - Public. * Allow to enable external firewall in Basic zone. 2) Don't allow to deployVm in Public Network. 3) Allow to add vlan ip ranges to Public networks in Basic zone. 4) Associate IP - allow to associate with Direct vms. 5) Allow to create PF/Static nat rules. Rules are being sent to External Firewall Rule only. 6) Add PF support to External Firewall element. --- .../api/commands/AssociateIPAddrCmd.java | 24 +++++++++--- .../com/cloud/api/commands/DeployVMCmd.java | 1 - .../UnsupportedServiceException.java | 28 ++++++++++++++ api/src/com/cloud/network/NetworkService.java | 3 ++ .../ConfigurationManagerImpl.java | 10 ++--- .../src/com/cloud/network/NetworkManager.java | 4 +- .../com/cloud/network/NetworkManagerImpl.java | 38 ++++++++++--------- .../cloud/network/element/DhcpElement.java | 4 +- .../cloud/network/guru/PublicNetworkGuru.java | 3 +- .../cloud/network/rules/RulesManagerImpl.java | 6 +-- .../cloud/server/ConfigurationServerImpl.java | 12 ++---- .../src/com/cloud/vm/UserVmManagerImpl.java | 6 +-- 12 files changed, 88 insertions(+), 51 deletions(-) create mode 100644 api/src/com/cloud/exception/UnsupportedServiceException.java diff --git a/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java b/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java index 5894e2aaf76..fe5a2838be1 100644 --- a/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java +++ b/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java @@ -30,6 +30,8 @@ import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; import com.cloud.api.response.IPAddressResponse; import com.cloud.async.AsyncJob; +import com.cloud.dc.DataCenter; +import com.cloud.dc.DataCenter.NetworkType; import com.cloud.event.EventTypes; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientAddressCapacityException; @@ -39,6 +41,7 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.IpAddress; import com.cloud.network.Network; +import com.cloud.network.Networks.TrafficType; import com.cloud.user.Account; import com.cloud.user.UserContext; @@ -91,12 +94,23 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { return networkId; } - List networks = _networkService.getVirtualNetworksOwnedByAccountInZone(getAccountName(), getDomainId(), getZoneId()); - if (networks.size() == 0) { - throw new InvalidParameterValueException("Account name=" + getAccountName() + " domainId=" + getDomainId() + " doesn't have virtual networks in zone " + getZoneId()); + DataCenter zone = _configService.getZone(getZoneId()); + if (zone.getNetworkType() == NetworkType.Advanced) { + List networks = _networkService.getVirtualNetworksOwnedByAccountInZone(getAccountName(), getDomainId(), getZoneId()); + if (networks.size() == 0) { + throw new InvalidParameterValueException("Account name=" + getAccountName() + " domainId=" + getDomainId() + " doesn't have virtual networks in zone " + getZoneId()); + } + assert (networks.size() <= 1) : "Too many virtual networks. This logic should be obsolete"; + return networks.get(0).getId(); + } else { + Network defaultGuestNetwork = _networkService.getSystemNetworkByZoneAndTrafficType(zone.getId(), TrafficType.Guest); + + if (defaultGuestNetwork == null) { + throw new InvalidParameterValueException("Unable to find a default Guest network for account " + getAccountName() + " in domain id=" + getDomainId()); + } else { + return defaultGuestNetwork.getId(); + } } - assert (networks.size() <= 1) : "Too many virtual networks. This logic should be obsolete"; - return networks.get(0).getId(); } @Override diff --git a/api/src/com/cloud/api/commands/DeployVMCmd.java b/api/src/com/cloud/api/commands/DeployVMCmd.java index c3733bb95b4..735eda8dd6a 100644 --- a/api/src/com/cloud/api/commands/DeployVMCmd.java +++ b/api/src/com/cloud/api/commands/DeployVMCmd.java @@ -38,7 +38,6 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; -import com.cloud.hypervisor.Hypervisor; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.offering.ServiceOffering; import com.cloud.template.VirtualMachineTemplate; diff --git a/api/src/com/cloud/exception/UnsupportedServiceException.java b/api/src/com/cloud/exception/UnsupportedServiceException.java new file mode 100644 index 00000000000..d6da7a11fae --- /dev/null +++ b/api/src/com/cloud/exception/UnsupportedServiceException.java @@ -0,0 +1,28 @@ +/** + * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. + * + * This software is licensed under the GNU General Public License v3 or later. + * + * It is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package com.cloud.exception; + +import com.cloud.utils.exception.CloudRuntimeException; + +public class UnsupportedServiceException extends CloudRuntimeException{ + + public UnsupportedServiceException(String message) { + super(message); + } +} diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java index d6c86f61c0f..f00d98149ee 100644 --- a/api/src/com/cloud/network/NetworkService.java +++ b/api/src/com/cloud/network/NetworkService.java @@ -34,6 +34,7 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.Network.Capability; import com.cloud.network.Network.Service; +import com.cloud.network.Networks.TrafficType; import com.cloud.offering.NetworkOffering; @@ -71,4 +72,6 @@ public interface NetworkService { Map> getNetworkCapabilities(long networkId); + Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType); + } diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index b2ae905059f..e1a0283eb20 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1168,7 +1168,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura } else if (offering.getTrafficType() == TrafficType.Control) { broadcastDomainType = BroadcastDomainType.LinkLocal; } else if (offering.getTrafficType() == TrafficType.Public) { - if (zone.getNetworkType() == NetworkType.Advanced && !zone.isSecurityGroupEnabled()) { + if ((zone.getNetworkType() == NetworkType.Advanced && !zone.isSecurityGroupEnabled()) || zone.getNetworkType() == NetworkType.Basic) { broadcastDomainType = BroadcastDomainType.Vlan; } else { continue; @@ -1741,12 +1741,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura //Allow adding untagged direct vlan only for Basic zone if (zone.getNetworkType() == NetworkType.Advanced && vlanId.equals(Vlan.UNTAGGED) && (!forVirtualNetwork || zone.isSecurityGroupEnabled())) { throw new InvalidParameterValueException("Direct untagged network is not supported for the zone " + zone.getId() + " of type " + zone.getNetworkType()); - } else if (zone.getNetworkType() == NetworkType.Basic && !(vlanId.equals(Vlan.UNTAGGED) && !forVirtualNetwork)) { - throw new InvalidParameterValueException("Only direct untagged network is supported in the zone " + zone.getId() + " of type " + zone.getNetworkType()); + } else if (zone.getNetworkType() == NetworkType.Basic && !((vlanId.equals(Vlan.UNTAGGED) && !forVirtualNetwork) || (!vlanId.equals(Vlan.UNTAGGED) && forVirtualNetwork))) { + throw new InvalidParameterValueException("Only Direct Untagged and Virtual networks are supported in the zone " + zone.getId() + " of type " + zone.getNetworkType()); } - //don't allow to create a virtual vlan when zone's vnet is NULL - if (zone.getVnet() == null && forVirtualNetwork) { + //don't allow to create a virtual vlan when zone's vnet is NULL in Advanced zone + if ((zone.getNetworkType() == NetworkType.Advanced && zone.getVnet() == null) && forVirtualNetwork) { throw new InvalidParameterValueException("Can't add virtual network to the zone id=" + zone.getId() + " as zone doesn't have guest vlan configured"); } diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java index a83217c05e3..84573f39956 100644 --- a/server/src/com/cloud/network/NetworkManager.java +++ b/server/src/com/cloud/network/NetworkManager.java @@ -126,8 +126,6 @@ public interface NetworkManager extends NetworkService { boolean applyRules(List rules, boolean continueOnError) throws ResourceUnavailableException; - NetworkVO getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType); - List getRemoteAccessVpnElements(); PublicIpAddress getPublicIpAddress(long ipAddressId); @@ -174,7 +172,7 @@ public interface NetworkManager extends NetworkService { void unassignPublicIpAddress(IPAddressVO addr); - Map getServiceCapability(long zoneId, Service service); + Map getServiceCapabilities(long zoneId, Service service); boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException; diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 7bf74dc7916..4815dc5f46b 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -80,6 +80,7 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.PermissionDeniedException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; +import com.cloud.exception.UnsupportedServiceException; import com.cloud.network.IpAddress.State; import com.cloud.network.Network.Capability; import com.cloud.network.Network.GuestIpType; @@ -450,6 +451,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag boolean success = true; for (NetworkElement element : _networkElements) { try { + s_logger.trace("Asking " + element + " to apply ip associations"); element.applyIps(network, publicIps); } catch (ResourceUnavailableException e) { success = false; @@ -693,8 +695,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag null, true, Availability.Required, - //services - all true except for firewall/lb/vpn and gateway services - true, true, true, false, false,false, false, GuestIpType.Direct); + //services - all true except for lb/vpn and gateway services + true, true, true, false, true,false, false, GuestIpType.Direct); guestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(guestNetworkOffering); _systemNetworks.put(NetworkOfferingVO.SystemGuestNetwork, guestNetworkOffering); @@ -1770,17 +1772,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag sb.and("removed", sb.entity().getRemoved(), Op.NULL); SearchCriteria sc = sb.create(); - - if (!isSystem) { - if (zoneId != null) { - DataCenterVO dc = _dcDao.findById(zoneId); - if (dc != null && !dc.isSecurityGroupEnabled()) { - sc.setJoinParameters("networkOfferingSearch", "systemOnly", false); - } - } - } else { - sc.setJoinParameters("networkOfferingSearch", "systemOnly", true); - sc.setJoinParameters("zoneSearch", "networkType", NetworkType.Advanced.toString()); + + if (isSystem != null) { + sc.setJoinParameters("networkOfferingSearch", "systemOnly", isSystem); } if (keyword != null) { @@ -2339,8 +2333,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } @Override - public Map getServiceCapability(long zoneId, Service service) { + public Map getServiceCapabilities(long zoneId, Service service) { Map> networkCapabilities = getZoneCapabilities(zoneId); + if (networkCapabilities.get(service) == null) { + throw new UnsupportedServiceException("Service " + service.getName() + " is not supported in zone id=" + zoneId); + } + return networkCapabilities.get(service); } @@ -2549,9 +2547,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override public boolean zoneIsConfiguredForExternalNetworking(long zoneId) { DataCenterVO zone = _dcDao.findById(zoneId); - - return (zone.getGatewayProvider() != null && zone.getGatewayProvider().equals(Network.Provider.JuniperSRX.getName()) && zone.getFirewallProvider().equals(Network.Provider.JuniperSRX.getName()) && zone.getLoadBalancerProvider().equals( - Network.Provider.F5BigIp.getName())); + + if (zone.getNetworkType() == NetworkType.Advanced) { + return (zone.getGatewayProvider() != null && zone.getGatewayProvider().equals(Network.Provider.JuniperSRX.getName()) + && zone.getFirewallProvider() != null && zone.getFirewallProvider().equals(Network.Provider.JuniperSRX.getName()) + && zone.getLoadBalancerProvider() != null && zone.getLoadBalancerProvider().equals( + Network.Provider.F5BigIp.getName())); + } else { + return (zone.getFirewallProvider() != null && zone.getFirewallProvider().equals(Network.Provider.JuniperSRX.getName())); + } } diff --git a/server/src/com/cloud/network/element/DhcpElement.java b/server/src/com/cloud/network/element/DhcpElement.java index 18c7c41bcf8..1a3f649cc27 100644 --- a/server/src/com/cloud/network/element/DhcpElement.java +++ b/server/src/com/cloud/network/element/DhcpElement.java @@ -28,7 +28,6 @@ import org.apache.log4j.Logger; import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter.NetworkType; -import com.cloud.dc.HostPodVO; import com.cloud.dc.dao.HostPodDao; import com.cloud.deploy.DeployDestination; import com.cloud.exception.ConcurrentOperationException; @@ -51,7 +50,6 @@ import com.cloud.offering.NetworkOffering; import com.cloud.uservm.UserVm; import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.Inject; -import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.vm.DomainRouterVO; import com.cloud.vm.NicProfile; import com.cloud.vm.ReservationContext; @@ -84,7 +82,7 @@ public class DhcpElement extends AdapterBase implements NetworkElement, Password if (provider != null && provider.equalsIgnoreCase(Provider.JuniperSRX.getName()) && ipType == GuestIpType.Virtual) { return true; - } else if (dest.getPod().getExternalDhcp()){ + } else if (dest.getPod() != null && dest.getPod().getExternalDhcp()){ //This pod is using external DHCP server return false; } else { diff --git a/server/src/com/cloud/network/guru/PublicNetworkGuru.java b/server/src/com/cloud/network/guru/PublicNetworkGuru.java index 3ab3b6103f8..c9b44dbdb0e 100644 --- a/server/src/com/cloud/network/guru/PublicNetworkGuru.java +++ b/server/src/com/cloud/network/guru/PublicNetworkGuru.java @@ -19,7 +19,6 @@ import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.InsufficientVirtualNetworkCapcityException; import com.cloud.network.IPAddressVO; import com.cloud.network.Network; -import com.cloud.network.Network.GuestIpType; import com.cloud.network.Network.State; import com.cloud.network.NetworkManager; import com.cloud.network.NetworkProfile; @@ -54,7 +53,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru { protected boolean canHandle(NetworkOffering offering, DataCenter dc) { - if (dc.getNetworkType() == NetworkType.Advanced && offering.getTrafficType() == TrafficType.Public && offering.isSystemOnly() && !dc.isSecurityGroupEnabled()) { + if (((dc.getNetworkType() == NetworkType.Advanced && !dc.isSecurityGroupEnabled()) || dc.getNetworkType() == NetworkType.Basic) && offering.getTrafficType() == TrafficType.Public && offering.isSystemOnly()) { return true; } else { s_logger.trace("We only take care of System only Public Virtual Network"); diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java index d37e24050c7..980a3bb5cb4 100644 --- a/server/src/com/cloud/network/rules/RulesManagerImpl.java +++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java @@ -220,8 +220,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager { } //Verify that the network guru supports the protocol specified - Map firewallCapability = _networkMgr.getServiceCapability(network.getDataCenterId(), Service.Firewall); - String supportedProtocols = firewallCapability.get(Capability.SupportedProtocols).toLowerCase(); + Map firewallCapabilities = _networkMgr.getServiceCapabilities(network.getDataCenterId(), Service.Firewall); + String supportedProtocols = firewallCapabilities.get(Capability.SupportedProtocols).toLowerCase(); if (!supportedProtocols.contains(rule.getProtocol().toLowerCase())) { throw new InvalidParameterValueException("Protocol " + rule.getProtocol() + " is not supported in zone " + network.getDataCenterId()); } @@ -330,7 +330,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager { } //Verify that the network guru supports the protocol specified - Map firewallCapability = _networkMgr.getServiceCapability(network.getDataCenterId(), Service.Firewall); + Map firewallCapability = _networkMgr.getServiceCapabilities(network.getDataCenterId(), Service.Firewall); String supportedProtocols = firewallCapability.get(Capability.SupportedProtocols).toLowerCase(); if (!supportedProtocols.contains(rule.getProtocol().toLowerCase())) { throw new InvalidParameterValueException("Protocol " + rule.getProtocol() + " is not supported in zone " + network.getDataCenterId()); diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index abcad1be28d..092ba7057f6 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -63,7 +63,6 @@ import com.cloud.network.NetworkVO; import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.dao.IPAddressDao; import com.cloud.network.dao.NetworkDao; import com.cloud.network.guru.ControlNetworkGuru; import com.cloud.network.guru.DirectPodBasedNetworkGuru; @@ -77,7 +76,6 @@ import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.dao.DiskOfferingDao; -import com.cloud.storage.dao.SnapshotPolicyDao; import com.cloud.test.IPRangeConfig; import com.cloud.user.Account; import com.cloud.user.User; @@ -94,7 +92,6 @@ public class ConfigurationServerImpl implements ConfigurationServer { public static final Logger s_logger = Logger.getLogger(ConfigurationServerImpl.class.getName()); private final ConfigurationDao _configDao; - private final SnapshotPolicyDao _snapPolicyDao; private final DataCenterDao _zoneDao; private final HostPodDao _podDao; private final DiskOfferingDao _diskOfferingDao; @@ -104,13 +101,11 @@ public class ConfigurationServerImpl implements ConfigurationServer { private final DataCenterDao _dataCenterDao; private final NetworkDao _networkDao; private final VlanDao _vlanDao; - private final IPAddressDao _ipAddressDao; public ConfigurationServerImpl() { ComponentLocator locator = ComponentLocator.getLocator(Name); _configDao = locator.getDao(ConfigurationDao.class); - _snapPolicyDao = locator.getDao(SnapshotPolicyDao.class); _zoneDao = locator.getDao(DataCenterDao.class); _podDao = locator.getDao(HostPodDao.class); _diskOfferingDao = locator.getDao(DiskOfferingDao.class); @@ -120,7 +115,6 @@ public class ConfigurationServerImpl implements ConfigurationServer { _dataCenterDao = locator.getDao(DataCenterDao.class); _networkDao = locator.getDao(NetworkDao.class); _vlanDao = locator.getDao(VlanDao.class); - _ipAddressDao = locator.getDao(IPAddressDao.class); } @Override @DB @@ -730,8 +724,8 @@ public class ConfigurationServerImpl implements ConfigurationServer { TrafficType.Guest, true, false, null, null, null, true, Availability.Required, - true, true, true, //services - all true except for firewall/lb/vpn and gateway - false, false, false, false, GuestIpType.Direct); + true, true, true, //services - all true except for lb/vpn and gateway + false, true, false, false, GuestIpType.Direct); guestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(guestNetworkOffering); @@ -800,7 +794,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { } else if (trafficType == TrafficType.Control) { broadcastDomainType = BroadcastDomainType.LinkLocal; } else if (offering.getTrafficType() == TrafficType.Public) { - if (zone.getNetworkType() == NetworkType.Advanced) { + if ((zone.getNetworkType() == NetworkType.Advanced && !zone.isSecurityGroupEnabled()) || zone.getNetworkType() == NetworkType.Basic) { broadcastDomainType = BroadcastDomainType.Vlan; } else { continue; diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index afdd02b061e..02d1fdb8e11 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -127,6 +127,7 @@ import com.cloud.offering.NetworkOffering.Availability; import com.cloud.offering.ServiceOffering; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; +import com.cloud.org.Cluster; import com.cloud.server.Criteria; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; @@ -199,7 +200,6 @@ import com.cloud.vm.dao.InstanceGroupVMMapDao; import com.cloud.vm.dao.NicDao; import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.UserVmDetailsDao; -import com.cloud.org.Cluster; @Local(value={UserVmManager.class, UserVmService.class}) public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager { @@ -1894,12 +1894,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager _accountMgr.checkAccess(caller, owner); //Get default guest network in Basic zone - NetworkVO defaultNetwork = _networkMgr.getSystemNetworkByZoneAndTrafficType(zone.getId(), TrafficType.Guest); + Network defaultNetwork = _networkMgr.getSystemNetworkByZoneAndTrafficType(zone.getId(), TrafficType.Guest); if (defaultNetwork == null) { throw new InvalidParameterValueException("Unable to find a default network to start a vm"); } else { - networkList.add(defaultNetwork); + networkList.add(_networkDao.findById(defaultNetwork.getId())); } return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, caller, diskOfferingId,