beautypg.com

Customizing existing rules – HP Matrix Operating Environment Software User Manual

Page 63

background image

rule "INIT"
salience 1000
when
pVO : PolicyExecutionVO();
then
insert(pVO.getAllocationEntry().getServiceEntity());
insert(pVO.getResultMap());
insert(pVO.getResourceList());
end

/*
* Rule to check memory criteria for a given service entity
* (LogicalServer) compared to list of physical resources available
* (ComputeServer)
*
*/

rule "MemorySizeCriteria"

when

$pVO : PolicyExecutionVO( );
$resLst : List();

$logicalServer : LogicalServer();
$computeServer : ComputeServer() from $resLst;

eval(memorySizeCriteria($logicalServer, $computeServer, $pVO));

then

$pVO.match($computeServer, HPIOMessage.get(HPIOBundleKey.ALLOCATION_CRITERIA_MEMORY));

end

function boolean memorySizeCriteria(
LogicalServer logicalServer,
ComputeServer computeServer,
PolicyExecutionVO pVO) {

pVO.doesNotMatch(computeServer,HPIOMessage.get(HPIOBundleKey.ALLOCATION_CRITERIA_MEMORY));

/* -------------- CUSTOM LOGIC ----------------------*/
Integer logicalMemorySizeMB = LogicalServerWrapper.getMemorySizeMi(logicalServer);

if (computeServer.getMemoryConsumedMB() == null) {
computeServer.setMemoryConsumedMB(0);
}
Integer resourceMemorySizeMB = computeServer.getMemorySizeMB() - computeServer.getMemoryConsumedMB();

if(logicalMemorySizeMB.doubleValue() <= resourceMemorySizeMB.doubleValue()){
return true;
}else{
return false;
}
/* -------------- CUSTOM LOGIC ----------------------*/

Customizing existing rules

The advantage of providing a rules based allocation fitting process is that you can customize the
existing rules to change the business logic by modifying the CUSTOM LOGIC portion of the code.
You can modify or delete existing rules, or add new custom rules. Rules are written in Java and
the Drools syntax.

Available hooks for customizing:

SubnetPolicyCheck.applyFitting

AttributeBasedSubnetPolicyCheck.applyFitting

SpecifiedSubnetPolicyCheck.applyFitting

AutomaticIpAddressPolicyCheck.applyFitting

StaticIpAddressPolicyCheck.applyFitting

DhcpIpAddressPolicyCheck.applyFitting

PhysicalServerPolicyCheck.applyFitting

PhysicalBootDiskPolicyCheck.applyFitting

NPIVDataDiskPolicyCheck.applyFitting

VirtualServerPolicyCheck.applyFitting

Customizable allocation process

63