Skip to content
Permalink
Browse files
fixed the formatting in all the files and added the license to each f…
…ile: This closes #4

Signed-off-by: Sebastien Goasguen <runseb@gmail.com>
  • Loading branch information
cloudops-wstevens authored and sebgoa committed May 28, 2014
1 parent 4629e02 commit e55976f35a822e2a369b1341db35307b2cb2dde2
Showing 15 changed files with 2,342 additions and 1,606 deletions.

Large diffs are not rendered by default.

@@ -1,3 +1,19 @@
.. 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.
Allocators
==========

@@ -14,45 +30,47 @@ These are following categories of allocators currently supported:
determine which storage pool to allocate the guest virtual machines
on.


Implementing a custom HostAllocator
-----------------------------------

HostAllocators are written by extending
com.cloud.agent.manager.allocator.HostAllocator interface.


HostAllocator Interface
~~~~~~~~~~~~~~~~~~~~~~~

The interface defines the following two methods.

::

/**
* Checks if the VM can be upgraded to the specified ServiceOffering
* @param UserVm vm
* @param ServiceOffering offering
* @return boolean true if the VM can be upgraded
**/

publicboolean isVirtualMachineUpgradable(final UserVm vm, final ServiceOffering offering);

/**
* Determines which physical hosts are suitable to allocate the guest virtual machines on
*
* @paramVirtualMachineProfile vmProfile
* @paramDeploymentPlan plan
* @paramType type
* @paramExcludeList avoid
* @paramint returnUpTo
* @returnList<Host>List of hosts that are suitable for VM allocation
**/

publicList<Host> allocateTo( VirtualMachineProfile<?extendsVirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, intreturnUpTo);
/**
* Checks if the VM can be upgraded to the specified ServiceOffering
* @param UserVm vm
* @param ServiceOffering offering
* @return boolean true if the VM can be upgraded
**/

publicboolean isVirtualMachineUpgradable(final UserVm vm, final ServiceOffering offering);

/**
* Determines which physical hosts are suitable to allocate the guest virtual machines on
*
* @paramVirtualMachineProfile vmProfile
* @paramDeploymentPlan plan
* @paramType type
* @paramExcludeList avoid
* @paramint returnUpTo
* @returnList<Host>List of hosts that are suitable for VM allocation
**/

publicList<Host> allocateTo( VirtualMachineProfile<?extendsVirtualMachine> vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, intreturnUpTo);

A custom HostAllocator can be written by implementing the ‘allocateTo’
method


Input Parameters for the method ‘HostAllocator :: allocateTo’
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@@ -124,6 +142,7 @@ This specifies return up to that many available hosts for this guest VM.

To get all possible hosts, set this value to -1.


Reference HostAllocator implementation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@@ -135,38 +154,41 @@ given ServiceOffering requirements.
If returnUpTo = 1, this allocator would return the first Host that fits
the requirements of the guest VM.


Loading a custom HostAllocator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1. Write a custom HostAllocator class, implementing the interface
#. Write a custom HostAllocator class, implementing the interface
described above.

2. Package the code into a JAR file and make the JAR available in the
#. Package the code into a JAR file and make the JAR available in the
classpath of the Management Server/tomcat.

3. Modify the components.xml and components-premium.xml files found in
#. Modify the components.xml and components-premium.xml files found in
/client/ tomcatconf as follows.

4. Search for ‘HostAllocator’ in these files.
#. Search for ‘HostAllocator’ in these files.

::

<adapters key="com.cloud.agent.manager.allocator.HostAllocator">
<adapter name="FirstFit" class="com.cloud.agent.manager.allocator.impl.FirstFitAllocator"/>
</adapters>
<adapters key="com.cloud.agent.manager.allocator.HostAllocator">
<adapter name="FirstFit" class="com.cloud.agent.manager.allocator.impl.FirstFitAllocator"/>
</adapters>

5. Replace the FirstFitAllocator with your class name. Optionally, you
#. Replace the FirstFitAllocator with your class name. Optionally, you
can change the name of the adapter as well.

6. Restart the Management Server.
#. Restart the Management Server.


Implementing a custom StoragePoolAllocator
------------------------------------------

StoragePoolAllocators are written by extending
com.cloud.storage.allocator. StoragePoolAllocator interface.


StoragePoolAllocator Interface
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@@ -175,24 +197,25 @@ A custom StoragePoolAllocator can be written by implementing the

::

/**
* Determines which storage pools are suitable for the guest virtual machine
* @param DiskProfile dskCh
* @param VirtualMachineProfile vmProfile
* @param DeploymentPlan plan
* @param ExcludeList avoid
* @param int returnUpTo
* @return List<StoragePool> List of storage pools that are suitable for the VM
**/

public List<StoragePool> allocateToPool(DiskProfile dskCh, VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid, int returnUpTo);
/**
* Determines which storage pools are suitable for the guest virtual machine
* @param DiskProfile dskCh
* @param VirtualMachineProfile vmProfile
* @param DeploymentPlan plan
* @param ExcludeList avoid
* @param int returnUpTo
* @return List<StoragePool> List of storage pools that are suitable for the VM
**/

public List<StoragePool> allocateToPool(DiskProfile dskCh, VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid, int returnUpTo);

This interface also contains some other methods to support some legacy
code. However your custom allocator can extend the existing
com.cloud.storage.allocator. AbstractStoragePoolAllocator. This class
provides default implementation for all the other interface methods.


Input Parameters for the method ‘StoragePoolAllocator :: allocateTo’
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@@ -253,6 +276,7 @@ This specifies return up to that many available pools for this guest VM

To get all possible pools, set this value to -1


Reference StoragePoolAllocator implementation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@@ -264,29 +288,28 @@ considering the given DiskProfile characteristics.
If returnUpTo = 1, this allocator would return the first Storage Pool
that fits the requirements of the guest VM.


Loading a custom StoragePoolAllocator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1. Write a custom StoragePoolAllocator class, implementing the interface
#. Write a custom StoragePoolAllocator class, implementing the interface
described above.

2. Package the code into a JAR file and make the JAR available in the
#. Package the code into a JAR file and make the JAR available in the
classpath of the Management Server/tomcat.

3. Modify the components.xml and components-premium.xml files found in
#. Modify the components.xml and components-premium.xml files found in
/client/ tomcatconf as follows.

4. Search for ‘StoragePoolAllocator’ in these files.
#. Search for ‘StoragePoolAllocator’ in these files.

::

<adapters key="com.cloud.storage.allocator.StoragePoolAllocator">
<adapter name="Storage" class="com.cloud.storage.allocator.FirstFitStoragePoolAllocator"/>
</adapters>
5. Replace the FirstFitStoragePoolAllocator with your class name.
#. Replace the FirstFitStoragePoolAllocator with your class name.
Optionally, you can change the name of the adapter as well.

6. Restart the Management Server.


#. Restart the Management Server.

0 comments on commit e55976f

Please sign in to comment.