cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [6/8] git commit: updated refs/heads/vmsync to aff0220
Date Thu, 13 Jun 2013 23:34:39 GMT
Complete the move of the virtualmachinemanager to cloud-engine


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

Branch: refs/heads/vmsync
Commit: 3ef77bc85abef67d99b088301138d87b10636c7e
Parents: fbe76f0
Author: Alex Huang <alex.huang@gmail.com>
Authored: Thu Jun 13 13:48:28 2013 -0700
Committer: Alex Huang <alex.huang@gmail.com>
Committed: Thu Jun 13 13:50:59 2013 -0700

----------------------------------------------------------------------
 .../agent/manager/allocator/HostAllocator.java  |   85 +
 .../src/com/cloud/alert/AlertManager.java       |   58 +
 .../com/cloud/ha/HighAvailabilityManager.java   |  114 +
 .../cloud/hypervisor/HypervisorGuruManager.java |   27 +
 .../com/cloud/network/rules/RulesManager.java   |   66 +
 .../src/com/cloud/resource/Discoverer.java      |   51 +
 .../src/com/cloud/resource/ResourceManager.java |  153 +
 .../cloud/resource/ResourceStateAdapter.java    |   63 +
 .../com/cloud/vm/ReservationContextImpl.java    |   94 +
 .../src/com/cloud/vm/VirtualMachineManager.java |    3 +
 .../cloud/vm/snapshot/VMSnapshotManager.java    |   47 +
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 3570 ++++++++++++++++++
 .../cloud/vm/VirtualMachinePowerStateSync.java  |   32 +
 .../vm/VirtualMachinePowerStateSyncImpl.java    |  131 +
 .../src/com/cloud/vm/VmWorkJobDispatcher.java   |   88 +
 .../src/com/cloud/vm/VmWorkStart.java           |  120 +
 .../src/com/cloud/vm/VmWorkStop.java            |   34 +
 .../cloud/async/AsyncJobExecutionContext.java   |  173 +
 .../manager/allocator/impl/RandomAllocator.java |    7 +-
 .../agent/manager/allocator/HostAllocator.java  |   86 -
 .../allocator/impl/FirstFitAllocator.java       |   48 +-
 .../allocator/impl/TestingAllocator.java        |    5 +-
 server/src/com/cloud/alert/AlertManager.java    |   58 -
 .../src/com/cloud/api/StringMapTypeAdapter.java |   46 -
 .../cloud/async/AsyncJobExecutionContext.java   |  173 -
 .../com/cloud/async/AsyncJobManagerImpl.java    |    5 +-
 .../src/com/cloud/capacity/CapacityManager.java |    5 +-
 .../com/cloud/capacity/CapacityManagerImpl.java |    7 +-
 server/src/com/cloud/configuration/Config.java  |    3 +-
 .../configuration/ConfigurationManager.java     |   17 -
 .../configuration/ConfigurationManagerImpl.java |   29 -
 .../com/cloud/ha/HighAvailabilityManager.java   |  114 -
 .../cloud/hypervisor/HypervisorGuruManager.java |   27 -
 .../com/cloud/network/rules/RulesManager.java   |   66 -
 server/src/com/cloud/resource/Discoverer.java   |   51 -
 .../src/com/cloud/resource/ResourceManager.java |  153 -
 .../cloud/resource/ResourceStateAdapter.java    |   63 -
 .../com/cloud/vm/ReservationContextImpl.java    |   94 -
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 3560 -----------------
 .../cloud/vm/VirtualMachinePowerStateSync.java  |   32 -
 .../vm/VirtualMachinePowerStateSyncImpl.java    |  132 -
 .../src/com/cloud/vm/VmWorkJobDispatcher.java   |   85 -
 server/src/com/cloud/vm/VmWorkStart.java        |  120 -
 server/src/com/cloud/vm/VmWorkStop.java         |   34 -
 .../cloud/vm/snapshot/VMSnapshotManager.java    |   47 -
 .../cloudstack/messagebus/TopicConstants.java   |   26 -
 .../src/com/cloud/api/StringMapTypeAdapter.java |   46 +
 47 files changed, 4994 insertions(+), 5054 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/api/src/com/cloud/agent/manager/allocator/HostAllocator.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/manager/allocator/HostAllocator.java b/api/src/com/cloud/agent/manager/allocator/HostAllocator.java
new file mode 100755
index 0000000..dbfe893
--- /dev/null
+++ b/api/src/com/cloud/agent/manager/allocator/HostAllocator.java
@@ -0,0 +1,85 @@
+// 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.agent.manager.allocator;
+
+import java.util.List;
+
+import com.cloud.deploy.DeploymentPlan;
+import com.cloud.deploy.DeploymentPlanner.ExcludeList;
+import com.cloud.host.Host;
+import com.cloud.host.Host.Type;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.utils.component.Adapter;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+
+public interface HostAllocator extends Adapter {
+
+	/**
+	 * @param UserVm vm
+	 * @param ServiceOffering offering
+	 **/
+	boolean isVirtualMachineUpgradable(final VirtualMachine vm, final ServiceOffering offering);
+
+	/**
+	* Determines which physical hosts are suitable to
+	* allocate the guest virtual machines on
+	* 
+	* @param VirtualMachineProfile vmProfile
+	* @param DeploymentPlan plan
+	* @param GuestType type
+	* @param ExcludeList avoid
+	* @param int returnUpTo (use -1 to return all possible hosts)
+	* @return List<Host> List of hosts that are suitable for VM allocation
+	**/
+	
+    public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan,
Type type, ExcludeList avoid, int returnUpTo);
+	
+    /**
+    * Determines which physical hosts are suitable to
+    * allocate the guest virtual machines on
+    * 
+    * @param VirtualMachineProfile vmProfile
+    * @param DeploymentPlan plan
+    * @param GuestType type
+    * @param ExcludeList avoid
+    * @param int returnUpTo (use -1 to return all possible hosts)
+    * @param boolean considerReservedCapacity (default should be true, set to false if host
capacity calculation should not look at reserved capacity)
+    * @return List<Host> List of hosts that are suitable for VM allocation
+    **/
+    
+    public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan,
Type type, ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity);
+
+    /**
+     * Determines which physical hosts are suitable to
+     * allocate the guest virtual machines on
+     *
+     * @param VirtualMachineProfile vmProfile
+     * @param DeploymentPlan plan
+     * @param GuestType type
+     * @param ExcludeList avoid
+     * @param List<HostVO> hosts
+     * @param int returnUpTo (use -1 to return all possible hosts)
+     * @param boolean considerReservedCapacity (default should be true, set to false if host
capacity calculation should not look at reserved capacity)
+     * @return List<Host> List of hosts that are suitable for VM allocation
+     **/
+    public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan,
Type type, ExcludeList avoid, List<? extends Host> hosts, int returnUpTo,
+            boolean considerReservedCapacity);
+
+     public static int RETURN_UPTO_ALL = -1;
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/engine/components-api/src/com/cloud/alert/AlertManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/alert/AlertManager.java b/engine/components-api/src/com/cloud/alert/AlertManager.java
new file mode 100755
index 0000000..b6d005a
--- /dev/null
+++ b/engine/components-api/src/com/cloud/alert/AlertManager.java
@@ -0,0 +1,58 @@
+// 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.alert;
+
+import com.cloud.capacity.CapacityVO;
+import com.cloud.utils.component.Manager;
+
+public interface AlertManager extends Manager {
+    public static final short ALERT_TYPE_MEMORY = CapacityVO.CAPACITY_TYPE_MEMORY;
+    public static final short ALERT_TYPE_CPU = CapacityVO.CAPACITY_TYPE_CPU;
+    public static final short ALERT_TYPE_STORAGE = CapacityVO.CAPACITY_TYPE_STORAGE;
+    public static final short ALERT_TYPE_STORAGE_ALLOCATED = CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED;
+    public static final short ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = CapacityVO.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP;
+    public static final short ALERT_TYPE_PRIVATE_IP = CapacityVO.CAPACITY_TYPE_PRIVATE_IP;
+    public static final short ALERT_TYPE_SECONDARY_STORAGE = CapacityVO.CAPACITY_TYPE_SECONDARY_STORAGE;
+    public static final short ALERT_TYPE_HOST = 7;
+    public static final short ALERT_TYPE_USERVM = 8;
+    public static final short ALERT_TYPE_DOMAIN_ROUTER = 9;
+    public static final short ALERT_TYPE_CONSOLE_PROXY = 10;
+    public static final short ALERT_TYPE_ROUTING = 11; // lost connection to default route
(to the gateway)
+    public static final short ALERT_TYPE_STORAGE_MISC = 12; // lost connection to default
route (to the gateway)
+    public static final short ALERT_TYPE_USAGE_SERVER = 13; // lost connection to default
route (to the gateway)
+    public static final short ALERT_TYPE_MANAGMENT_NODE = 14; // lost connection to default
route (to the gateway)
+    public static final short ALERT_TYPE_DOMAIN_ROUTER_MIGRATE = 15;
+    public static final short ALERT_TYPE_CONSOLE_PROXY_MIGRATE = 16;
+    public static final short ALERT_TYPE_USERVM_MIGRATE = 17;
+    public static final short ALERT_TYPE_VLAN = 18;
+    public static final short ALERT_TYPE_SSVM = 19;
+    public static final short ALERT_TYPE_USAGE_SERVER_RESULT = 20; // Usage job result
+    public static final short ALERT_TYPE_STORAGE_DELETE = 21;
+    public static final short ALERT_TYPE_UPDATE_RESOURCE_COUNT = 22; // Generated when we
fail to update the resource
+    // count
+    public static final short ALERT_TYPE_USAGE_SANITY_RESULT = 23;
+    public static final short ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 24;
+    public static final short ALERT_TYPE_LOCAL_STORAGE = 25;
+    public static final short ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED = 26; // Generated when
the resource limit exceeds the limit. Currently used for recurring snapshots only
+
+
+    void clearAlert(short alertType, long dataCenterId, long podId);
+
+    void sendAlert(short alertType, long dataCenterId, Long podId, String subject, String
body);
+
+    void recalculateCapacity();
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/engine/components-api/src/com/cloud/ha/HighAvailabilityManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/ha/HighAvailabilityManager.java b/engine/components-api/src/com/cloud/ha/HighAvailabilityManager.java
new file mode 100644
index 0000000..dd0b3e6
--- /dev/null
+++ b/engine/components-api/src/com/cloud/ha/HighAvailabilityManager.java
@@ -0,0 +1,114 @@
+// 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.ha;
+
+import java.util.List;
+
+import com.cloud.host.HostVO;
+import com.cloud.host.Status;
+import com.cloud.utils.component.Manager;
+import com.cloud.vm.VMInstanceVO;
+
+/**
+ * HighAvailabilityManager checks to make sure the VMs are running fine.
+ */
+public interface HighAvailabilityManager extends Manager {
+    public enum WorkType {
+        Migration,  // Migrating VMs off of a host.
+        Stop,       // Stops a VM for storage pool migration purposes.  This should be obsolete
now.
+        CheckStop,  // Checks if a VM has been stopped.
+        ForceStop,  // Force a VM to stop even if the states don't allow it.  Use this only
if you know the VM is stopped on the physical hypervisor.
+        Destroy,    // Destroy a VM.
+        HA;         // Restart a VM.
+    }
+
+    enum Step {
+        Scheduled,
+        Investigating,
+        Fencing,
+        Stopping,
+        Restarting,
+        Migrating,
+        Cancelled,
+        Done,
+        Error,
+    }
+
+    /**
+     * Investigate why a host has disconnected and migrate the VMs on it
+     * if necessary.
+     * 
+     * @param host - the host that has disconnected.
+     */
+    Status investigate(long hostId);
+
+    /**
+     * Restart a vm that has gone away due to various reasons.  Whether a
+     * VM is restarted depends on various reasons.
+     *   1. Is the VM really dead.  This method will try to find out.
+     *   2. Is the VM HA enabled?  If not, the VM is simply stopped.
+     * 
+     * All VMs that enter HA mode is not allowed to be operated on until it
+     * has been determined that the VM is dead.
+     * 
+     * @param vm the vm that has gone away.
+     * @param investigate must be investigated before we do anything with this vm.
+     */
+    void scheduleRestart(VMInstanceVO vm, boolean investigate);
+
+    void cancelDestroy(VMInstanceVO vm, Long hostId);
+    
+    void scheduleDestroy(VMInstanceVO vm, long hostId);
+    
+    /**
+     * Schedule restarts for all vms running on the host.
+     * @param host host.
+     * @param investigate TODO
+     */
+    void scheduleRestartForVmsOnHost(HostVO host, boolean investigate);
+
+    /**
+     * Schedule the vm for migration.
+     * 
+     * @param vm
+     * @return true if schedule worked.
+     */
+    boolean scheduleMigration(VMInstanceVO vm);
+    
+    List<VMInstanceVO> findTakenMigrationWork();
+
+    /**
+     * Schedules a work item to stop a VM.  This method schedules a work
+     * item to do one of three things.
+     * 
+     * 1. Perform a regular stop of a VM: WorkType.Stop
+     * 2. Perform a force stop of a VM: WorkType.ForceStop
+     * 3. Check if a VM has been stopped: WorkType.CheckStop
+     * 
+     * @param vm virtual machine to stop.
+     * @param host host the virtual machine is on.
+     * @param type which type of stop is requested. 
+     */
+    void scheduleStop(VMInstanceVO vm, long hostId, WorkType type);
+
+    void cancelScheduledMigrations(HostVO host);
+
+    /**
+     * @return
+     */
+    String getHaTag();
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/engine/components-api/src/com/cloud/hypervisor/HypervisorGuruManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/hypervisor/HypervisorGuruManager.java b/engine/components-api/src/com/cloud/hypervisor/HypervisorGuruManager.java
new file mode 100644
index 0000000..5249750
--- /dev/null
+++ b/engine/components-api/src/com/cloud/hypervisor/HypervisorGuruManager.java
@@ -0,0 +1,27 @@
+// 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.hypervisor;
+
+import com.cloud.agent.api.Command;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.utils.component.Manager;
+
+public interface HypervisorGuruManager extends Manager {
+	HypervisorGuru getGuru(HypervisorType hypervisorType);
+    long getGuruProcessedCommandTargetHost(long hostId, Command cmd);
+}
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/engine/components-api/src/com/cloud/network/rules/RulesManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/network/rules/RulesManager.java b/engine/components-api/src/com/cloud/network/rules/RulesManager.java
new file mode 100644
index 0000000..201d79d
--- /dev/null
+++ b/engine/components-api/src/com/cloud/network/rules/RulesManager.java
@@ -0,0 +1,66 @@
+// 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.rules;
+
+import java.util.List;
+
+import com.cloud.exception.InsufficientAddressCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.IpAddress;
+import com.cloud.user.Account;
+import com.cloud.uservm.UserVm;
+import com.cloud.vm.Nic;
+import com.cloud.vm.VirtualMachine;
+
+/**
+ * Rules Manager manages the network rules created for different networks.
+ */
+public interface RulesManager extends RulesService {
+
+    boolean applyPortForwardingRulesForNetwork(long networkId, boolean continueOnError, Account
caller);
+
+    boolean applyStaticNatRulesForNetwork(long networkId, boolean continueOnError, Account
caller);
+
+    void checkRuleAndUserVm(FirewallRule rule, UserVm userVm, Account caller);
+
+    boolean revokeAllPFAndStaticNatRulesForIp(long ipId, long userId, Account caller) throws
ResourceUnavailableException;
+
+    boolean revokeAllPFStaticNatRulesForNetwork(long networkId, long userId, Account caller)
throws ResourceUnavailableException;
+
+    boolean revokePortForwardingRulesForVm(long vmId);
+
+    FirewallRule[] reservePorts(IpAddress ip, String protocol, FirewallRule.Purpose purpose,
boolean openFirewall, Account caller, int... ports) throws NetworkRuleConflictException;
+
+    boolean applyStaticNatsForNetwork(long networkId, boolean continueOnError, Account caller);
+
+    void getSystemIpAndEnableStaticNatForVm(VirtualMachine vm, boolean getNewIp) throws InsufficientAddressCapacityException;
+
+    boolean disableStaticNat(long ipAddressId, Account caller, long callerUserId, boolean
releaseIpIfElastic) throws ResourceUnavailableException;
+
+    /**
+     * @param networkId
+     * @param continueOnError
+     * @param caller
+     * @param forRevoke
+     * @return
+     */
+    boolean applyStaticNatForNetwork(long networkId, boolean continueOnError, Account caller,
boolean forRevoke);
+
+    List<FirewallRuleVO> listAssociatedRulesForGuestNic(Nic nic);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/engine/components-api/src/com/cloud/resource/Discoverer.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/resource/Discoverer.java b/engine/components-api/src/com/cloud/resource/Discoverer.java
new file mode 100755
index 0000000..9af7363
--- /dev/null
+++ b/engine/components-api/src/com/cloud/resource/Discoverer.java
@@ -0,0 +1,51 @@
+// 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.resource;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.exception.DiscoveryException;
+import com.cloud.host.HostVO;
+import com.cloud.hypervisor.Hypervisor;
+import com.cloud.utils.component.Adapter;
+
+/**
+ * Discoverer encapsulates interfaces that will discover resources.
+ *
+ */
+public interface Discoverer extends Adapter {
+    /**
+     * Given an accessible ip address, find out what it is.
+     * 
+     * @param url
+     * @param username
+     * @param password
+     * @return ServerResource
+     */
+    Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId,
Long clusterId, URI uri, String username, String password, List<String> hostTags) throws
DiscoveryException;
+
+	void postDiscovery(List<HostVO> hosts, long msId)  throws DiscoveryException;
+	
+	boolean matchHypervisor(String hypervisor);
+	Hypervisor.HypervisorType getHypervisorType();
+	public void putParam(Map<String, String> params);
+	
+	ServerResource reloadResource(HostVO host);
+	
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/engine/components-api/src/com/cloud/resource/ResourceManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/resource/ResourceManager.java b/engine/components-api/src/com/cloud/resource/ResourceManager.java
new file mode 100755
index 0000000..b0ab926
--- /dev/null
+++ b/engine/components-api/src/com/cloud/resource/ResourceManager.java
@@ -0,0 +1,153 @@
+// 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.resource;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.agent.api.StartupRoutingCommand;
+import com.cloud.dc.DataCenterVO;
+import com.cloud.dc.HostPodVO;
+import com.cloud.dc.PodCluster;
+import com.cloud.exception.AgentUnavailableException;
+import com.cloud.host.Host;
+import com.cloud.host.Host.Type;
+import com.cloud.host.HostStats;
+import com.cloud.host.HostVO;
+import com.cloud.host.Status;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.resource.ResourceState.Event;
+import com.cloud.service.ServiceOfferingVO;
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.utils.Pair;
+import com.cloud.utils.fsm.NoTransitionException;
+
+/**
+ * ResourceManager manages how physical resources are organized within the
+ * CloudStack. It also manages the life cycle of the physical resources.
+ */
+public interface ResourceManager extends ResourceService{
+    /**
+     * Register a listener for different types of resource life cycle events.
+     * There can only be one type of listener per type of host.
+     * 
+     * @param Event type see ResourceListener.java, allow combination of multiple events.
+     * @param listener the listener to notify.
+     */
+    public void registerResourceEvent(Integer event, ResourceListener listener);
+    
+    public void unregisterResourceEvent(ResourceListener listener);
+    
+    /**
+     * 
+     * @param name of adapter
+     * @param adapter
+     * @param hates, a list of names which will be eliminated by this adapter. Especially
for the case where 
+     * can be only one adapter responds to an event, e.g. startupCommand
+     */
+    public void registerResourceStateAdapter(String name, ResourceStateAdapter adapter);
+    
+    public void unregisterResourceStateAdapter(String name);
+    
+	public Host createHostAndAgent(Long hostId, ServerResource resource, Map<String, String>
details, boolean old, List<String> hostTags,
+	        boolean forRebalance);
+	
+	public Host addHost(long zoneId, ServerResource resource, Type hostType, Map<String,
String> hostDetails);
+	
+	public HostVO createHostVOForConnectedAgent(StartupCommand[] cmds);
+	
+	public void checkCIDR(HostPodVO pod, DataCenterVO dc, String serverPrivateIP, String serverPrivateNetmask);
+	
+	public HostVO fillRoutingHostVO(HostVO host, StartupRoutingCommand ssCmd, HypervisorType
hyType, Map<String, String> details, List<String> hostTags);
+	
+	public void deleteRoutingHost(HostVO host, boolean isForced, boolean forceDestroyStorage)
throws UnableDeleteHostException;
+	
+    public boolean executeUserRequest(long hostId, ResourceState.Event event) throws AgentUnavailableException;
+
+	boolean resourceStateTransitTo(Host host, Event event, long msId) throws NoTransitionException;
+
+	boolean umanageHost(long hostId);
+
+	boolean maintenanceFailed(long hostId);
+	
+	public boolean maintain(final long hostId) throws AgentUnavailableException;
+	
+    @Override
+    public boolean deleteHost(long hostId, boolean isForced, boolean isForceDeleteStorage);
+    
+    public List<HostVO> findDirectlyConnectedHosts();
+    
+    public List<HostVO> listAllUpAndEnabledHosts(Host.Type type, Long clusterId, Long
podId, long dcId);
+    
+    public List<HostVO> listAllHostsInCluster(long clusterId);
+    
+    public List<HostVO> listHostsInClusterByStatus(long clusterId, Status status);
+    
+    public List<HostVO> listAllUpAndEnabledHostsInOneZoneByType(Host.Type type, long
dcId);
+    public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType
type, long dcId);
+    
+    public List<HostVO> listAllHostsInOneZoneByType(Host.Type type, long dcId);
+    
+    public List<HostVO> listAllHostsInAllZonesByType(Type type);
+    
+    public List<HypervisorType> listAvailHypervisorInZone(Long hostId, Long zoneId);
+    
+    public HostVO findHostByGuid(String guid);
+    
+    public HostVO findHostByName(String name);
+    
+    public List<HostVO> listHostsByNameLike(String name);
+    
+    /**
+     * Find a pod based on the user id, template, and data center.
+     * 
+     * @param template
+     * @param dc
+     * @param userId
+     * @return
+     */
+    Pair<HostPodVO, Long> findPod(VirtualMachineTemplate template, ServiceOfferingVO
offering, DataCenterVO dc, long accountId, Set<Long> avoids);
+    
+    HostStats getHostStatistics(long hostId);
+    
+    Long getGuestOSCategoryId(long hostId);
+    
+    String getHostTags(long hostId);
+    
+    List<PodCluster> listByDataCenter(long dcId);
+
+	List<HostVO> listAllNotInMaintenanceHostsInOneZone(Type type, Long dcId);
+
+	HypervisorType getDefaultHypervisor(long zoneId);
+
+	HypervisorType getAvailableHypervisor(long zoneId);
+
+    Discoverer getMatchingDiscover(HypervisorType hypervisorType);
+
+	List<HostVO> findHostByGuid(long dcId, String guid);
+
+    /**
+     * @param type
+     * @param clusterId
+     * @param podId
+     * @param dcId
+     * @return
+     */
+    List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId,
long dcId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/engine/components-api/src/com/cloud/resource/ResourceStateAdapter.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/resource/ResourceStateAdapter.java b/engine/components-api/src/com/cloud/resource/ResourceStateAdapter.java
new file mode 100755
index 0000000..68e43f3
--- /dev/null
+++ b/engine/components-api/src/com/cloud/resource/ResourceStateAdapter.java
@@ -0,0 +1,63 @@
+// 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.resource;
+
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.agent.api.StartupAnswer;
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.exception.ConnectionException;
+import com.cloud.host.HostVO;
+import com.cloud.utils.component.Adapter;
+
+public interface ResourceStateAdapter extends Adapter {
+    static public enum Event {
+        CREATE_HOST_VO_FOR_CONNECTED,
+        CREATE_HOST_VO_FOR_DIRECT_CONNECT,
+        DELETE_HOST,
+    }
+    
+    static public class DeleteHostAnswer {
+        private boolean isContinue;
+        private boolean isException;
+        
+        public DeleteHostAnswer(boolean isContinue) {
+            this.isContinue = isContinue;
+            this.isException = false;
+        }
+        
+        public DeleteHostAnswer(boolean isContinue, boolean isException) {
+            this.isContinue = isContinue;
+            this.isException = isException;
+        }
+        
+        public boolean getIsContinue() {
+            return this.isContinue;
+        }
+        
+        public boolean getIsException() {
+            return this.isException;
+        }
+    }
+    
+    public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd);
+    
+    public HostVO createHostVOForDirectConnectAgent(HostVO host, final StartupCommand[] startup,
ServerResource resource, Map<String, String> details, List<String> hostTags);
+    
+    public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage)
throws UnableDeleteHostException;
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/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..cab93b4
--- /dev/null
+++ b/engine/components-api/src/com/cloud/vm/ReservationContextImpl.java
@@ -0,0 +1,94 @@
+// 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.dao.EntityManager;
+import com.cloud.domain.Domain;
+import com.cloud.domain.DomainVO;
+import com.cloud.user.Account;
+import com.cloud.user.User;
+import com.cloud.utils.Journal;
+
+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() {
+        return _account;
+    }
+
+    @Override
+    public Domain getDomain() {
+        if (_domain == null) {
+            getAccount();
+            _domain = s_entityMgr.findById(DomainVO.class, _account.getDomainId());
+        }
+        return _domain;
+    }
+
+    @Override
+    public Journal getJournal() {
+        return _journal;
+    }
+
+    @Override
+    public String getReservationId() {
+        return _reservationId;
+    }
+    
+    static EntityManager s_entityMgr;
+    
+    static public void setComponents(EntityManager entityMgr) {
+        s_entityMgr = entityMgr;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/engine/components-api/src/com/cloud/vm/VirtualMachineManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/vm/VirtualMachineManager.java b/engine/components-api/src/com/cloud/vm/VirtualMachineManager.java
index 83ec485..f1ace6c 100644
--- a/engine/components-api/src/com/cloud/vm/VirtualMachineManager.java
+++ b/engine/components-api/src/com/cloud/vm/VirtualMachineManager.java
@@ -65,6 +65,9 @@ import com.cloud.utils.fsm.NoTransitionException;
  * 
  */
 public interface VirtualMachineManager extends Manager {
+    public interface Topics {
+        public static final String VM_POWER_STATE = "vm.powerstate";
+    }
 
     boolean allocate(String vmInstanceName,
             VMTemplateVO template,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ef77bc8/engine/components-api/src/com/cloud/vm/snapshot/VMSnapshotManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/vm/snapshot/VMSnapshotManager.java b/engine/components-api/src/com/cloud/vm/snapshot/VMSnapshotManager.java
new file mode 100644
index 0000000..c609005
--- /dev/null
+++ b/engine/components-api/src/com/cloud/vm/snapshot/VMSnapshotManager.java
@@ -0,0 +1,47 @@
+// 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.snapshot;
+
+import com.cloud.utils.component.Manager;
+import com.cloud.vm.VMInstanceVO;
+
+public interface VMSnapshotManager extends VMSnapshotService, Manager {
+    public static final int VMSNAPSHOTMAX = 10;
+
+    
+    /**
+     * Delete all VM snapshots belonging to one VM
+     * @param id, VM id
+     * @param type, 
+     * @return true for success, false for failure
+     */
+    boolean deleteAllVMSnapshots(long id, VMSnapshot.Type type);
+
+    /**
+     * Sync VM snapshot state when VM snapshot in reverting or snapshoting or expunging state
+     * Used for fullsync after agent connects
+     * 
+     * @param vm, the VM in question
+     * @param hostId
+     * @return true if succeeds, false if fails
+     */
+    boolean syncVMSnapshot(VMInstanceVO vm, Long hostId);
+
+    boolean hasActiveVMSnapshotTasks(Long vmId);
+
+}


Mime
View raw message