<Protocol>
<ProtocolType>
<Uri>http://saf.com/types/protocols/compute_provision_increase</Uri>
</ProtocolType>
<PrescriptionType>
<Uri>http://saf.com/types/prescriptions/compute_provision_increase</Uri>
</PrescriptionType>
<ProtocolName>ProvisionAdditionalVMs</ProtocolName>
<Description>Provision additional virtual machines</Description>
<Effectiveness>Effective</Effectiveness>
<Risk>Moderate</Risk>
<Duration>Moderate</Duration>
<Function>Preventative</Function>
<Directive>
for $x in /Symptoms/Symptom
let $client_id := $x/Subject
let $change_percentage := fn:number($x/Content/SalesProjection/PercentageIncrease)
return
<Details>
<ClientID>$client_id</ClientID>
<ChangePercentage>$change_percentage</ChangePercentage>
<Details>
</Directive>
<PotentialSyndromes />
<Process>
#ruby
# arguments: $client.id, $change.percentage
# get current machines
get_response = RestClient.get(“http://saf.com/cimi/” + $client.id + “machines”)
# response resembles below
#<MachineCollection>
# <uri>http://saf.com/cimi/12345/machines</uri>
# <name>mymachines</name>
# <description>my machines</description>
# <created>2011-10-04T11:28:00</created>
# <machine href="" href="http://saf.com/cimi/12345/machine/mymachine1">http://saf.com/cimi/12345/machine/mymachine1” />
# <machine href="" href="http://saf.com/cimi/12345/machine/mymachine2">http://saf.com/cimi/12345/machine/mymachine2” />
# <machine href="" href="http://saf.com/cimi/12345/machine/mymachine3">http://saf.com/cimi/12345/machine/mymachine3” />
# <machine href="" href="http://saf.com/cimi/12345/machine/mymachine4">http://saf.com/cimi/12345/machine/mymachine4” />
# <operation rel=”add” href="" href="http://saf.com/cimi/12345/machines">http://saf.com/cimi/12345/machines” />
#</MachineCollection>
# determine number of additional machines required
$client_uri = “http://saf.com/cimi/” + $client.id + “machines”
$machine_count = XPath(count(response/MachineCollection[$client_uri]/machine
$new_machine_count = $machine_count * (1 + $change.percentage/100)
# add more capacity
do
begin
body = {
<MachineCreate>
<name>mymachineXXXXXX</name>
<machineTemplate href="" href="http://saf.com/cimi/">http://saf.com/cimi/” + $client.id + “machineTemplates/LinuxTemplate” />
</MachineCreate>
}
RestClient.post(get_response/MachineCollection/operation[@rel=’add’]/@href, body)
end
$new_machine_count = $new_machine_count - 1
while $new_machine_count >= 0
</Process>
</Protocol>
<!—The diagnostician creates the Prescription (instance) from the Protocol and participating Symptoms -->
<Prescription>
<PrescriptionId>http://saf.com/prescriptions/001</PrescriptionId>
<PrescriptionType> http://saf.com/types/prescriptions/ compute_provision_increase </PrescriptionType>
<ExpirationDate>2010-03-25T13:45</ExpirationDate>
<Arguments>
<Details>
<ClientID>http://saf.com/subjects/client-12345</ClientID>
<ChangePercentage>10</ChangePercentage>
</Details>
</Arguments>
<Process>
Same as above, in Protocol
</Process>
</Prescription>
<!—An example Symptom -->
<Symptom>
<SymptomId>http://saf.com/symptoms/salesprojection/1</SymptomId>
<SymptomType>
<Uri>http://saf.com/types/symptom/salesprojection</Uri>
</SymptomType>
<CreationDate>2011-10-24T13:10:05</CreationDate>
<Confidence>High</Confidence>
<Reporter>http://saf.com/reporters/salessensor-123</Reporter>
<Subject>http://saf.com/subjects/client-12345</Subject>
<ExpirationDate />
<RelatedSymptoms />
<Incident />
<Content>
<SalesProjection>
<Region>Global</Region>
<PercentageIncrease>10</PercentageIncrease>
</SalesProjection>
</Content>
</Symptom>
|