cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [08/36] git commit: updated refs/heads/master to a05ec6d
Date Fri, 06 Sep 2013 22:38:38 GMT
Moved NetworkManagerImpl to NetworkOrchestrator


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2e5bb63f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2e5bb63f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2e5bb63f

Branch: refs/heads/master
Commit: 2e5bb63f77c3bdd807d686d3899b4e5a94fa67f0
Parents: 8e5249d
Author: Alex Huang <alex.huang@citrix.com>
Authored: Mon Aug 19 21:33:31 2013 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Fri Sep 6 15:40:32 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/network/NetworkRuleApplier.java   |   28 +
 api/src/com/cloud/network/guru/NetworkGuru.java |    4 +-
 .../service/VolumeOrchestrationService.java     |    3 +
 engine/components-api/pom.xml                   |   10 +
 .../cloud/deploy/DeploymentPlanningManager.java |   50 +
 .../src/com/cloud/event/UsageEventUtils.java    |  168 +
 .../src/com/cloud/network/IpAddressManager.java |  181 +
 .../src/com/cloud/network/addr/PublicIp.java    |  235 ++
 .../network/lb/LoadBalancingRulesManager.java   |   62 +
 .../src/com/cloud/template/TemplateManager.java |  115 +
 .../com/cloud/vm/ReservationContextImpl.java    |   96 +
 .../com/cloud/vm/VirtualMachineProfileImpl.java |  258 ++
 engine/orchestration/pom.xml                    |    8 +-
 .../orchestration/NetworkOrchestrator.java      | 3155 +++++++++++++++++
 .../orchestration/VolumeOrchestrator.java       |  102 +-
 engine/schema/pom.xml                           |   10 -
 .../cloud/storage/dao/GuestOSHypervisorDao.java |   27 +
 .../storage/dao/GuestOSHypervisorDaoImpl.java   |   49 +
 .../cloud/storage/dao/VMTemplateDaoImpl.java    |   11 +-
 .../com/cloud/storage/dao/VolumeDetailsDao.java |   36 +
 .../cloud/storage/dao/VolumeDetailsDaoImpl.java |  114 +
 engine/schema/src/com/cloud/vm/NicDetailVO.java |   85 +
 .../src/com/cloud/vm/dao/NicDetailDao.java      |   35 +
 .../src/com/cloud/vm/dao/NicDetailDaoImpl.java  |  110 +
 .../src/com/cloud/vm/dao/NicIpAliasDao.java     |   60 +
 .../src/com/cloud/vm/dao/NicIpAliasDaoImpl.java |  177 +
 .../src/com/cloud/vm/dao/NicIpAliasVO.java      |  226 ++
 .../guru/BigSwitchVnsGuestNetworkGuru.java      |    5 +-
 .../network/guru/MidoNetGuestNetworkGuru.java   |    5 +-
 .../network/guru/MidoNetPublicNetworkGuru.java  |    2 +-
 .../network/guru/NiciraNvpGuestNetworkGuru.java |    5 +-
 server/pom.xml                                  |   12 +
 .../cloud/deploy/DeploymentPlanningManager.java |   50 -
 server/src/com/cloud/event/UsageEventUtils.java |  165 -
 .../src/com/cloud/network/IpAddressManager.java |  181 -
 .../com/cloud/network/NetworkManagerImpl.java   | 3172 ------------------
 .../com/cloud/network/NetworkRuleApplier.java   |   28 -
 server/src/com/cloud/network/addr/PublicIp.java |  235 --
 .../cloud/network/guru/ControlNetworkGuru.java  |    2 +-
 .../cloud/network/guru/DirectNetworkGuru.java   |    2 +-
 .../cloud/network/guru/GuestNetworkGuru.java    |    2 +-
 .../cloud/network/guru/PodBasedNetworkGuru.java |    2 +-
 .../cloud/network/guru/PrivateNetworkGuru.java  |    2 +-
 .../cloud/network/guru/PublicNetworkGuru.java   |    2 +-
 .../cloud/network/guru/StorageNetworkGuru.java  |    2 +-
 .../network/lb/LoadBalancingRulesManager.java   |   62 -
 .../lb/LoadBalancingRulesManagerImpl.java       |    2 -
 .../src/com/cloud/resource/ResourceManager.java |   16 -
 .../com/cloud/resource/ResourceManagerImpl.java |   27 -
 .../com/cloud/storage/VolumeApiServiceImpl.java |   58 +-
 .../cloud/storage/dao/GuestOSHypervisorDao.java |   27 -
 .../storage/dao/GuestOSHypervisorDaoImpl.java   |   49 -
 .../com/cloud/storage/dao/VolumeDetailsDao.java |   36 -
 .../cloud/storage/dao/VolumeDetailsDaoImpl.java |  114 -
 .../src/com/cloud/template/TemplateManager.java |  117 -
 .../com/cloud/template/TemplateManagerImpl.java |    2 -
 server/src/com/cloud/vm/NicDetailVO.java        |   85 -
 .../com/cloud/vm/ReservationContextImpl.java    |   96 -
 .../com/cloud/vm/VirtualMachineProfileImpl.java |  258 --
 server/src/com/cloud/vm/dao/NicDetailDao.java   |   35 -
 .../src/com/cloud/vm/dao/NicDetailDaoImpl.java  |  110 -
 server/src/com/cloud/vm/dao/NicIpAliasDao.java  |   60 -
 .../src/com/cloud/vm/dao/NicIpAliasDaoImpl.java |  177 -
 server/src/com/cloud/vm/dao/NicIpAliasVO.java   |  226 --
 .../lb/ApplicationLoadBalancerManagerImpl.java  |    5 +-
 .../com/cloud/network/NetworkManagerTest.java   |   69 -
 .../cloud/resource/MockResourceManagerImpl.java |   16 -
 .../lb/ApplicationLoadBalancerTest.java         |    7 +-
 68 files changed, 5389 insertions(+), 5554 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/api/src/com/cloud/network/NetworkRuleApplier.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkRuleApplier.java b/api/src/com/cloud/network/NetworkRuleApplier.java
new file mode 100644
index 0000000..31763d0
--- /dev/null
+++ b/api/src/com/cloud/network/NetworkRuleApplier.java
@@ -0,0 +1,28 @@
+// 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;
+
+import java.util.List;
+
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.rules.FirewallRule;
+
+public interface NetworkRuleApplier {
+    public boolean applyRules(Network network, FirewallRule.Purpose purpose, List<? extends FirewallRule> rules) throws ResourceUnavailableException;
+    
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/api/src/com/cloud/network/guru/NetworkGuru.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/guru/NetworkGuru.java b/api/src/com/cloud/network/guru/NetworkGuru.java
index 4127233..57ffef8 100755
--- a/api/src/com/cloud/network/guru/NetworkGuru.java
+++ b/api/src/com/cloud/network/guru/NetworkGuru.java
@@ -29,7 +29,6 @@ import com.cloud.user.Account;
 import com.cloud.utils.component.Adapter;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 
 /**
@@ -196,10 +195,9 @@ public interface NetworkGuru extends Adapter {
      *
      * @param network guest network being destroyed.
      * @param offering network offering the guest network was created with.
-     * @param owner owner of the network.
      * @return true if trash was successful; false if not.
      */
-    boolean trash(Network network, NetworkOffering offering, Account owner);
+    boolean trash(Network network, NetworkOffering offering);
 
     void updateNetworkProfile(NetworkProfile networkProfile);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
index 5f21eb5..a773ac4 100644
--- a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
@@ -33,6 +33,7 @@ import com.cloud.exception.StorageUnavailableException;
 import com.cloud.host.Host;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.offering.DiskOffering;
+import com.cloud.storage.Snapshot;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.Volume;
 import com.cloud.storage.Volume.Type;
@@ -61,6 +62,8 @@ public interface VolumeOrchestrationService {
 
     String getVmNameOnVolume(Volume volume);
 
+    VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot) throws StorageUnavailableException;
+
     Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException;
 
     void destroyVolume(Volume volume);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/engine/components-api/pom.xml
----------------------------------------------------------------------
diff --git a/engine/components-api/pom.xml b/engine/components-api/pom.xml
index fdcac6a..55af5ee 100644
--- a/engine/components-api/pom.xml
+++ b/engine/components-api/pom.xml
@@ -35,11 +35,21 @@
     </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-engine-schema</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-framework-ipc</artifactId>
       <version>${project.version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-framework-events</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-framework-jobs</artifactId>
       <version>${project.version}</version>
     </dependency>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java b/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java
new file mode 100644
index 0000000..7dde815
--- /dev/null
+++ b/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java
@@ -0,0 +1,50 @@
+// 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 com.cloud.deploy.DeploymentPlanner.ExcludeList;
+import com.cloud.exception.AffinityConflictException;
+import com.cloud.exception.InsufficientServerCapacityException;
+import com.cloud.utils.component.Manager;
+import com.cloud.vm.VirtualMachineProfile;
+
+public interface DeploymentPlanningManager extends Manager {
+
+    /**
+     * Manages vm deployment stages: First Process Affinity/Anti-affinity - Call
+     * the chain of AffinityGroupProcessor adapters to set deploymentplan scope
+     * and exclude list Secondly, Call DeploymentPlanner - to use heuristics to
+     * find the best spot to place the vm/volume. Planner will drill down to the
+     * write set of clusters to look for placement based on various heuristics.
+     * Lastly, Call Allocators - Given a cluster, allocators matches the
+     * requirements to capabilities of the physical resource (host, storage
+     * pool).
+     *
+     * @throws AffinityConflictException
+     *
+     *
+     *
+     */
+    DeployDestination planDeployment(VirtualMachineProfile vmProfile, DeploymentPlan plan,
+            ExcludeList avoids) throws InsufficientServerCapacityException, AffinityConflictException;
+
+    String finalizeReservation(DeployDestination plannedDestination,
+            VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoids)
+            throws InsufficientServerCapacityException, AffinityConflictException;
+
+    void cleanupVMReservations();
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/engine/components-api/src/com/cloud/event/UsageEventUtils.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/event/UsageEventUtils.java b/engine/components-api/src/com/cloud/event/UsageEventUtils.java
new file mode 100644
index 0000000..b44ed32
--- /dev/null
+++ b/engine/components-api/src/com/cloud/event/UsageEventUtils.java
@@ -0,0 +1,168 @@
+// 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.event;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+
+import org.apache.cloudstack.framework.events.Event;
+import org.apache.cloudstack.framework.events.EventBus;
+import org.apache.cloudstack.framework.events.EventBusException;
+
+import com.cloud.dc.DataCenterVO;
+import com.cloud.dc.dao.DataCenterDao;
+import com.cloud.event.dao.UsageEventDao;
+import com.cloud.user.Account;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.component.ComponentContext;
+
+public class UsageEventUtils {
+
+    private static UsageEventDao _usageEventDao;
+    private static AccountDao _accountDao;
+    private static DataCenterDao _dcDao;
+    private static final Logger s_logger = Logger.getLogger(UsageEventUtils.class);
+    protected static EventBus _eventBus = null;
+
+    @Inject UsageEventDao usageEventDao;
+    @Inject AccountDao accountDao;
+    @Inject DataCenterDao dcDao;
+
+    public UsageEventUtils() {
+    }
+    
+    @PostConstruct
+    void init() {
+    	_usageEventDao = usageEventDao;
+    	_accountDao = accountDao;
+    	_dcDao = dcDao;
+    }
+    
+    public static void publishUsageEvent(String usageType, long accountId, long zoneId,
+                                         long resourceId, String resourceName,
+                                         Long offeringId, Long templateId, Long size,
+                                         String entityType, String entityUUID) {
+        saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, size);
+        publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID);
+    }
+
+    public static void publishUsageEvent(String usageType, long accountId, long zoneId,
+                                        long resourceId, String resourceName,
+                                        Long offeringId, Long templateId, Long size, Long virtualSize,
+                                        String entityType, String entityUUID) {
+        saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, size, virtualSize);
+        publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID);
+    }
+
+    public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId,
+                                         String resourceName, String entityType, String entityUUID) {
+        saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName);
+        publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID);
+    }
+
+    public static void publishUsageEvent(String usageType, long accountId, long zoneId,
+                                         long ipAddressId, String ipAddress, boolean isSourceNat,
+                                         String guestType, boolean isSystem, String entityType, String entityUUID) {
+        saveUsageEvent(usageType, accountId, zoneId, ipAddressId, ipAddress, isSourceNat, guestType, isSystem);
+        publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID);
+    }
+
+    public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId,
+                                         String resourceName, Long offeringId, Long templateId, String resourceType,
+                                         String entityType, String entityUUID) {
+        saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, resourceType);
+        publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID);
+    }
+
+    public static void publishUsageEvent(String usageType, long accountId,long zoneId, long vmId,
+                                         long securityGroupId, String entityType, String entityUUID) {
+        saveUsageEvent(usageType, accountId, zoneId, vmId, securityGroupId);
+        publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID);
+    }
+
+    public static void saveUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, Long size) {
+        _usageEventDao.persist( new UsageEventVO(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, size));
+    }
+
+    public static void saveUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, Long size, Long virtualSize) {
+        _usageEventDao.persist( new UsageEventVO(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, size, virtualSize));
+    }
+    public static void saveUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName) {
+        _usageEventDao.persist( new UsageEventVO(usageType, accountId, zoneId, resourceId, resourceName));
+    }
+
+    public static void saveUsageEvent(String usageType, long accountId, long zoneId, long ipAddressId, String ipAddress, boolean isSourceNat, String guestType, boolean isSystem) {
+        _usageEventDao.persist( new UsageEventVO(usageType, accountId, zoneId, ipAddressId, ipAddress, isSourceNat, guestType, isSystem));
+    }
+
+    public static void saveUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, String resourceType) {
+        _usageEventDao.persist( new UsageEventVO(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, resourceType));
+    }
+
+    public static void saveUsageEvent(String usageType, long accountId,long zoneId, long vmId, long securityGroupId) {
+        _usageEventDao.persist( new UsageEventVO( usageType, accountId, zoneId, vmId, securityGroupId));
+    }
+
+    private static void publishUsageEvent(String usageEventType, Long accountId, Long zoneId, String resourceType, String resourceUUID) {
+
+        try {
+            _eventBus = ComponentContext.getComponent(EventBus.class);
+        } catch(NoSuchBeanDefinitionException nbe) {
+            return; // no provider is configured to provide events bus, so just return
+        }
+
+        Account account = _accountDao.findById(accountId);
+        DataCenterVO dc = _dcDao.findById(zoneId);
+
+        // if account has been deleted, this might be called during cleanup of resources and results in null pointer
+        if (account == null)
+            return;
+
+        Event event = new Event(Name, EventCategory.USAGE_EVENT.getName(), usageEventType,
+                resourceType, resourceUUID);
+
+        Map<String, String> eventDescription = new HashMap<String, String>();
+        eventDescription.put("account", account.getUuid());
+        eventDescription.put("zone", dc.getUuid());
+        eventDescription.put("event", usageEventType);
+        eventDescription.put("resource", resourceType);
+        eventDescription.put("id", resourceUUID);
+
+        String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date());
+        eventDescription.put("eventDateTime", eventDate);
+
+        event.setDescription(eventDescription);
+
+        try {
+            _eventBus.publish(event);
+        } catch (EventBusException e) {
+            s_logger.warn("Failed to publish usage event on the the event bus.");
+        }
+    }
+
+    static final String Name = "management-server";
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/engine/components-api/src/com/cloud/network/IpAddressManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/network/IpAddressManager.java b/engine/components-api/src/com/cloud/network/IpAddressManager.java
new file mode 100644
index 0000000..0394ebb
--- /dev/null
+++ b/engine/components-api/src/com/cloud/network/IpAddressManager.java
@@ -0,0 +1,181 @@
+// 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;
+
+import java.util.List;
+
+import com.cloud.dc.DataCenter;
+import com.cloud.dc.Pod;
+import com.cloud.dc.Vlan.VlanType;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientAddressCapacityException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.addr.PublicIp;
+import com.cloud.network.dao.IPAddressVO;
+import com.cloud.network.rules.FirewallRule;
+import com.cloud.network.rules.StaticNat;
+import com.cloud.user.Account;
+import com.cloud.vm.NicProfile;
+import com.cloud.vm.VirtualMachineProfile;
+
+public interface IpAddressManager {
+    /**
+     * Assigns a new public ip address.
+     * 
+     * @param dcId
+     * @param podId
+     *            TODO
+     * @param owner
+     * @param type
+     * @param networkId
+     * @param requestedIp
+     *            TODO
+     * @param allocatedBy
+     *            TODO
+     * @return
+     * @throws InsufficientAddressCapacityException
+     */
+
+    PublicIp
+        assignPublicIpAddress(long dcId, Long podId, Account owner, VlanType type, Long networkId, String requestedIp, boolean isSystem) throws InsufficientAddressCapacityException;
+
+    /**
+     * Do all of the work of releasing public ip addresses. Note that if this method fails, there can be side effects.
+     * 
+     * @param userId
+     * @param caller
+     *            TODO
+     * @param IpAddress
+     * @return true if it did; false if it didn't
+     */
+    boolean disassociatePublicIpAddress(long id, long userId, Account caller);
+
+    boolean applyRules(List<? extends FirewallRule> rules, FirewallRule.Purpose purpose, NetworkRuleApplier applier, boolean continueOnError) throws ResourceUnavailableException;
+
+    /**
+     * @throws ResourceAllocationException TODO
+     * @throws InsufficientCapacityException
+     *             Associates an ip address list to an account. The list of ip addresses are all addresses associated
+     *             with the
+     *             given vlan id.
+     * @param userId
+     * @param accountId
+     * @param zoneId
+     * @param vlanId
+     * @throws InsufficientAddressCapacityException
+     * @throws
+     */
+    boolean associateIpAddressListToAccount(long userId, long accountId, long zoneId, Long vlanId, Network guestNetwork) throws InsufficientCapacityException,
+        ConcurrentOperationException,
+        ResourceUnavailableException,
+        ResourceAllocationException;
+
+    boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException;
+
+    boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError, List<? extends PublicIpAddress> publicIps) throws ResourceUnavailableException;
+
+    IPAddressVO markIpAsUnavailable(long addrId);
+
+    public String acquireGuestIpAddress(Network network, String requestedIp);
+
+    boolean applyStaticNats(List<? extends StaticNat> staticNats, boolean continueOnError, boolean forRevoke) throws ResourceUnavailableException;
+
+    IpAddress assignSystemIp(long networkId, Account owner, boolean forElasticLb, boolean forElasticIp) throws InsufficientAddressCapacityException;
+
+    boolean handleSystemIpRelease(IpAddress ip);
+
+    void
+        allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile vm, Network network, String requestedIpv4, String requestedIpv6) throws InsufficientVirtualNetworkCapcityException,
+            InsufficientAddressCapacityException;
+
+    /**
+     * @param owner
+     * @param guestNetwork
+     * @return
+     * @throws ConcurrentOperationException
+     * @throws InsufficientAddressCapacityException
+     */
+    PublicIp assignSourceNatIpAddressToGuestNetwork(Account owner, Network guestNetwork) throws InsufficientAddressCapacityException, ConcurrentOperationException;
+
+    /**
+     * @param ipAddrId
+     * @param networkId
+     * @param releaseOnFailure TODO
+     */
+    IPAddressVO associateIPToGuestNetwork(long ipAddrId, long networkId, boolean releaseOnFailure) throws ResourceAllocationException,
+        ResourceUnavailableException,
+        InsufficientAddressCapacityException,
+        ConcurrentOperationException;
+
+    IpAddress allocatePortableIp(Account ipOwner, Account caller, long dcId, Long networkId, Long vpcID) throws ConcurrentOperationException,
+        ResourceAllocationException,
+        InsufficientAddressCapacityException;
+
+    boolean releasePortableIpAddress(long addrId);
+
+    IPAddressVO associatePortableIPToGuestNetwork(long ipAddrId, long networkId, boolean releaseOnFailure) throws ResourceAllocationException,
+        ResourceUnavailableException,
+        InsufficientAddressCapacityException,
+        ConcurrentOperationException;
+
+    IPAddressVO disassociatePortableIPToGuestNetwork(long ipAddrId, long networkId) throws ResourceAllocationException,
+        ResourceUnavailableException,
+        InsufficientAddressCapacityException,
+        ConcurrentOperationException;
+
+    boolean isPortableIpTransferableFromNetwork(long ipAddrId, long networkId);
+
+    void transferPortableIP(long ipAddrId, long currentNetworkId, long newNetworkId) throws ResourceAllocationException,
+        ResourceUnavailableException,
+        InsufficientAddressCapacityException,
+        ConcurrentOperationException;;
+
+    /**
+     * @param addr
+     */
+    void markPublicIpAsAllocated(IPAddressVO addr);
+
+    /**
+     * @param owner
+     * @param guestNtwkId
+     * @param vpcId
+     * @param dcId
+     * @param isSourceNat
+     * @return
+     * @throws ConcurrentOperationException
+     * @throws InsufficientAddressCapacityException
+     */
+    PublicIp assignDedicateIpAddress(Account owner, Long guestNtwkId, Long vpcId, long dcId, boolean isSourceNat) throws ConcurrentOperationException,
+        InsufficientAddressCapacityException;
+
+    IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerId, DataCenter zone) throws ConcurrentOperationException,
+        ResourceAllocationException,
+        InsufficientAddressCapacityException;
+
+    PublicIp
+        assignPublicIpAddressFromVlans(long dcId, Long podId, Account owner, VlanType type, List<Long> vlanDbIds, Long networkId, String requestedIp, boolean isSystem) throws InsufficientAddressCapacityException;
+
+    int getRuleCountForIp(Long addressId, FirewallRule.Purpose purpose, FirewallRule.State state);
+
+    public String allocateGuestIP(Account ipOwner, boolean isSystem, long zoneId, Long networkId, String requestedIp) throws InsufficientAddressCapacityException;
+
+    String allocatePublicIpForGuestNic(Long networkId, DataCenter dc, Pod pod, Account caller, String requestedIp) throws InsufficientAddressCapacityException;
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/engine/components-api/src/com/cloud/network/addr/PublicIp.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/network/addr/PublicIp.java b/engine/components-api/src/com/cloud/network/addr/PublicIp.java
new file mode 100644
index 0000000..b18c691
--- /dev/null
+++ b/engine/components-api/src/com/cloud/network/addr/PublicIp.java
@@ -0,0 +1,235 @@
+// 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.addr;
+
+import java.util.Date;
+
+import com.cloud.dc.VlanVO;
+import com.cloud.network.PublicIpAddress;
+import com.cloud.network.dao.IPAddressVO;
+import com.cloud.utils.net.Ip;
+import com.cloud.utils.net.NetUtils;
+
+/**
+ */
+public class PublicIp implements PublicIpAddress {
+    IPAddressVO _addr;
+    VlanVO _vlan;
+    String macAddress;
+
+    public PublicIp(IPAddressVO addr, VlanVO vlan, long macAddress) {
+        _addr = addr;
+        _vlan = vlan;
+        this.macAddress = NetUtils.long2Mac(macAddress);
+    }
+
+    public static PublicIp createFromAddrAndVlan(IPAddressVO addr, VlanVO vlan) {
+    	return new PublicIp(addr, vlan, NetUtils.createSequenceBasedMacAddress(addr.getMacAddress()));
+    }
+    
+    @Override
+    public Ip getAddress() {
+        return _addr.getAddress();
+    }
+
+    @Override
+    public String getNetmask() {
+        return _vlan.getVlanNetmask();
+    }
+
+    @Override
+    public String getGateway() {
+        return _vlan.getVlanGateway();
+    }
+
+    @Override
+    public String getVlanTag() {
+        return _vlan.getVlanTag();
+    }
+
+    @Override
+    public long getDataCenterId() {
+        return _addr.getDataCenterId();
+    }
+
+    @Override
+    public boolean readyToUse() {
+        return _addr.getAllocatedTime() != null && _addr.getState() == State.Allocated;
+    }
+
+    @Override
+    public boolean isSourceNat() {
+        return _addr.isSourceNat();
+    }
+
+    @Override
+    public boolean isOneToOneNat() {
+        return _addr.isOneToOneNat();
+    }
+
+    @Override
+    public Long getAssociatedWithVmId() {
+        return _addr.getAssociatedWithVmId();
+    }
+
+    @Override
+    public Date getAllocatedTime() {
+        return _addr.getAllocatedTime();
+    }
+
+    @Override
+    public long getAccountId() {
+        return _addr.getAccountId();
+    }
+
+    @Override
+    public long getDomainId() {
+        return _addr.getDomainId();
+    }
+
+    @Override
+    public long getVlanId() {
+        return _vlan.getId();
+    }
+
+    @Override
+    public State getState() {
+        return _addr.getState();
+    }
+
+    public IPAddressVO ip() {
+        return _addr;
+    }
+
+    public VlanVO vlan() {
+        return _vlan;
+    }
+
+    @Override
+    public String getMacAddress() {
+        return macAddress;
+    }
+
+    @Override
+    public Long getAssociatedWithNetworkId() {
+        return _addr.getAssociatedWithNetworkId();
+    }
+
+    @Override
+    public Long getNetworkId() {
+        return _vlan.getNetworkId();
+    }
+
+    @Override
+    public String getVlanGateway() {
+        return _vlan.getVlanGateway();
+    }
+
+    @Override
+    public String getVlanNetmask() {
+        return _vlan.getVlanNetmask();
+    }
+
+    @Override
+    public String getIpRange() {
+        return _vlan.getIpRange();
+    }
+
+    @Override
+    public VlanType getVlanType() {
+        return _vlan.getVlanType();
+    }
+
+    @Override
+    public long getId() {
+        return _addr.getId();
+    }
+
+
+    @Override
+    public String getUuid() {
+        return _addr.getUuid();
+    }
+
+    @Override
+    public String toString() {
+        return _addr.getAddress().toString();
+    }
+
+    @Override
+    public Long getPhysicalNetworkId() {
+        return _vlan.getPhysicalNetworkId();
+    }
+
+	@Override
+	public void setState(State state) {
+		_addr.setState(state);
+	}
+
+	@Override
+	public Long getAllocatedToAccountId() {
+		return _addr.getAllocatedToAccountId();
+	}
+
+	@Override
+	public Long getAllocatedInDomainId() {
+		return _addr.getAllocatedInDomainId();
+	}
+
+	@Override
+    public boolean getSystem() {
+        return _addr.getSystem();
+    }
+	
+    @Override
+    public Long getVpcId() {
+       return _addr.getVpcId();
+    }
+
+    @Override
+    public String getIp6Gateway() {
+        return _vlan.getIp6Gateway();
+    }
+
+    @Override
+    public String getIp6Cidr() {
+        return _vlan.getIp6Cidr();
+    }
+
+    @Override
+    public String getIp6Range() {
+        return _vlan.getIp6Range();
+    }
+
+    @Override
+    public String getVmIp() {
+        return _addr.getVmIp();
+    }
+
+    @Override
+    public boolean isPortable() {
+        return _addr.isPortable();
+    }
+
+    public void setPortable(boolean portable) {
+        _addr.setPortable(portable);
+    }
+
+    public Long getIpMacAddress() {
+        return  _addr.getMacAddress();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java b/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java
new file mode 100644
index 0000000..3e32585
--- /dev/null
+++ b/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java
@@ -0,0 +1,62 @@
+// 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.lb;
+
+import java.util.List;
+
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.lb.LoadBalancingRule.LbDestination;
+import com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy;
+import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
+import com.cloud.network.rules.LbStickinessMethod;
+import com.cloud.network.rules.LoadBalancer;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+import com.cloud.user.Account;
+
+public interface LoadBalancingRulesManager {
+
+    LoadBalancer createPublicLoadBalancer(String xId, String name, String description,
+            int srcPort, int destPort, long sourceIpId, String protocol, String algorithm, boolean openFirewall, CallContext caller)
+            throws NetworkRuleConflictException;
+
+    boolean removeAllLoadBalanacersForIp(long ipId, Account caller, long callerUserId);
+    boolean removeAllLoadBalanacersForNetwork(long networkId, Account caller, long callerUserId);
+    List<LbDestination> getExistingDestinations(long lbId);
+    List<LbStickinessPolicy> getStickinessPolicies(long lbId);
+    List<LbStickinessMethod> getStickinessMethods(long networkid);
+    List<LbHealthCheckPolicy> getHealthCheckPolicies(long lbId);
+
+    /**
+     * Remove vm from all load balancers
+     * @param vmId
+     * @return true if removal is successful
+     */
+    boolean removeVmFromLoadBalancers(long vmId);
+    boolean applyLoadBalancersForNetwork(long networkId, Scheme scheme) throws ResourceUnavailableException;
+    String getLBCapability(long networkid, String capabilityName);
+    boolean configureLbAutoScaleVmGroup(long vmGroupid, String currentState) throws ResourceUnavailableException;
+    boolean revokeLoadBalancersForNetwork(long networkId, Scheme scheme) throws ResourceUnavailableException;
+
+    boolean validateLbRule(LoadBalancingRule lbRule);
+
+    void removeLBRule(LoadBalancer rule);
+
+    void isLbServiceSupportedInNetwork(long networkId, Scheme scheme);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/engine/components-api/src/com/cloud/template/TemplateManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/template/TemplateManager.java b/engine/components-api/src/com/cloud/template/TemplateManager.java
new file mode 100755
index 0000000..4c42ab7
--- /dev/null
+++ b/engine/components-api/src/com/cloud/template/TemplateManager.java
@@ -0,0 +1,115 @@
+// 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.template;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+
+import com.cloud.dc.DataCenterVO;
+import com.cloud.exception.InternalErrorException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.StorageUnavailableException;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.VMTemplateHostVO;
+import com.cloud.storage.VMTemplateStoragePoolVO;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.utils.Pair;
+
+/**
+ * TemplateManager manages the templates stored on secondary storage. It is responsible for creating private/public templates.
+ */
+public interface TemplateManager {
+
+    /**
+     * Prepares a template for vm creation for a certain storage pool.
+     *
+     * @param template
+     *            template to prepare
+     * @param pool
+     *            pool to make sure the template is ready in.
+     * @return VMTemplateStoragePoolVO if preparation is complete; null if not.
+     */
+    VMTemplateStoragePoolVO prepareTemplateForCreate(VMTemplateVO template, StoragePool pool);
+
+    boolean resetTemplateDownloadStateOnPool(long templateStoragePoolRefId);
+
+    /**
+     * Copies a template from its current secondary storage server to the secondary storage server in the specified zone.
+     *
+     * @param template
+     * @param srcSecStore
+     * @param destZone
+     * @return true if success
+     * @throws InternalErrorException
+     * @throws StorageUnavailableException
+     * @throws ResourceAllocationException
+     */
+    boolean copy(long userId, VMTemplateVO template, DataStore srcSecStore, DataCenterVO dstZone) throws StorageUnavailableException, ResourceAllocationException;
+
+    /**
+     * Deletes a template from secondary storage servers
+     *
+     * @param userId
+     * @param templateId
+     * @param zoneId
+     *            - optional. If specified, will only delete the template from the specified zone's secondary storage server.
+     * @return true if success
+     */
+    boolean delete(long userId, long templateId, Long zoneId);
+
+    /**
+     * Lists templates in the specified storage pool that are not being used by any VM.
+     *
+     * @param pool
+     * @return list of VMTemplateStoragePoolVO
+     */
+    List<VMTemplateStoragePoolVO> getUnusedTemplatesInPool(StoragePoolVO pool);
+
+    /**
+     * Deletes a template in the specified storage pool.
+     *
+     * @param templatePoolVO
+     */
+    void evictTemplateFromStoragePool(VMTemplateStoragePoolVO templatePoolVO);
+
+    boolean templateIsDeleteable(VMTemplateHostVO templateHostRef);
+
+    boolean templateIsDeleteable(long templateId);
+
+    Pair<String, String> getAbsoluteIsoPath(long templateId, long dataCenterId);
+
+    String getSecondaryStorageURL(long zoneId);
+
+    DataStore getImageStore(long zoneId, long tmpltId);
+
+    Long getTemplateSize(long templateId, long zoneId);
+
+    DataStore getImageStore(String storeUuid, Long zoneId);
+
+    String getChecksum(DataStore store, String templatePath);
+
+    List<DataStore> getImageStoreByTemplate(long templateId, Long zoneId);
+
+    TemplateInfo prepareIso(long isoId, long dcId);
+
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/engine/components-api/src/com/cloud/vm/ReservationContextImpl.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/vm/ReservationContextImpl.java b/engine/components-api/src/com/cloud/vm/ReservationContextImpl.java
new file mode 100644
index 0000000..b53841c
--- /dev/null
+++ b/engine/components-api/src/com/cloud/vm/ReservationContextImpl.java
@@ -0,0 +1,96 @@
+// 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.vm;
+
+import com.cloud.domain.Domain;
+import com.cloud.user.Account;
+import com.cloud.user.User;
+import com.cloud.utils.Journal;
+import com.cloud.utils.db.EntityManager;
+
+public class ReservationContextImpl implements ReservationContext {
+    User _caller;
+    Account _account;
+    Domain _domain;
+    Journal _journal;
+    String _reservationId;
+    
+    public ReservationContextImpl(String reservationId, Journal journal, User caller) {
+        this(reservationId, journal, caller, null, null);
+    }
+    
+    public ReservationContextImpl(String reservationId, Journal journal, User caller, Account account) {
+        this(reservationId, journal, caller, account, null);
+        
+    }
+    
+    public ReservationContextImpl(String reservationId, Journal journal, User caller, Account account, Domain domain) {
+        _caller = caller;
+        _account = account;
+        _domain = domain;
+        _journal = journal;
+        _reservationId = reservationId;
+    }
+    
+    @Override
+    public long getDomainId() {
+        return 0;
+    }
+
+    @Override
+    public long getAccountId() {
+        return _caller.getAccountId();
+    }
+
+    @Override
+    public User getCaller() {
+        return _caller;
+    }
+
+    @Override
+    public Account getAccount() {
+        if (_account == null) {
+            _account = s_entityMgr.findById(Account.class, _caller.getId());
+        }
+        return _account;
+    }
+
+    @Override
+    public Domain getDomain() {
+        if (_domain == null) {
+            getAccount();
+            _domain = s_entityMgr.findById(Domain.class, _account.getDomainId());
+        }
+        return _domain;
+    }
+
+    @Override
+    public Journal getJournal() {
+        return _journal;
+    }
+
+    @Override
+    public String getReservationId() {
+        return _reservationId;
+    }
+    
+    static EntityManager s_entityMgr;
+    
+    static public void init(EntityManager entityMgr) {
+        s_entityMgr = entityMgr;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/engine/components-api/src/com/cloud/vm/VirtualMachineProfileImpl.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/vm/VirtualMachineProfileImpl.java b/engine/components-api/src/com/cloud/vm/VirtualMachineProfileImpl.java
new file mode 100644
index 0000000..8282b16
--- /dev/null
+++ b/engine/components-api/src/com/cloud/vm/VirtualMachineProfileImpl.java
@@ -0,0 +1,258 @@
+// 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.vm;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.agent.api.to.DiskTO;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.service.ServiceOfferingVO;
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.template.VirtualMachineTemplate.BootloaderType;
+import com.cloud.user.Account;
+import com.cloud.utils.db.EntityManager;
+
+/**
+ * Implementation of VirtualMachineProfile.
+ *
+ */
+public class VirtualMachineProfileImpl implements VirtualMachineProfile {
+
+    VirtualMachine _vm;
+    ServiceOffering _offering;
+    VirtualMachineTemplate _template;
+    UserVmDetailVO _userVmDetails;
+    Map<Param, Object> _params;
+    List<NicProfile> _nics = new ArrayList<NicProfile>();
+    List<DiskTO> _disks = new ArrayList<DiskTO>();
+    StringBuilder _bootArgs = new StringBuilder();
+    Account _owner;
+    BootloaderType _bootloader;
+    Float cpuOvercommitRatio = 1.0f;
+    Float memoryOvercommitRatio = 1.0f;
+
+    VirtualMachine.Type _type;
+
+    public VirtualMachineProfileImpl(VirtualMachine vm, VirtualMachineTemplate template, ServiceOffering offering, Account owner, Map<Param, Object> params) {
+        _vm = vm;
+        _template = template;
+        _offering = offering;
+        _params = params;
+        _owner = owner;
+        if (_params == null) {
+            _params = new HashMap<Param, Object>();
+        }
+        if (vm != null)
+        	_type = vm.getType();
+    }
+
+    public VirtualMachineProfileImpl(VirtualMachine vm) {
+        this(vm, null, null, null, null);
+    }
+
+    public VirtualMachineProfileImpl(VirtualMachine.Type type) {
+        _type = type;
+    }
+
+    @Override
+    public String toString() {
+        return _vm.toString();
+    }
+
+    @Override
+    public VirtualMachine getVirtualMachine() {
+        return _vm;
+    }
+
+    @Override
+    public ServiceOffering getServiceOffering() {
+        if (_offering == null) {
+            _offering = s_entityMgr.findById(ServiceOffering.class, _vm.getServiceOfferingId());
+        }
+        return _offering;
+    }
+
+    @Override
+    public void setParameter(Param name, Object value) {
+        _params.put(name, value);
+    }
+
+    @Override
+    public void setBootLoaderType(BootloaderType bootLoader) {
+    	_bootloader = bootLoader;
+    }
+
+    @Override
+    public VirtualMachineTemplate getTemplate() {
+        if (_template == null && _vm != null) {
+            _template = s_entityMgr.findById(VirtualMachineTemplate.class, _vm.getTemplateId());
+        }
+        return _template;
+    }
+
+    @Override
+    public HypervisorType getHypervisorType() {
+        return _vm.getHypervisorType();
+    }
+
+    @Override
+    public long getTemplateId() {
+        return _vm.getTemplateId();
+    }
+
+    @Override
+    public long getServiceOfferingId() {
+        return _vm.getServiceOfferingId();
+    }
+
+    @Override
+    public long getId() {
+        return _vm.getId();
+    }
+
+    @Override
+    public String getUuid() {
+	return _vm.getUuid();
+    }
+
+    public void setNics(List<NicProfile> nics) {
+        _nics = nics;
+    }
+
+    public void setDisks(List<DiskTO> disks) {
+        _disks = disks;
+    }
+
+    @Override
+    public List<NicProfile> getNics() {
+        return _nics;
+    }
+
+    @Override
+    public List<DiskTO> getDisks() {
+        return _disks;
+    }
+
+    @Override
+    public void addNic(int index, NicProfile nic) {
+        _nics.add(index, nic);
+    }
+
+    @Override
+    public void addDisk(int index, DiskTO disk) {
+        _disks.add(index, disk);
+    }
+
+    @Override
+    public StringBuilder getBootArgsBuilder() {
+        return _bootArgs;
+    }
+
+    @Override
+    public void addBootArgs(String... args) {
+        for (String arg : args) {
+            _bootArgs.append(arg).append(" ");
+        }
+    }
+
+    @Override
+    public VirtualMachine.Type getType() {
+        return _type;
+    }
+
+    @Override
+    public Account getOwner() {
+        if (_owner == null) {
+            _owner = s_entityMgr.findById(Account.class, _vm.getAccountId());
+        }
+        return _owner;
+    }
+
+    @Override
+    public String getBootArgs() {
+        return _bootArgs.toString();
+    }
+
+    static EntityManager s_entityMgr;
+
+    static void init(EntityManager entityMgr) {
+        s_entityMgr = entityMgr;
+    }
+
+    @Override
+    public void addNic(NicProfile nic) {
+        _nics.add(nic);
+    }
+
+    @Override
+    public void addDisk(DiskTO disk) {
+        _disks.add(disk);
+    }
+
+    @Override
+    public Object getParameter(Param name) {
+        return _params.get(name);
+    }
+
+    @Override
+    public String getHostName() {
+        return _vm.getHostName();
+    }
+
+    @Override
+    public String getInstanceName() {
+        return _vm.getInstanceName();
+    }
+
+	@Override
+	public BootloaderType getBootLoaderType() {
+		return _bootloader;
+	}
+
+	@Override
+	public Map<Param, Object> getParameters() {
+	    return _params;
+	}
+
+	public void setServiceOffering(ServiceOfferingVO offering) {
+		_offering = offering;
+	}
+
+    public void setCpuOvercommitRatio(Float cpuOvercommitRatio) {
+        this.cpuOvercommitRatio = cpuOvercommitRatio;
+
+    }
+
+    public void setMemoryOvercommitRatio(Float memoryOvercommitRatio) {
+        this.memoryOvercommitRatio = memoryOvercommitRatio;
+
+    }
+
+    @Override
+    public Float getCpuOvercommitRatio() {
+        return  cpuOvercommitRatio;
+    }
+
+    @Override
+    public Float getMemoryOvercommitRatio() {
+        return memoryOvercommitRatio;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e5bb63f/engine/orchestration/pom.xml
----------------------------------------------------------------------
diff --git a/engine/orchestration/pom.xml b/engine/orchestration/pom.xml
index 4f8e5d7..290a4d4 100755
--- a/engine/orchestration/pom.xml
+++ b/engine/orchestration/pom.xml
@@ -45,6 +45,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-framework-events</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-engine-components-api</artifactId>
       <version>${project.version}</version>
     </dependency>
@@ -57,10 +62,9 @@
       <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-server</artifactId>
       <version>${project.version}</version>
-    </dependency>    
+    </dependency>
   </dependencies>
   <build>
-    <defaultGoal>install</defaultGoal>
     <plugins>
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>


Mime
View raw message