diff --git a/api/src/com/cloud/network/NetworkConfiguration.java b/api/src/com/cloud/network/NetworkConfiguration.java
index 8ef4de71b5a..d0e7c7da512 100644
--- a/api/src/com/cloud/network/NetworkConfiguration.java
+++ b/api/src/com/cloud/network/NetworkConfiguration.java
@@ -11,6 +11,7 @@ import com.cloud.acl.ControlledEntity;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
+import com.cloud.offering.NetworkOffering.GuestIpType;
import com.cloud.utils.fsm.FiniteState;
import com.cloud.utils.fsm.StateMachine;
@@ -98,4 +99,6 @@ public interface NetworkConfiguration extends ControlledEntity {
String getDns1();
String getDns2();
+
+ GuestIpType getGuestType();
}
diff --git a/api/src/com/cloud/offering/NetworkOffering.java b/api/src/com/cloud/offering/NetworkOffering.java
index 3d098f0069e..5441625f9b9 100644
--- a/api/src/com/cloud/offering/NetworkOffering.java
+++ b/api/src/com/cloud/offering/NetworkOffering.java
@@ -30,6 +30,10 @@ public interface NetworkOffering {
DirectSingle,
DirectDual
}
+
+ public final String DefaultVirtualizedNetworkOffering = "DefaultVirtualizedNetworkOffering";
+ public final String DefaultDirectNetworkOffering = "DefaultDirectNetworkOffering";
+ public final String DefaultDirectChooseVlanNetworkOffering = "DefaultDirectChooseVlanNetworkOffering";
long getId();
@@ -64,4 +68,6 @@ public interface NetworkOffering {
Integer getConcurrentConnections();
TrafficType getTrafficType();
+
+ boolean getSpecifyVlan();
}
diff --git a/api/src/com/cloud/uservm/UserVm.java b/api/src/com/cloud/uservm/UserVm.java
index 0709baec361..b9589752d7f 100755
--- a/api/src/com/cloud/uservm/UserVm.java
+++ b/api/src/com/cloud/uservm/UserVm.java
@@ -17,24 +17,24 @@
*/
package com.cloud.uservm;
-import com.cloud.domain.PartOf;
-import com.cloud.user.OwnedBy;
+import com.cloud.acl.ControlledEntity;
import com.cloud.vm.VirtualMachine;
/**
* This represents one running virtual machine instance.
*/
-public interface UserVm extends VirtualMachine, OwnedBy, PartOf {
+public interface UserVm extends VirtualMachine, ControlledEntity {
/**
* @return service offering id
*/
+ @Override
long getServiceOfferingId();
/**
* @return the domain router associated with this vm.
- */
Long getDomainRouterId();
+ */
/**
* @return the vnet associated with this vm.
@@ -44,6 +44,7 @@ public interface UserVm extends VirtualMachine, OwnedBy, PartOf {
/**
* @return the domain this vm instance belongs to.
*/
+ @Override
long getDomainId();
/**
@@ -62,5 +63,9 @@ public interface UserVm extends VirtualMachine, OwnedBy, PartOf {
String getUserData();
+ String getPassword();
+
+ Long getDomainRouterId();
+
void setUserData(String userData);
}
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 0e83aeb4390..1af383f7c13 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -33,11 +33,11 @@ updateResourceLimit=com.cloud.api.commands.UpdateResourceLimitCmd;3
listResourceLimits=com.cloud.api.commands.ListResourceLimitsCmd;15
#### VM commands
-deployVirtualMachine=com.cloud.api.commands.DeployVMCmd;11
+deployVirtualMachine=com.cloud.api.commands.DeployVm2Cmd;11
destroyVirtualMachine=com.cloud.api.commands.DestroyVMCmd;15
rebootVirtualMachine=com.cloud.api.commands.RebootVMCmd;15
-startVirtualMachine=com.cloud.api.commands.StartVMCmd;15
-stopVirtualMachine=com.cloud.api.commands.StopVMCmd;15
+startVirtualMachine=com.cloud.api.commands.StartVm2Cmd;15
+stopVirtualMachine=com.cloud.api.commands.StopVm2Cmd;15
resetPasswordForVirtualMachine=com.cloud.api.commands.ResetVMPasswordCmd;15
changeServiceForVirtualMachine=com.cloud.api.commands.UpgradeVMCmd;15
updateVirtualMachine=com.cloud.api.commands.UpdateVMCmd;15
diff --git a/core/src/com/cloud/dc/dao/DataCenterIpAddressDao.java b/core/src/com/cloud/dc/dao/DataCenterIpAddressDao.java
new file mode 100644
index 00000000000..10a6bc8034c
--- /dev/null
+++ b/core/src/com/cloud/dc/dao/DataCenterIpAddressDao.java
@@ -0,0 +1,31 @@
+/**
+ * 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.dc.dao;
+
+import java.util.List;
+
+import com.cloud.dc.DataCenterIpAddressVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface DataCenterIpAddressDao extends GenericDao {
+ boolean mark(long dcId, long podId, String ip);
+ List listByPodIdDcIdIpAddress(long podId, long dcId, String ipAddress);
+ int countIPs(long podId, long dcId, boolean onlyCountAllocated);
+ boolean deleteIpAddressByPod(long podId);
+
+}
diff --git a/core/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java b/core/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java
index e08fac697e6..d8d22abe25f 100755
--- a/core/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java
+++ b/core/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java
@@ -27,7 +27,6 @@ import javax.ejb.Local;
import org.apache.log4j.Logger;
import com.cloud.dc.DataCenterIpAddressVO;
-import com.cloud.utils.db.GenericDao;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
@@ -35,8 +34,8 @@ import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
-@Local(value={DataCenterIpAddressDaoImpl.class})
-public class DataCenterIpAddressDaoImpl extends GenericDaoBase implements GenericDao {
+@Local(value={DataCenterIpAddressDao.class})
+public class DataCenterIpAddressDaoImpl extends GenericDaoBase implements DataCenterIpAddressDao {
private static final Logger s_logger = Logger.getLogger(DataCenterIpAddressDaoImpl.class);
private static final String COUNT_ALL_PRIVATE_IPS = "SELECT count(*) from `cloud`.`op_dc_ip_address_alloc` where pod_id = ? AND data_center_id = ?";
diff --git a/core/src/com/cloud/offerings/NetworkOfferingVO.java b/core/src/com/cloud/offerings/NetworkOfferingVO.java
index e4a034c3a80..adef5307aee 100644
--- a/core/src/com/cloud/offerings/NetworkOfferingVO.java
+++ b/core/src/com/cloud/offerings/NetworkOfferingVO.java
@@ -36,11 +36,10 @@ import com.cloud.utils.db.GenericDao;
@Entity
@Table(name="network_offerings")
public class NetworkOfferingVO implements NetworkOffering {
- public final static String SystemVmPublicNetwork = "System-Vm-Public-Network";
- public final static String SystemVmGuestNetwork = "System-Vm-Guest-Network";
- public final static String SystemVmControlNetwork = "System-Vm-Control-Network";
- public final static String SystemVmManagementNetwork = "System-Vm-Management-Network";
- public final static String SystemVmStorageNetwork = "System-Vm-Storage-Network";
+ public final static String SystemVmPublicNetwork = "System-Public-Network";
+ public final static String SystemVmControlNetwork = "System-Control-Network";
+ public final static String SystemVmManagementNetwork = "System-Management-Network";
+ public final static String SystemVmStorageNetwork = "System-Storage-Network";
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@@ -70,6 +69,9 @@ public class NetworkOfferingVO implements NetworkOffering {
@Enumerated(value=EnumType.STRING)
TrafficType trafficType;
+ @Column(name="specify_vlan")
+ boolean specifyVlan;
+
@Column(name="system_only")
boolean systemOnly;
@@ -195,12 +197,17 @@ public class NetworkOfferingVO implements NetworkOffering {
public void setRemoved(Date removed) {
this.removed = removed;
}
+
+ @Override
+ public boolean getSpecifyVlan() {
+ return specifyVlan;
+ }
public void setCreated(Date created) {
this.created = created;
}
- public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, GuestIpType type, boolean systemOnly, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections) {
+ public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, GuestIpType type, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections) {
this.name = name;
this.displayText = displayText;
this.guestIpType = type;
@@ -209,10 +216,11 @@ public class NetworkOfferingVO implements NetworkOffering {
this.concurrentConnections = concurrentConnections;
this.trafficType = trafficType;
this.systemOnly = systemOnly;
+ this.specifyVlan = specifyVlan;
}
public NetworkOfferingVO(ServiceOfferingVO offering) {
- this("Network Offering for " + offering.getName(), "Network Offering for " + offering.getDisplayText(), TrafficType.Guest, offering.getGuestIpType(), false, offering.getRateMbps(), offering.getMulticastRateMbps(), null);
+ this("Network Offering for " + offering.getName(), "Network Offering for " + offering.getDisplayText(), TrafficType.Guest, offering.getGuestIpType(), false, false, offering.getRateMbps(), offering.getMulticastRateMbps(), null);
this.serviceOfferingId = offering.getId();
}
@@ -223,7 +231,7 @@ public class NetworkOfferingVO implements NetworkOffering {
* @param type
*/
public NetworkOfferingVO(String name, TrafficType trafficType, GuestIpType type) {
- this(name, "System Offering for " + name, trafficType, type, true, null, null, null);
+ this(name, "System Offering for " + name, trafficType, type, true, false, null, null, null);
}
@Override
diff --git a/core/src/com/cloud/vm/UserVmVO.java b/core/src/com/cloud/vm/UserVmVO.java
index d02b3ed0d0f..cfefc454fd6 100755
--- a/core/src/com/cloud/vm/UserVmVO.java
+++ b/core/src/com/cloud/vm/UserVmVO.java
@@ -63,7 +63,17 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
@Column(name="display_name", updatable=true, nullable=true)
private String displayName;
+
+ transient String password;
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
@Override
public String getGuestIpAddress() {
return guestIpAddress;
diff --git a/server/src/com/cloud/acl/DomainChecker.java b/server/src/com/cloud/acl/DomainChecker.java
index b1872252299..f8e989e8d3f 100644
--- a/server/src/com/cloud/acl/DomainChecker.java
+++ b/server/src/com/cloud/acl/DomainChecker.java
@@ -32,7 +32,7 @@ import com.cloud.user.dao.AccountDao;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.Inject;
-@Local(value=DomainChecker.class)
+@Local(value=SecurityChecker.class)
public class DomainChecker extends AdapterBase implements SecurityChecker {
@Inject DomainDao _domainDao;
diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java
index 2a2ab8e69bd..8833a098705 100755
--- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -91,7 +91,7 @@ import com.cloud.dc.Pod;
import com.cloud.dc.PodCluster;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
+import com.cloud.dc.dao.DataCenterIpAddressDao;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.event.dao.EventDao;
@@ -188,9 +188,9 @@ import com.cloud.vm.dao.VMInstanceDao;
public class AgentManagerImpl implements AgentManager, HandlerFactory {
private static final Logger s_logger = Logger.getLogger(AgentManagerImpl.class);
- protected ConcurrentHashMap _agents = new ConcurrentHashMap(2047);
- protected List> _hostMonitors = new ArrayList>(11);
- protected List> _cmdMonitors = new ArrayList>(11);
+ protected ConcurrentHashMap _agents = new ConcurrentHashMap(10007);
+ protected List> _hostMonitors = new ArrayList>(17);
+ protected List> _cmdMonitors = new ArrayList>(17);
protected int _monitorId = 0;
protected NioServer _connection;
@@ -198,7 +198,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
@Inject protected UserStatisticsDao _userStatsDao = null;
@Inject protected DataCenterDao _dcDao = null;
@Inject protected VlanDao _vlanDao = null;
- @Inject protected DataCenterIpAddressDaoImpl _privateIPAddressDao = null;
+ @Inject protected DataCenterIpAddressDao _privateIPAddressDao = null;
@Inject protected IPAddressDao _publicIPAddressDao = null;
@Inject protected HostPodDao _podDao = null;
protected Adapters _hostAllocators = null;
diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java
index 4b98dd5cdb6..efcca92145e 100644
--- a/server/src/com/cloud/alert/AlertManagerImpl.java
+++ b/server/src/com/cloud/alert/AlertManagerImpl.java
@@ -48,7 +48,7 @@ import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
+import com.cloud.dc.dao.DataCenterIpAddressDao;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
@@ -105,7 +105,7 @@ public class AlertManagerImpl implements AlertManager {
@Inject private HostPodDao _podDao;
@Inject private VolumeDao _volumeDao;
@Inject private IPAddressDao _publicIPAddressDao;
- @Inject private DataCenterIpAddressDaoImpl _privateIPAddressDao;
+ @Inject private DataCenterIpAddressDao _privateIPAddressDao;
@Inject private StoragePoolDao _storagePoolDao;
private Timer _timer = null;
diff --git a/server/src/com/cloud/api/commands/StopVm2Cmd.java b/server/src/com/cloud/api/commands/StopVm2Cmd.java
new file mode 100644
index 00000000000..08eadd580c4
--- /dev/null
+++ b/server/src/com/cloud/api/commands/StopVm2Cmd.java
@@ -0,0 +1,95 @@
+/**
+ * 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.api.commands;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.api.ApiConstants;
+import com.cloud.api.ApiDBUtils;
+import com.cloud.api.ApiResponseHelper;
+import com.cloud.api.BaseAsyncCmd;
+import com.cloud.api.Implementation;
+import com.cloud.api.Parameter;
+import com.cloud.api.response.UserVmResponse;
+import com.cloud.event.EventTypes;
+import com.cloud.user.Account;
+import com.cloud.uservm.UserVm;
+import com.cloud.vm.UserVmService;
+
+@Implementation(method="stopVirtualMachine", manager=UserVmService.class, description="Stops a virtual machine.")
+public class StopVm2Cmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(StopVMCmd.class.getName());
+
+ private static final String s_name = "stopvirtualmachineresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
+ private Long id;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getName() {
+ return s_name;
+ }
+
+ public static String getResultObjectName() {
+ return "virtualmachine";
+ }
+
+ @Override
+ public long getAccountId() {
+ UserVm vm = ApiDBUtils.findUserVmById(getId());
+ if (vm != null) {
+ return vm.getAccountId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_VM_STOP;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "stopping user vm: " + getId();
+ }
+
+ @Override @SuppressWarnings("unchecked")
+ public UserVmResponse getResponse() {
+ UserVm userVm = (UserVm)getResponseObject();
+ UserVmResponse recoverVmResponse = ApiResponseHelper.createUserVmResponse(userVm);
+ recoverVmResponse.setResponseName(getName());
+ return recoverVmResponse;
+ }
+}
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 178e35a6df2..aac282a2904 100644
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -59,7 +59,7 @@ import com.cloud.dc.Vlan.VlanType;
import com.cloud.dc.VlanVO;
import com.cloud.dc.dao.AccountVlanMapDao;
import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
+import com.cloud.dc.dao.DataCenterIpAddressDao;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.dc.dao.PodVlanMapDao;
import com.cloud.dc.dao.VlanDao;
@@ -124,7 +124,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
@Inject DiskOfferingDao _diskOfferingDao;
@Inject VlanDao _vlanDao;
@Inject IPAddressDao _publicIpAddressDao;
- @Inject DataCenterIpAddressDaoImpl _privateIpAddressDao;
+ @Inject DataCenterIpAddressDao _privateIpAddressDao;
@Inject VMInstanceDao _vmInstanceDao;
@Inject AccountDao _accountDao;
@Inject EventDao _eventDao;
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index d23595e6460..bfdf6241c80 100644
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -531,7 +531,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
@Override
public ConsoleProxyVO startProxy(long proxyVmId, long startEventId) {
try {
- return start(proxyVmId, startEventId);
+ return start2(proxyVmId, startEventId);
} catch (StorageUnavailableException e) {
s_logger.warn("Exception while trying to start console proxy", e);
return null;
@@ -887,7 +887,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
if (s_logger.isDebugEnabled())
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
- Map context = createProxyInstance(dataCenterId);
+ Map context = createProxyInstance2(dataCenterId);
long proxyVmId = (Long) context.get("proxyVmId");
if (proxyVmId == 0) {
@@ -927,7 +927,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
if (s_logger.isDebugEnabled())
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
- Map context = createProxyInstance(dataCenterId);
+ Map context = createProxyInstance2(dataCenterId);
long proxyVmId = (Long) context.get("proxyVmId");
if (proxyVmId == 0) {
@@ -1468,7 +1468,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
try {
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
try {
- readyProxy = start(readyProxy.getId(), 0);
+ readyProxy = start2(readyProxy.getId(), 0);
} finally {
proxyLock.unlock();
}
diff --git a/server/src/com/cloud/network/NetworkConfigurationVO.java b/server/src/com/cloud/network/NetworkConfigurationVO.java
index f55058c7a7a..53754b510df 100644
--- a/server/src/com/cloud/network/NetworkConfigurationVO.java
+++ b/server/src/com/cloud/network/NetworkConfigurationVO.java
@@ -31,6 +31,7 @@ import javax.persistence.Transient;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
+import com.cloud.offering.NetworkOffering.GuestIpType;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.net.NetUtils;
@@ -58,6 +59,9 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
@Enumerated(value=EnumType.STRING)
TrafficType trafficType;
+ @Column(name="guest_type")
+ GuestIpType guestType;
+
@Column(name="broadcast_uri")
URI broadcastUri;
@@ -116,7 +120,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
* @param networkOfferingId
* @param dataCenterId
*/
- public NetworkConfigurationVO(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId) {
+ public NetworkConfigurationVO(TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId) {
this.trafficType = trafficType;
this.mode = mode;
this.broadcastDomainType = broadcastDomainType;
@@ -124,10 +128,11 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
this.dataCenterId = dataCenterId;
this.state = State.Allocated;
this.id = -1;
+ this.guestType = guestType;
}
public NetworkConfigurationVO(long id, NetworkConfiguration that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related) {
- this(id, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related);
+ this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related);
this.gateway = that.getGateway();
this.dns1 = that.getDns1();
this.dns2 = that.getDns2();
@@ -149,8 +154,8 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
* @param domainId
* @param accountId
*/
- public NetworkConfigurationVO(long id, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related) {
- this(trafficType, mode, broadcastDomainType, networkOfferingId, dataCenterId);
+ public NetworkConfigurationVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related) {
+ this(trafficType, guestType, mode, broadcastDomainType, networkOfferingId, dataCenterId);
this.domainId = domainId;
this.accountId = accountId;
this.related = related;
@@ -175,6 +180,11 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
public long getId() {
return id;
}
+
+ @Override
+ public GuestIpType getGuestType() {
+ return guestType;
+ }
@Override
public Mode getMode() {
diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java
index 1ae58d8455c..8ec90a09430 100644
--- a/server/src/com/cloud/network/NetworkManager.java
+++ b/server/src/com/cloud/network/NetworkManager.java
@@ -59,7 +59,6 @@ import com.cloud.service.ServiceOfferingVO;
import com.cloud.user.Account;
import com.cloud.user.AccountVO;
import com.cloud.utils.Pair;
-import com.cloud.utils.component.Manager;
import com.cloud.vm.DomainRouter;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.NicProfile;
@@ -73,7 +72,7 @@ import com.cloud.vm.VirtualMachineProfile;
* NetworkManager manages the network for the different end users.
*
*/
-public interface NetworkManager extends Manager {
+public interface NetworkManager {
public static final int DEFAULT_ROUTER_VM_RAMSIZE = 128; // 128M
public static final boolean USE_POD_VLAN = false;
/**
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index afd3a8f73f6..d825e2ec207 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -66,6 +66,7 @@ import com.cloud.api.commands.UpdateLoadBalancerRuleCmd;
import com.cloud.api.commands.UpgradeRouterCmd;
import com.cloud.async.AsyncJobManager;
import com.cloud.capacity.dao.CapacityDao;
+import com.cloud.configuration.Config;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.ResourceCount.ResourceType;
import com.cloud.configuration.dao.ConfigurationDao;
@@ -144,6 +145,7 @@ import com.cloud.utils.StringUtils;
import com.cloud.utils.Ternary;
import com.cloud.utils.component.Adapters;
import com.cloud.utils.component.Inject;
+import com.cloud.utils.component.Manager;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.JoinBuilder;
import com.cloud.utils.db.JoinBuilder.JoinType;
@@ -167,8 +169,8 @@ import com.cloud.vm.dao.UserVmDao;
/**
* NetworkManagerImpl implements NetworkManager.
*/
-@Local(value={NetworkManager.class, DomainRouterService.class})
-public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
+@Local(value={NetworkManager.class, NetworkService.class})
+public class NetworkManagerImpl implements NetworkManager, NetworkService, Manager {
private static final Logger s_logger = Logger.getLogger(NetworkManagerImpl.class);
String _name;
@@ -1670,22 +1672,39 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
_name = name;
final Map configs = _configDao.getConfiguration("AgentManager", params);
-
+
+ String value = configs.get(Config.NetworkThrottlingRate.key());
+ Integer rateMbps = null;
+ if (value != null) {
+ rateMbps = Integer.parseInt(value);
+ }
+
+ Integer multicastRateMbps = null;
+ value = configs.get(Config.MulticastThrottlingRate.key());
+ if (value != null) {
+ multicastRateMbps = Integer.parseInt(value);
+ }
+
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmPublicNetwork, TrafficType.Public, null);
- publicNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(publicNetworkOffering);
+ publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
_systemNetworks.put(NetworkOfferingVO.SystemVmPublicNetwork, publicNetworkOffering);
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmManagementNetwork, TrafficType.Management, null);
- managementNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(managementNetworkOffering);
+ managementNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(managementNetworkOffering);
_systemNetworks.put(NetworkOfferingVO.SystemVmManagementNetwork, managementNetworkOffering);
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmControlNetwork, TrafficType.Control, null);
- controlNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(controlNetworkOffering);
+ controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering);
_systemNetworks.put(NetworkOfferingVO.SystemVmControlNetwork, controlNetworkOffering);
- NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmGuestNetwork, TrafficType.Guest, GuestIpType.Virtualized);
- guestNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(guestNetworkOffering);
- _systemNetworks.put(NetworkOfferingVO.SystemVmGuestNetwork, guestNetworkOffering);
+// NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmGuestNetwork, TrafficType.Guest, GuestIpType.Virtualized);
+// guestNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(guestNetworkOffering);
+// _systemNetworks.put(NetworkOfferingVO.SystemVmGuestNetwork, guestNetworkOffering);
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmStorageNetwork, TrafficType.Storage, null);
- storageNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(storageNetworkOffering);
- _systemNetworks.put(NetworkOfferingVO.SystemVmGuestNetwork, storageNetworkOffering);
+ storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
+ _systemNetworks.put(NetworkOfferingVO.SystemVmStorageNetwork, storageNetworkOffering);
+
+ NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtualized, false, false, rateMbps, multicastRateMbps, null);
+ defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering);
+ NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, GuestIpType.DirectSingle, false, false, rateMbps, multicastRateMbps, null);
+ defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering);
AccountsUsingNetworkConfigurationSearch = _accountDao.createSearchBuilder();
SearchBuilder networkAccountSearch = _networkConfigDao.createSearchBuilderForAccount();
@@ -1909,6 +1928,14 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
vo.setNetmask(profile.getNetmask());
vo.setGateway(profile.getGateway());
+ if (profile.getBroadCastUri() != null) {
+ vo.setBroadcastUri(profile.getBroadCastUri());
+ }
+
+ if (profile.getIsolationUri() != null) {
+ vo.setIsolationUri(profile.getIsolationUri());
+ }
+
return deviceId;
}
@@ -2898,6 +2925,9 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
}
}
-
+ @Override
+ public List listNetworkOfferings() {
+ return _networkOfferingDao.listNonSystemNetworkOfferings();
+ }
}
diff --git a/server/src/com/cloud/network/NetworkService.java b/server/src/com/cloud/network/NetworkService.java
new file mode 100644
index 00000000000..d97576ba582
--- /dev/null
+++ b/server/src/com/cloud/network/NetworkService.java
@@ -0,0 +1,27 @@
+/**
+ * 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.network;
+
+import java.util.List;
+
+import com.cloud.offering.NetworkOffering;
+
+
+public interface NetworkService {
+ List extends NetworkOffering> listNetworkOfferings();
+}
diff --git a/server/src/com/cloud/network/configuration/ControlNetworkGuru.java b/server/src/com/cloud/network/configuration/ControlNetworkGuru.java
index 46cd1043e0a..319480737c7 100644
--- a/server/src/com/cloud/network/configuration/ControlNetworkGuru.java
+++ b/server/src/com/cloud/network/configuration/ControlNetworkGuru.java
@@ -49,7 +49,7 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru {
return null;
}
- NetworkConfigurationVO config = new NetworkConfigurationVO(offering.getTrafficType(), Mode.Static, BroadcastDomainType.LinkLocal, offering.getId(), plan.getDataCenterId());
+ NetworkConfigurationVO config = new NetworkConfigurationVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.LinkLocal, offering.getId(), plan.getDataCenterId());
config.setCidr(_cidr);
config.setGateway(_gateway);
diff --git a/server/src/com/cloud/network/configuration/GuestNetworkGuru.java b/server/src/com/cloud/network/configuration/GuestNetworkGuru.java
index 1c5d925b439..1323517176c 100644
--- a/server/src/com/cloud/network/configuration/GuestNetworkGuru.java
+++ b/server/src/com/cloud/network/configuration/GuestNetworkGuru.java
@@ -72,7 +72,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
}
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
- NetworkConfigurationVO config = new NetworkConfigurationVO(offering.getTrafficType(), mode, broadcastType, offering.getId(), plan.getDataCenterId());
+ NetworkConfigurationVO config = new NetworkConfigurationVO(offering.getTrafficType(), offering.getGuestIpType(), mode, broadcastType, offering.getId(), plan.getDataCenterId());
if (userSpecified != null) {
if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) ||
(userSpecified.getCidr() != null && userSpecified.getGateway() == null)) {
@@ -116,7 +116,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
assert (config.getState() == State.Allocated) : "Why implement are we implementing " + config;
long dcId = dest.getDataCenter().getId();
- NetworkConfigurationVO implemented = new NetworkConfigurationVO(config.getTrafficType(), config.getMode(), config.getBroadcastDomainType(), config.getNetworkOfferingId(), config.getDataCenterId());
+ NetworkConfigurationVO implemented = new NetworkConfigurationVO(config.getTrafficType(), config.getGuestType(), config.getMode(), config.getBroadcastDomainType(), config.getNetworkOfferingId(), config.getDataCenterId());
if (config.getBroadcastUri() == null) {
String vnet = _dcDao.allocateVnet(dcId, config.getAccountId());
diff --git a/server/src/com/cloud/network/configuration/PodBasedNetworkGuru.java b/server/src/com/cloud/network/configuration/PodBasedNetworkGuru.java
index 663f58b2be6..55e294ed657 100644
--- a/server/src/com/cloud/network/configuration/PodBasedNetworkGuru.java
+++ b/server/src/com/cloud/network/configuration/PodBasedNetworkGuru.java
@@ -44,7 +44,7 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
return null;
}
- NetworkConfigurationVO config = new NetworkConfigurationVO(type, Mode.Static, BroadcastDomainType.Native, offering.getId(), plan.getDataCenterId());
+ NetworkConfigurationVO config = new NetworkConfigurationVO(type, offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Native, offering.getId(), plan.getDataCenterId());
return config;
}
diff --git a/server/src/com/cloud/network/configuration/PublicNetworkGuru.java b/server/src/com/cloud/network/configuration/PublicNetworkGuru.java
index 563dab39a1a..31ba72d269f 100644
--- a/server/src/com/cloud/network/configuration/PublicNetworkGuru.java
+++ b/server/src/com/cloud/network/configuration/PublicNetworkGuru.java
@@ -49,7 +49,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
return null;
}
- return new NetworkConfigurationVO(offering.getTrafficType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId());
+ return new NetworkConfigurationVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId());
}
protected PublicNetworkGuru() {
@@ -95,7 +95,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
}
nic.setMacAddress(mac);
- DataCenter dc = _dcDao.findById(config.getId());
+ DataCenter dc = _dcDao.findById(config.getDataCenterId());
getIp(nic, dc, vm);
return nic;
diff --git a/server/src/com/cloud/network/dao/NetworkConfigurationDaoImpl.java b/server/src/com/cloud/network/dao/NetworkConfigurationDaoImpl.java
index 754687c5065..3e77b050b65 100644
--- a/server/src/com/cloud/network/dao/NetworkConfigurationDaoImpl.java
+++ b/server/src/com/cloud/network/dao/NetworkConfigurationDaoImpl.java
@@ -75,7 +75,7 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase uservm = (VirtualMachineProfile)vm;
- return _routerMgr.addVirtualMachineIntoNetwork(config, nic, uservm, context) != null;
+ return _routerMgr.addVirtualMachineIntoNetwork(config, nic, uservm, dest, context) != null;
}
@Override
diff --git a/server/src/com/cloud/network/router/DomainRouterManager.java b/server/src/com/cloud/network/router/DomainRouterManager.java
index 7dccb72142e..a8c31a3c2a7 100644
--- a/server/src/com/cloud/network/router/DomainRouterManager.java
+++ b/server/src/com/cloud/network/router/DomainRouterManager.java
@@ -37,7 +37,6 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.RemoteAccessVpnVO;
import com.cloud.network.VpnUserVO;
-import com.cloud.offering.NetworkOffering;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
@@ -175,7 +174,7 @@ public interface DomainRouterManager extends Manager {
DomainRouterVO getRouter(long accountId, long zoneId);
DomainRouterVO getRouter(String publicIpAddress);
- DomainRouterVO deploy(NetworkConfiguration guestConfig, NetworkOffering offering, DeployDestination dest, Account owner) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
+ DomainRouterVO deploy(NetworkConfiguration guestConfig, DeployDestination dest, Account owner) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
RemoteAccessVpnVO startRemoteAccessVpn(RemoteAccessVpnVO vpnVO) throws ResourceUnavailableException;
@@ -183,5 +182,5 @@ public interface DomainRouterManager extends Manager {
boolean deleteRemoteAccessVpn(RemoteAccessVpnVO vpnVO);
- DomainRouterVO addVirtualMachineIntoNetwork(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException;
+ DomainRouterVO addVirtualMachineIntoNetwork(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException;
}
diff --git a/server/src/com/cloud/network/router/DomainRouterManagerImpl.java b/server/src/com/cloud/network/router/DomainRouterManagerImpl.java
index c9ee5d6e130..3cab635a13b 100644
--- a/server/src/com/cloud/network/router/DomainRouterManagerImpl.java
+++ b/server/src/com/cloud/network/router/DomainRouterManagerImpl.java
@@ -104,6 +104,7 @@ import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.network.DomainRouterService;
import com.cloud.network.FirewallRuleVO;
import com.cloud.network.IPAddressVO;
import com.cloud.network.Network.TrafficType;
@@ -122,7 +123,6 @@ import com.cloud.network.dao.NetworkRuleConfigDao;
import com.cloud.network.dao.RemoteAccessVpnDao;
import com.cloud.network.dao.VpnUserDao;
import com.cloud.offering.NetworkOffering;
-import com.cloud.offering.NetworkOffering.GuestIpType;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.service.ServiceOfferingVO;
@@ -180,8 +180,8 @@ import com.cloud.vm.dao.UserVmDao;
/**
* NetworkManagerImpl implements NetworkManager.
*/
-@Local(value={DomainRouterManager.class})
-public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMachineManager, VirtualMachineGuru {
+@Local(value={DomainRouterManager.class, DomainRouterService.class})
+public class DomainRouterManagerImpl implements DomainRouterManager, DomainRouterService, VirtualMachineManager, VirtualMachineGuru {
private static final Logger s_logger = Logger.getLogger(DomainRouterManagerImpl.class);
String _name;
@@ -2033,14 +2033,14 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
}
@Override
- public DomainRouterVO deploy(NetworkConfiguration guestConfig, NetworkOffering offering, DeployDestination dest, Account owner) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException {
+ public DomainRouterVO deploy(NetworkConfiguration guestConfig, DeployDestination dest, Account owner) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException {
long dcId = dest.getDataCenter().getId();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Starting a router for network configurations: virtual=" + guestConfig + " in " + dest);
}
assert guestConfig.getState() == NetworkConfiguration.State.Implemented : "Network is not yet fully implemented: " + guestConfig;
- assert offering.getGuestIpType() == GuestIpType.Virtualized;
+ assert guestConfig.getTrafficType() == TrafficType.Guest;
DataCenterDeployment plan = new DataCenterDeployment(dcId);
@@ -2221,10 +2221,10 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
}
@Override
- public DomainRouterVO addVirtualMachineIntoNetwork(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile profile, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
+ public DomainRouterVO addVirtualMachineIntoNetwork(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
DomainRouterVO router = _routerDao.findByNetworkConfiguration(config.getId());
try {
- router = start(router, context.getCaller(), context.getAccount());
+ router = this.deploy(config, dest, profile.getOwner());
} catch (InsufficientNetworkCapacityException e) {
throw e;
} catch (InsufficientCapacityException e) {
@@ -2236,7 +2236,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
throw new ResourceUnavailableException("Can't find a domain router to start " + profile + " in " + config);
}
- String password = null;
+
+ String password = profile.getVirtualMachine().getPassword();
String userData = profile.getVirtualMachine().getUserData();
Commands cmds = new Commands(OnError.Stop);
String routerPublicIpAddress = nic.getIp4Address();
diff --git a/server/src/com/cloud/offerings/dao/NetworkOfferingDao.java b/server/src/com/cloud/offerings/dao/NetworkOfferingDao.java
index 60e478f37ca..884ab00d62b 100644
--- a/server/src/com/cloud/offerings/dao/NetworkOfferingDao.java
+++ b/server/src/com/cloud/offerings/dao/NetworkOfferingDao.java
@@ -3,6 +3,8 @@
*/
package com.cloud.offerings.dao;
+import java.util.List;
+
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.utils.db.GenericDao;
@@ -28,7 +30,9 @@ public interface NetworkOfferingDao extends GenericDao
* @param offering network offering to persist if not in the database.
* @return NetworkOfferingVO backed by a row in the database
*/
- NetworkOfferingVO persistSystemNetworkOffering(NetworkOfferingVO offering);
+ NetworkOfferingVO persistDefaultNetworkOffering(NetworkOfferingVO offering);
NetworkOfferingVO findByServiceOffering(ServiceOfferingVO offering);
+
+ List listNonSystemNetworkOfferings();
}
diff --git a/server/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java b/server/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
index 08c7dc4ca68..e0d886d12dc 100644
--- a/server/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
+++ b/server/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
@@ -4,6 +4,8 @@
package com.cloud.offerings.dao;
+import java.util.List;
+
import javax.ejb.Local;
import javax.persistence.EntityExistsException;
@@ -22,8 +24,9 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase NameSearch;
- SearchBuilder ServiceOfferingSearch;
+ final SearchBuilder NameSearch;
+ final SearchBuilder ServiceOfferingSearch;
+ final SearchBuilder SystemOfferingSearch;
protected NetworkOfferingDaoImpl() {
super();
@@ -33,8 +36,12 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase sc = ServiceOfferingSearch.create();
- sc.setParameters("serviceoffering", offering.getId());
+ sc.setParameters("serviceoffering", offering.getGuestIpType());
NetworkOfferingVO vo = findOneBy(sc);
if (vo != null) {
@@ -86,4 +93,11 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase listNonSystemNetworkOfferings() {
+ SearchCriteria sc = SystemOfferingSearch.create();
+ sc.setParameters("system", false);
+ return this.listIncludingRemovedBy(sc, null);
+ }
}
diff --git a/server/src/com/cloud/vm/ItWorkDao.java b/server/src/com/cloud/vm/ItWorkDao.java
index c4ea36ef47d..51c60943a9c 100644
--- a/server/src/com/cloud/vm/ItWorkDao.java
+++ b/server/src/com/cloud/vm/ItWorkDao.java
@@ -19,6 +19,6 @@ package com.cloud.vm;
import com.cloud.utils.db.GenericDao;
-public interface ItWorkDao extends GenericDao {
+public interface ItWorkDao extends GenericDao {
}
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 552a8c639f4..95d68b3d692 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -76,6 +76,7 @@ import com.cloud.api.commands.RebootVMCmd;
import com.cloud.api.commands.RecoverVMCmd;
import com.cloud.api.commands.ResetVMPasswordCmd;
import com.cloud.api.commands.StartVMCmd;
+import com.cloud.api.commands.StartVm2Cmd;
import com.cloud.api.commands.StopVMCmd;
import com.cloud.api.commands.StopVm2Cmd;
import com.cloud.api.commands.UpdateVMCmd;
@@ -3726,13 +3727,27 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
long vmId = cmd.getId();
UserVmVO vm = _vmDao.findById(vmId);
- long dcId = cmd.getZoneId();
+ // Check that the password was passed in and is valid
+ VMTemplateVO template = _templateDao.findById(vm.getTemplateId());
+
+ String password = "saved_password";
+ if (template.getEnablePassword()) {
+ password = generateRandomPassword();
+ }
+
+ if (password == null || password.equals("") || (!validPassword(password))) {
+ throw new InvalidParameterValueException("A valid password for this virtual machine was not provided.");
+ }
+ vm.setPassword(password);
+
long userId = UserContext.current().getUserId();
UserVO caller = _userDao.findById(userId);
AccountVO owner = _accountDao.findById(vm.getAccountId());
- return _itMgr.start(vm, null, caller, owner);
+ vm = _itMgr.start(vm, null, caller, owner);
+ vm.setPassword(password);
+ return vm;
}
@Override
@@ -3804,4 +3819,33 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
public void finalizeStop(VirtualMachineProfile profile, long hostId, String reservationId) {
}
+ public String generateRandomPassword() {
+ return PasswordGenerator.generateRandomPassword(6);
+ }
+
+
+ @Override
+ public UserVm startVirtualMachine(StartVm2Cmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
+ //Input validation
+ Account account = UserContext.current().getAccount();
+ Long userId = UserContext.current().getUserId();
+ Long id = cmd.getId();
+
+ //if account is removed, return error
+ if(account!=null && account.getRemoved() != null)
+ throw new PermissionDeniedException("The account " + account.getId()+" is removed");
+
+ UserVmVO vm = _vmDao.findById(id.longValue());
+ if (vm == null) {
+ throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + id);
+ }
+
+ long eventId = EventUtils.saveScheduledEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_START, "Starting Vm with Id: "+id);
+
+ userId = accountAndUserValidation(id, account, userId, vm);
+ UserVO user = _userDao.findById(userId);
+
+ return _itMgr.start(vm, null, user, account);
+ }
+
}
diff --git a/server/src/com/cloud/vm/UserVmService.java b/server/src/com/cloud/vm/UserVmService.java
index b448edc9581..5be28644cd9 100755
--- a/server/src/com/cloud/vm/UserVmService.java
+++ b/server/src/com/cloud/vm/UserVmService.java
@@ -28,6 +28,7 @@ import com.cloud.api.commands.RebootVMCmd;
import com.cloud.api.commands.RecoverVMCmd;
import com.cloud.api.commands.ResetVMPasswordCmd;
import com.cloud.api.commands.StartVMCmd;
+import com.cloud.api.commands.StartVm2Cmd;
import com.cloud.api.commands.StopVMCmd;
import com.cloud.api.commands.StopVm2Cmd;
import com.cloud.api.commands.UpdateVMCmd;
@@ -148,4 +149,6 @@ public interface UserVmService extends Manager {
UserVm upgradeVirtualMachine(UpgradeVMCmd cmd);
UserVm stopVirtualMachine(StopVm2Cmd cmd) throws ConcurrentOperationException;
+
+ UserVm startVirtualMachine(StartVm2Cmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
}
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index f507887ced4..5921fe93329 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -129,6 +129,7 @@ CREATE TABLE `cloud`.`network_configurations` (
`dns2` varchar(255) COMMENT 'comma separated DNS list',
`guru_data` varchar(1024) COMMENT 'data stored by the network guru that setup this network',
`set_fields` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'which fields are set already',
+ `guest_type` char(32) COMMENT 'type of guest network',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -184,6 +185,7 @@ CREATE TABLE `cloud`.`network_offerings` (
`traffic_type` varchar(32) NOT NULL COMMENT 'traffic type carried on this network',
`tags` varchar(4096) COMMENT 'tags supported by this offering',
`system_only` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Is this network offering for system use only',
+ `specify_vlan` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Should the user specify vlan',
`service_offering_id` bigint unsigned UNIQUE COMMENT 'service offering id that this network offering is tied to',
`created` datetime NOT NULL COMMENT 'time the entry was created',
`removed` datetime DEFAULT NULL COMMENT 'time the entry was removed',
diff --git a/utils/src/com/cloud/utils/component/ComponentLocator.java b/utils/src/com/cloud/utils/component/ComponentLocator.java
index 47a616c84f2..ce4c9fc10c4 100755
--- a/utils/src/com/cloud/utils/component/ComponentLocator.java
+++ b/utils/src/com/cloud/utils/component/ComponentLocator.java
@@ -379,6 +379,8 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
instance = locator.getDao(fc);
} else if (Adapters.class.isAssignableFrom(fc)) {
instance = locator.getAdapters(inject.adapter());
+ } else {
+ instance = locator.getManager(fc);
}
if (instance == null) {
@@ -690,16 +692,25 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
throw new CloudRuntimeException("Caught throwable: ", e);
}
+ if (!interphace.isAssignableFrom(info.clazz)) {
+ throw new CloudRuntimeException("Class " + info.clazz.toString() + " does not implment " + interphace);
+ }
+
Local local = info.clazz.getAnnotation(Local.class);
if (local == null) {
throw new CloudRuntimeException("Unable to find Local annotation for class " + clazzName);
}
-
+
Class>[] classes = local.value();
for (int i = 0; i < classes.length; i++) {
- if (findInterfaceInHierarchy(classes[i].getInterfaces(), interphace)) {
+ if (!classes[i].isInterface()) {
+ throw new CloudRuntimeException(classes[i].getName() + " is not an interface");
+ }
+ if (classes[i].isAssignableFrom(info.clazz)) {
info.keys.add(classes[i].getName());
- s_logger.info("Found component: " + interphace.getName() + " - " + clazzName + " - " + info.name);
+ s_logger.info("Found component: " + classes[i].getName() + " in " + clazzName + " - " + info.name);
+ } else {
+ throw new CloudRuntimeException(classes[i].getName() + " is not implemented by " + info.clazz.getName());
}
}
@@ -752,6 +763,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
fillInfo(atts, Manager.class, info);
s_logger.info("Adding Manager: " + info.name);
for (String key : info.keys) {
+ s_logger.info("Linking " + key + " to " + info.name);
managers.put(key, info);
}
currentInfo = info;