cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From frankzh...@apache.org
Subject [2/7] CloudStack CLOUDSTACK-774 Supporting kickstart in CloudStack baremetal
Date Thu, 21 Feb 2013 23:34:58 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e069ad1/server/src/com/cloud/deploy/BareMetalPlanner.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/BareMetalPlanner.java b/server/src/com/cloud/deploy/BareMetalPlanner.java
deleted file mode 100755
index 829a466..0000000
--- a/server/src/com/cloud/deploy/BareMetalPlanner.java
+++ /dev/null
@@ -1,163 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.deploy;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.capacity.CapacityManager;
-import com.cloud.configuration.Config;
-import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.dc.ClusterVO;
-import com.cloud.dc.DataCenter;
-import com.cloud.dc.Pod;
-import com.cloud.dc.dao.ClusterDao;
-import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.dc.dao.HostPodDao;
-import com.cloud.exception.InsufficientServerCapacityException;
-import com.cloud.host.Host;
-import com.cloud.host.HostVO;
-import com.cloud.host.dao.HostDao;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.offering.ServiceOffering;
-import com.cloud.org.Cluster;
-import com.cloud.resource.ResourceManager;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.component.AdapterBase;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-
-@Local(value=DeploymentPlanner.class)
-public class BareMetalPlanner extends AdapterBase implements DeploymentPlanner {
-	private static final Logger s_logger = Logger.getLogger(BareMetalPlanner.class);
-	@Inject protected DataCenterDao _dcDao;
-	@Inject protected HostPodDao _podDao;
-	@Inject protected ClusterDao _clusterDao;
-	@Inject protected HostDao _hostDao;
-	@Inject protected ConfigurationDao _configDao;
-	@Inject protected CapacityManager _capacityMgr;
-	@Inject protected ResourceManager _resourceMgr;
-	
-	@Override
-	public DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vmProfile,
DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException {
-		VirtualMachine vm = vmProfile.getVirtualMachine();
-		ServiceOffering offering = vmProfile.getServiceOffering();	
-		String hostTag = null;
-		
-        String opFactor = _configDao.getValue(Config.CPUOverprovisioningFactor.key());
-        float cpuOverprovisioningFactor = NumbersUtil.parseFloat(opFactor, 1);
-        
-        String haVmTag = (String)vmProfile.getParameter(VirtualMachineProfile.Param.HaTag);
-        
-		if (vm.getLastHostId() != null && haVmTag == null) {
-			HostVO h = _hostDao.findById(vm.getLastHostId());
-			DataCenter dc = _dcDao.findById(h.getDataCenterId());
-			Pod pod = _podDao.findById(h.getPodId());
-			Cluster c =  _clusterDao.findById(h.getClusterId());
-			s_logger.debug("Start baremetal vm " + vm.getId() + " on last stayed host " + h.getId());
-			return new DeployDestination(dc, pod, c, h);
-		}
-		
-		if (haVmTag != null) {
-		    hostTag = haVmTag;
-		} else if (offering.getHostTag() != null) {
-			String[] tags = offering.getHostTag().split(",");
-			if (tags.length > 0) {
-				hostTag = tags[0];
-			}
-		}
-		
-		List<ClusterVO> clusters = _clusterDao.listByDcHyType(vm.getDataCenterId(), HypervisorType.BareMetal.toString());
-		int cpu_requested;
-		long ram_requested;
-		HostVO target = null;
-		List<HostVO> hosts;
-		for (ClusterVO cluster : clusters) {
-			hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(),
cluster.getDataCenterId());
-			if (hostTag != null) {
-				for (HostVO h : hosts) {
-					_hostDao.loadDetails(h);
-					if (h.getDetail("hostTag") != null && h.getDetail("hostTag").equalsIgnoreCase(hostTag))
{
-						target = h;
-						break;
-					}
-				}
-			}
-		}
-
-		if (target == null) {
-			s_logger.warn("Cannot find host with tag " + hostTag + " use capacity from service offering");
-			cpu_requested = offering.getCpu() * offering.getSpeed();
-			ram_requested = offering.getRamSize() * 1024 * 1024;
-		} else {
-			cpu_requested = target.getCpus() * target.getSpeed().intValue();
-			ram_requested = target.getTotalMemory();
-		}
-		
-		for (ClusterVO cluster : clusters) {
-		    if (haVmTag == null) {
-		        hosts = _resourceMgr.listAllUpAndEnabledNonHAHosts(Host.Type.Routing, cluster.getId(),
cluster.getPodId(), cluster.getDataCenterId());
-		    } else {
-		        s_logger.warn("Cannot find HA host with tag " + haVmTag + " in cluster id=" + cluster.getId()
+ ", pod id=" + cluster.getPodId() + ", data center id=" + cluster.getDataCenterId());
-		        return null;
-		    }
-			for (HostVO h : hosts) {
-				if (_capacityMgr.checkIfHostHasCapacity(h.getId(), cpu_requested, ram_requested, false,
cpuOverprovisioningFactor, true)) {
-					s_logger.debug("Find host " + h.getId() + " has enough capacity");
-					DataCenter dc = _dcDao.findById(h.getDataCenterId());
-					Pod pod = _podDao.findById(h.getPodId());
-					return new DeployDestination(dc, pod, cluster, h);
-				}
-			}
-		}
-
-		s_logger.warn(String.format("Cannot find enough capacity(requested cpu=%1$s memory=%2$s)",
cpu_requested, ram_requested));
-		return null;
-	}
-
-	@Override
-	public boolean canHandle(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan
plan, ExcludeList avoid) {
-		return vm.getHypervisorType() == HypervisorType.BareMetal;
-	}
-
-	@Override
-	public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
-		return true;
-	}
-
-	@Override
-	public boolean start() {
-		return true;
-	}
-
-	@Override
-	public boolean stop() {
-		return true;
-	}
-
-	@Override
-	public boolean check(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan
plan, DeployDestination dest, ExcludeList exclude) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e069ad1/server/src/com/cloud/deploy/DeployPlannerSelector.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/DeployPlannerSelector.java b/server/src/com/cloud/deploy/DeployPlannerSelector.java
new file mode 100755
index 0000000..9154bc9
--- /dev/null
+++ b/server/src/com/cloud/deploy/DeployPlannerSelector.java
@@ -0,0 +1,8 @@
+package com.cloud.deploy;
+
+import com.cloud.utils.component.Adapter;
+import com.cloud.vm.UserVmVO;
+
+public interface DeployPlannerSelector extends Adapter {
+    String selectPlanner(UserVmVO vm);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e069ad1/server/src/com/cloud/deploy/HypervisorVmPlannerSelector.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/HypervisorVmPlannerSelector.java b/server/src/com/cloud/deploy/HypervisorVmPlannerSelector.java
new file mode 100755
index 0000000..de64e1c
--- /dev/null
+++ b/server/src/com/cloud/deploy/HypervisorVmPlannerSelector.java
@@ -0,0 +1,17 @@
+package com.cloud.deploy;
+
+import javax.ejb.Local;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.vm.UserVmVO;
+
+@Local(value = {DeployPlannerSelector.class})
+public class HypervisorVmPlannerSelector extends AbstractDeployPlannerSelector {
+    @Override
+    public String selectPlanner(UserVmVO vm) {
+        if (vm.getHypervisorType() != HypervisorType.BareMetal) {
+            return "FirstFitPlanner";
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e069ad1/server/src/com/cloud/host/dao/HostDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/host/dao/HostDaoImpl.java b/server/src/com/cloud/host/dao/HostDaoImpl.java
index c03611d..697c3dc 100755
--- a/server/src/com/cloud/host/dao/HostDaoImpl.java
+++ b/server/src/com/cloud/host/dao/HostDaoImpl.java
@@ -491,7 +491,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements
HostDao
     	txn.start();
     	SearchCriteria<HostVO> sc = UnmanagedApplianceSearch.create();
     	sc.setParameters("lastPinged", lastPingSecondsAfter);
-        sc.setParameters("types", Type.ExternalDhcp, Type.ExternalFirewall, Type.ExternalLoadBalancer,
Type.PxeServer, Type.TrafficMonitor, Type.L2Networking);
+        sc.setParameters("types", Type.ExternalDhcp, Type.ExternalFirewall, Type.ExternalLoadBalancer,
Type.BaremetalDhcp, Type.BaremetalPxe, Type.TrafficMonitor, Type.L2Networking);
     	List<HostVO> hosts = lockRows(sc, null, true);
     	
     	for (HostVO host : hosts) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e069ad1/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
index e2382f8..014db59 100755
--- a/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
+++ b/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
@@ -25,7 +25,6 @@ import java.util.concurrent.ScheduledExecutorService;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
-import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.command.admin.network.AddNetworkDeviceCmd;
@@ -37,14 +36,7 @@ import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import com.cloud.agent.AgentManager;
-import com.cloud.api.ApiDBUtils;
-import com.cloud.baremetal.ExternalDhcpManager;
-import com.cloud.baremetal.PxeServerManager;
-import com.cloud.baremetal.PxeServerManager.PxeServerType;
-import com.cloud.baremetal.PxeServerProfile;
 import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.dc.DataCenter;
-import com.cloud.dc.Pod;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.VlanDao;
 import com.cloud.host.Host;
@@ -63,8 +55,6 @@ import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
 import com.cloud.network.dao.VpnUserDao;
 import com.cloud.network.rules.dao.PortForwardingRulesDao;
 import com.cloud.offerings.dao.NetworkOfferingDao;
-import com.cloud.server.api.response.NwDeviceDhcpResponse;
-import com.cloud.server.api.response.PxePingResponse;
 import com.cloud.user.AccountManager;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserStatisticsDao;
@@ -77,8 +67,6 @@ import com.cloud.vm.dao.NicDao;
 @Local(value = {ExternalNetworkDeviceManager.class})
 public class ExternalNetworkDeviceManagerImpl extends ManagerBase implements ExternalNetworkDeviceManager
{
 
-    @Inject ExternalDhcpManager _dhcpMgr;
-    @Inject PxeServerManager _pxeMgr;
     @Inject AgentManager _agentMgr;
     @Inject NetworkModel _networkMgr;
     @Inject HostDao _hostDao;
@@ -121,80 +109,12 @@ public class ExternalNetworkDeviceManagerImpl extends ManagerBase implements
Ext
 
         Collection paramsCollection = paramList.values();
         HashMap params = (HashMap) (paramsCollection.toArray())[0];
-        if (cmd.getDeviceType().equalsIgnoreCase(NetworkDevice.ExternalDhcp.getName())) {
-            //Long zoneId = _identityService.getIdentityId("data_center", (String) params.get(ApiConstants.ZONE_ID));
-            //Long podId = _identityService.getIdentityId("host_pod_ref", (String)params.get(ApiConstants.POD_ID));
-            Long zoneId = Long.valueOf((String) params.get(ApiConstants.ZONE_ID));
-            Long podId = Long.valueOf((String)params.get(ApiConstants.POD_ID));
-            String type = (String) params.get(ApiConstants.DHCP_SERVER_TYPE);
-            String url = (String) params.get(ApiConstants.URL);
-            String username = (String) params.get(ApiConstants.USERNAME);
-            String password = (String) params.get(ApiConstants.PASSWORD);
-
-            return _dhcpMgr.addDhcpServer(zoneId, podId, type, url, username, password);
-        } else if (cmd.getDeviceType().equalsIgnoreCase(NetworkDevice.PxeServer.getName()))
{
-            Long zoneId = Long.parseLong((String) params.get(ApiConstants.ZONE_ID));
-            Long podId = Long.parseLong((String)params.get(ApiConstants.POD_ID));
-            //Long zoneId = _identityService.getIdentityId("data_center", (String) params.get(ApiConstants.ZONE_ID));
-            //Long podId = _identityService.getIdentityId("host_pod_ref", (String)params.get(ApiConstants.POD_ID));
-            String type = (String) params.get(ApiConstants.PXE_SERVER_TYPE);
-            String url = (String) params.get(ApiConstants.URL);
-            String username = (String) params.get(ApiConstants.USERNAME);
-            String password = (String) params.get(ApiConstants.PASSWORD);
-            String pingStorageServerIp = (String) params.get(ApiConstants.PING_STORAGE_SERVER_IP);
-            String pingDir = (String) params.get(ApiConstants.PING_DIR);
-            String tftpDir = (String) params.get(ApiConstants.TFTP_DIR);
-            String pingCifsUsername = (String) params.get(ApiConstants.PING_CIFS_USERNAME);
-            String pingCifsPassword = (String) params.get(ApiConstants.PING_CIFS_PASSWORD);
-            PxeServerProfile profile = new PxeServerProfile(zoneId, podId, url, username,
password, type, pingStorageServerIp, pingDir, tftpDir,
-                    pingCifsUsername, pingCifsPassword);
-            return _pxeMgr.addPxeServer(profile);
-        } else {
-            throw new CloudRuntimeException("Unsupported network device type:" + cmd.getDeviceType());
-        }
+        return null;
     }
 
     @Override
     public NetworkDeviceResponse getApiResponse(Host device) {
-        NetworkDeviceResponse response;
-        HostVO host = (HostVO)device;
-        _hostDao.loadDetails(host);
-        if (host.getType() == Host.Type.ExternalDhcp) {
-            NwDeviceDhcpResponse r = new NwDeviceDhcpResponse();
-            r.setZoneId(host.getDataCenterId());
-            r.setPodId(host.getPodId());
-            r.setUrl(host.getPrivateIpAddress());
-            r.setType(host.getDetail("type"));
-            response = r;
-        } else if (host.getType() == Host.Type.PxeServer) {
-            String pxeType = host.getDetail("type");
-            if (pxeType.equalsIgnoreCase(PxeServerType.PING.getName())) {
-                PxePingResponse r = new PxePingResponse();
-                DataCenter zone = ApiDBUtils.findZoneById(host.getDataCenterId());
-                if (zone != null) {
-                    r.setZoneId(zone.getUuid());
-                }
-                if (host.getPodId() != null) {
-                    Pod pod = ApiDBUtils.findPodById(host.getPodId());
-                    if (pod != null) {
-                        r.setPodId(pod.getUuid());
-                    }
-                }
-                r.setUrl(host.getPrivateIpAddress());
-                r.setType(pxeType);
-                r.setStorageServerIp(host.getDetail("storageServer"));
-                r.setPingDir(host.getDetail("pingDir"));
-                r.setTftpDir(host.getDetail("tftpDir"));
-                response = r;
-            } else {
-                throw new CloudRuntimeException("Unsupported PXE server type:" + pxeType);
-            }
-        } else {
-            throw new CloudRuntimeException("Unsupported network device type:" + host.getType());
-        }
-
-        response.setId(device.getUuid());
-        return response;
+        return null;
     }
 
     private List<Host> listNetworkDevice(Long zoneId, Long physicalNetworkId, Long
podId, Host.Type type) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e069ad1/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index f670deb..9fc4643 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -1517,7 +1517,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             DeployDestination dest, ReservationContext context) throws InsufficientCapacityException,
             ConcurrentOperationException, ResourceUnavailableException {
         element.prepare(network, profile, vmProfile, dest, context);
-        if (vmProfile.getType() == Type.User && vmProfile.getHypervisorType() !=
HypervisorType.BareMetal && element.getProvider() != null) {
+        if (vmProfile.getType() == Type.User && element.getProvider() != null) {
             if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dhcp)
&&
                     _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
element.getProvider()) &&
                     (element instanceof DhcpServiceProvider)) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e069ad1/server/src/com/cloud/network/element/BareMetalElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/BareMetalElement.java b/server/src/com/cloud/network/element/BareMetalElement.java
deleted file mode 100644
index 553fe1d..0000000
--- a/server/src/com/cloud/network/element/BareMetalElement.java
+++ /dev/null
@@ -1,128 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.element;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.baremetal.ExternalDhcpManager;
-import com.cloud.deploy.DeployDestination;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.host.Host;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.network.Network;
-import com.cloud.network.Network.Capability;
-import com.cloud.network.Network.Provider;
-import com.cloud.network.Network.Service;
-import com.cloud.network.PhysicalNetworkServiceProvider;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.utils.component.AdapterBase;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Transaction;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.NicVO;
-import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-import com.cloud.vm.dao.NicDao;
-
-@Local(value=NetworkElement.class)
-public class BareMetalElement extends AdapterBase implements NetworkElement {
-	private static final Logger s_logger = Logger.getLogger(BareMetalElement.class);
-	@Inject NicDao _nicDao;
-	@Inject ExternalDhcpManager _dhcpMgr;
-	
-	@Override
-	public Map<Service, Map<Capability, String>> getCapabilities() {
-		return null;
-	}
-
-	@Override
-	public Provider getProvider() {
-		return null;
-	}
-
-	@Override
-	public boolean implement(Network network, NetworkOffering offering, DeployDestination dest,
ReservationContext context)
-			throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException
{
-		return true;
-	}
-
-	@Override @DB
-	public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends
VirtualMachine> vm, DeployDestination dest,
-			ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException,
InsufficientCapacityException {
-		Host host = dest.getHost();
-		if (host == null || host.getHypervisorType() != HypervisorType.BareMetal) {
-			return true;
-		}
-		
-		Transaction txn = Transaction.currentTxn();
-        txn.start();
-		nic.setMacAddress(host.getPrivateMacAddress());
-		NicVO vo = _nicDao.findById(nic.getId());
-		assert vo != null : "Where ths nic " + nic.getId() + " going???";
-		vo.setMacAddress(nic.getMacAddress());
-		_nicDao.update(vo.getId(), vo);
-		txn.commit();
-		s_logger.debug("Bare Metal changes mac address of nic " + nic.getId() + " to " + nic.getMacAddress());
-		
-		return _dhcpMgr.addVirtualMachineIntoNetwork(network, nic, vm, dest, context);
-	}
-
-	@Override
-	public boolean release(Network network, NicProfile nic, VirtualMachineProfile<? extends
VirtualMachine> vm, ReservationContext context)
-			throws ConcurrentOperationException, ResourceUnavailableException {
-		return true;
-	}
-
-	@Override
-	public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws
ConcurrentOperationException, ResourceUnavailableException {
-		return true;
-	}
-
-	@Override
-	public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
-		return true;
-	}
-
-    @Override
-    public boolean isReady(PhysicalNetworkServiceProvider provider) {
-        return true;
-    }
-
-    @Override
-    public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext
context) throws ConcurrentOperationException, ResourceUnavailableException {
-        return true;
-    }
-
-    @Override
-    public boolean canEnableIndividualServices() {
-        return false;
-    }
-    
-    @Override
-    public boolean verifyServicesCombination(Set<Service> services) {
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e069ad1/server/src/com/cloud/network/element/ExternalDhcpElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/ExternalDhcpElement.java b/server/src/com/cloud/network/element/ExternalDhcpElement.java
deleted file mode 100755
index f7c465d..0000000
--- a/server/src/com/cloud/network/element/ExternalDhcpElement.java
+++ /dev/null
@@ -1,152 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.element;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.baremetal.ExternalDhcpManager;
-import com.cloud.dc.DataCenter;
-import com.cloud.dc.DataCenter.NetworkType;
-import com.cloud.dc.Pod;
-import com.cloud.deploy.DeployDestination;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.host.Host;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.network.Network;
-import com.cloud.network.Network.Capability;
-import com.cloud.network.Network.GuestType;
-import com.cloud.network.Network.Provider;
-import com.cloud.network.Network.Service;
-import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.PhysicalNetworkServiceProvider;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.utils.component.AdapterBase;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-
-@Local(value = NetworkElement.class)
-public class ExternalDhcpElement extends AdapterBase implements NetworkElement, DhcpServiceProvider
{
-    private static final Logger s_logger = Logger.getLogger(ExternalDhcpElement.class);
-    @Inject
-    ExternalDhcpManager _dhcpMgr;
-    private static final Map<Service, Map<Capability, String>> capabilities =
setCapabilities();
-
-    private boolean canHandle(DeployDestination dest, TrafficType trafficType, GuestType
networkType) {
-        DataCenter dc = dest.getDataCenter();
-        Pod pod = dest.getPod();
-
-        if ((pod != null && pod.getExternalDhcp()) && dc.getNetworkType()
== NetworkType.Basic && trafficType == TrafficType.Guest
-                && networkType == Network.GuestType.Shared) {
-            s_logger.debug("External DHCP can handle");
-            return true;
-        }
-
-        return false;
-    }
-
-    private static Map<Service, Map<Capability, String>> setCapabilities() {
-        // No external dhcp support for Acton release
-        Map<Service, Map<Capability, String>> capabilities = new HashMap<Service,
Map<Capability, String>>();
-        //capabilities.put(Service.Dhcp, null);
-        return capabilities;
-    }
-
-    @Override
-    public Map<Service, Map<Capability, String>> getCapabilities() {
-        return capabilities;
-    }
-
-    @Override
-    public Provider getProvider() {
-        return Provider.ExternalDhcpServer;
-    }
-
-    @Override
-    public boolean implement(Network network, NetworkOffering offering, DeployDestination
dest, ReservationContext context)
-            throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException
{
-        if (!canHandle(dest, offering.getTrafficType(), network.getGuestType())) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends
VirtualMachine> vm, DeployDestination dest,
-            ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException,
InsufficientCapacityException {
-        return true;
-    }
-
-    @Override
-    public boolean release(Network network, NicProfile nic, VirtualMachineProfile<? extends
VirtualMachine> vm, ReservationContext context)
-            throws ConcurrentOperationException, ResourceUnavailableException {
-        return true;
-    }
-
-    @Override
-    public boolean shutdown(Network network, ReservationContext context, boolean cleanup)
throws ConcurrentOperationException, ResourceUnavailableException {
-        return true;
-    }
-
-    @Override
-    public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
-        return true;
-    }
-
-    @Override
-    public boolean isReady(PhysicalNetworkServiceProvider provider) {
-        // TODO Auto-generated method stub
-        return true;
-    }
-
-    @Override
-    public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext
context) throws ConcurrentOperationException, ResourceUnavailableException {
-        // TODO Auto-generated method stub
-        return true;
-    }
-
-    @Override
-    public boolean canEnableIndividualServices() {
-        return false;
-    }
-
-    @Override
-    public boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile<?
extends VirtualMachine> vm, DeployDestination dest, ReservationContext context)
-            throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException
{
-        Host host = dest.getHost();
-        if (host.getHypervisorType() == HypervisorType.BareMetal || !canHandle(dest, network.getTrafficType(),
network.getGuestType())) {
-            // BareMetalElement or DhcpElement handle this
-            return false;
-        }
-        return _dhcpMgr.addVirtualMachineIntoNetwork(network, nic, vm, dest, context);
-    }
-
-    @Override
-    public boolean verifyServicesCombination(Set<Service> services) {
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e069ad1/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
old mode 100644
new mode 100755
index 2382b4b..7e64cea
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -108,6 +108,7 @@ import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.HostPodDao;
 import com.cloud.deploy.DataCenterDeployment;
 import com.cloud.deploy.DeployDestination;
+import com.cloud.deploy.DeployPlannerSelector;
 import com.cloud.deploy.DeploymentPlanner.ExcludeList;
 import com.cloud.domain.DomainVO;
 import com.cloud.domain.dao.DomainDao;
@@ -133,15 +134,11 @@ import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
-import com.cloud.network.Network;
 import com.cloud.network.*;
 import com.cloud.network.Network.IpAddresses;
 import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
-import com.cloud.network.NetworkManager;
-import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.PhysicalNetwork;
 import com.cloud.network.dao.FirewallRulesDao;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.IPAddressVO;
@@ -392,6 +389,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
     protected GuestOSCategoryDao _guestOSCategoryDao;
     @Inject
     UsageEventDao _usageEventDao;
+    @Inject
+    List<DeployPlannerSelector> plannerSelectors;
 
     protected ScheduledExecutorService _executor = null;
     protected int _expungeInterval;
@@ -3151,14 +3150,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
                 }
             }
         }
-
-        // check if we have available pools for vm deployment
-        long availablePools = _storagePoolDao
-                .countPoolsByStatus(StoragePoolStatus.Up);
-        if (availablePools  < 1) {
-            throw new StorageUnavailableException(
-                    "There are no available pools in the UP state for vm deployment",
-                    -1);
+
+        if (template.getHypervisorType() != null && template.getHypervisorType()
!= HypervisorType.BareMetal) {
+            // check if we have available pools for vm deployment
+            long availablePools = _storagePoolDao.countPoolsByStatus(StoragePoolStatus.Up);
+            if (availablePools < 1) {
+                throw new StorageUnavailableException("There are no available pools in the
UP state for vm deployment", -1);
+            }
         }
 
         ServiceOfferingVO offering = _serviceOfferingDao
@@ -3846,8 +3844,19 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
         }
 
         VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
+        
+        String plannerName = null;
+        for (DeployPlannerSelector dps : plannerSelectors) {
+            plannerName = dps.selectPlanner(vm);
+            if (plannerName != null) {
+                break;
+            }
+        }
+        if (plannerName == null) {
+            throw new CloudRuntimeException(String.format("cannot find DeployPlannerSelector
for vm[uuid:%s, hypervisorType:%s]", vm.getUuid(), vm.getHypervisorType()));
+        }
         
-        String reservationId = vmEntity.reserve("FirstFitPlanner", plan, new ExcludeList(),
new Long(callerUser.getId()).toString());
+        String reservationId = vmEntity.reserve(plannerName, plan, new ExcludeList(), new
Long(callerUser.getId()).toString());
         vmEntity.deploy(reservationId, new Long(callerUser.getId()).toString());
 
         Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> vmParamPair
= new Pair(vm, params);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e069ad1/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 1838ed2..c22adfb 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -345,11 +345,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         return (VirtualMachineGuru<T>) _vmGurus.get(vm.getType());
     }
 
-    @SuppressWarnings("unchecked")
-    private <T extends VMInstanceVO> VirtualMachineGuru<T> getBareMetalVmGuru(T
vm) {
-        return (VirtualMachineGuru<T>) _vmGurus.get(VirtualMachine.Type.UserBareMetal);
-    }
-
     @Override
     public <T extends VMInstanceVO> boolean expunge(T vm, User caller, Account account)
throws ResourceUnavailableException {
         try {
@@ -595,12 +590,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
     public <T extends VMInstanceVO> T advanceStart(T vm, Map<VirtualMachineProfile.Param,
Object> params, User caller, Account account, DeploymentPlan planToDeploy)
             throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException
{
         long vmId = vm.getId();
-        VirtualMachineGuru<T> vmGuru;
-        if (vm.getHypervisorType() == HypervisorType.BareMetal) {
-            vmGuru = getBareMetalVmGuru(vm);
-        } else {
-            vmGuru = getVmGuru(vm);
-        }
+        VirtualMachineGuru<T> vmGuru = getVmGuru(vm);
 
         vm = vmGuru.findById(vm.getId());
         Ternary<T, ReservationContext, ItWorkVO> start = changeToStartState(vmGuru,
vm, caller, account);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2e069ad1/setup/db/db/schema-40to410.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql
index 47b7cbe..dce2177 100644
--- a/setup/db/db/schema-40to410.sql
+++ b/setup/db/db/schema-40to410.sql
@@ -1671,3 +1671,31 @@ CREATE VIEW `cloud`.`data_center_view` AS
             left join
         `cloud`.`domain` ON data_center.domain_id = domain.id;
 
+INSERT INTO `cloud`.`region` values ('1','Local','http://localhost:8080/client/api','','');
+ALTER TABLE `cloud`.`account` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1';
+ALTER TABLE `cloud`.`user` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1';
+ALTER TABLE `cloud`.`domain` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1';
+
+ALTER TABLE `cloud_usage`.`account` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT
'1';
+
+CREATE TABLE `cloud`.`baremetal_dhcp_devices` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `uuid` varchar(40) UNIQUE,
+  `nsp_id` bigint unsigned DEFAULT NULL COMMENT 'Network Service Provider ID',
+  `pod_id` bigint unsigned DEFAULT NULL COMMENT 'Pod id where this dhcp server in',
+  `device_type` varchar(255) DEFAULT NULL COMMENT 'type of the external device',
+  `physical_network_id` bigint unsigned DEFAULT NULL COMMENT 'id of the physical network
in to which external dhcp device is added',
+  `host_id` bigint unsigned DEFAULT NULL COMMENT 'host id coresponding to the external dhcp
device',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`baremetal_pxe_devices` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `uuid` varchar(40) UNIQUE,
+  `nsp_id` bigint unsigned DEFAULT NULL COMMENT 'Network Service Provider ID',
+  `pod_id` bigint unsigned DEFAULT NULL COMMENT 'Pod id where this pxe server in, for pxe
per zone this field is null',
+  `device_type` varchar(255) DEFAULT NULL COMMENT 'type of the pxe device',
+  `physical_network_id` bigint unsigned DEFAULT NULL COMMENT 'id of the physical network
in to which external pxe device is added',
+  `host_id` bigint unsigned DEFAULT NULL COMMENT 'host id coresponding to the external pxe
device',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;


Mime
View raw message