API Guide

Table Of Contents
Set the current timezone
Here we utilize the simple XML utility class called ASM::Payload to do simple manipulations of our XML.
require 'ASMConfig'
payload = ASM::Payload.load_xml('timezone.xml')
payload.set('timeZoneId','15')
# Set Timezone
response = ASM::API::sign {
url = ASM::API::URI("/Timezone")
RestClient.put url, payload.to_xml, :content_type => :xml
}
Credential
Credential objects can be created and referenced in ASM. These named credentials are used to gain
access to the various Resources during the Discovery process. Credentials are also typed according to
their target resource such as, Server, Storage, VCenter, IOM, Chassis, and SCVMM.
Get all defined Credentials
Default credentials are defined for several hardware types. These can be listed for the purpose of
obtaining their reference id’s needed for the Discovery process and to utilize as XML skeleton.
require 'ASMConfig'
url = ASM::API::URI('/Credential')
begin
response = ASM::API::sign {
RestClient.get url, :content_type => :xml
}
payload = ASM::Payload.from_xml(response)
payload.save_xml('credentials.xml')
rescue RestClient::Exception => e
print "Got exception with status: %d\n" % e.response.code
print "%s\n" % e.response
end
Define new Credential
Define a new Server Credential using a skeleton file previously saved to a file.
require 'ASMConfig'
url = ASM::API::URI('/Credential')
cred = ASM::Payload::load_xml('credential_skeleton.xml')
# Set Credential parameters
cred.set('label', 'ServerX')
cred.set('username', 'admin')
cred.set('password', 'abc123')
cred.set('protocol', '')
cred.set('snmpCommunityString', '')
19