API Guide

After getting all Services we print the id, name, and status of each. Services that are still in the act of being deployed will have a
status of IN_PROGRESS. So calling this method with the Deployment Id as a path parameter can also be used to periodically poll a
Deployment to nd out when it has nished.
Deploy a new Service
Here, after having previously gotten an existing ServiceTemplate by name, and saved it to a le, we then set the required parameters
in the ServiceTemplate le, and nally embed the ServiceTemplate into a prefabricated Deployment structure that is read from a le.
As mentioned previously we can monitor the status of this Deployment by performing a GET with the deployment id as a path
parameter.
require 'ASMConfig'
url = ASM::API::URI('/Deployment')
template_name = 'TwoServers'
template = ASM::Payload::load_xml("%s.xml"%template_name)
deployment = ASM::Payload::load_xml('deployment_skeleton.xml')
# Set Deployment parameters
deployment.set("deploymentName", 'ManualAPIDeploymentDeux')
deployment.set("deploymentDescription", 'Manual API Deployment')
deployment.set("numberOfDeployments", '1')
# Inject the template into the deployment
deployment.replaceInner('serviceTemplate', template.doc.at_xpath('ServiceTemplate'))
deployment.save_xml('deploy_payload.xml')
response = ASM::API::sign {
RestClient.post url, deployment.to_xml, :content_type => :xml
}
doc = Nokogiri::parse(response)
deploymentId = doc.xpath('//Deployment/id').text
print "<id>%s</id>\n" % deploymentId
Tear down a Service
In order to completely tear down a Service we set the teardown element to true for all components in the Deployment plus the
Deployment itself, and then we PUT this Deployment back to ASM.
require 'ASMConfig'
deploymentId = "ff8080814aba74ce014ac455e9b80951"
url = ASM::API::URI("/Deployment/%s"%deploymentId)
response = ASM::API::sign {
RestClient.get url
}
payload = ASM::Payload.from_xml(response)
payload.set('Deployment/teardown', 'true')
payload.set_all('components/teardown', 'true')
payload.save_xml('teardown.xml')
response = ASM::API::sign {
RestClient.put url, payload.to_xml, :content_type => :xml
}
doc = Nokogiri::parse(response)
deploymentId = doc.xpath('//Deployment/id').text
jobStatus = doc.xpath('//Deployment/jobStatus').text
print "<jobStatus>%s</jobStatus>\n" % jobStatus
21