Skip to content

Instantly share code, notes, and snippets.

@sergiopena
Created February 12, 2013 16:49
Show Gist options
  • Save sergiopena/4771273 to your computer and use it in GitHub Desktop.
Save sergiopena/4771273 to your computer and use it in GitHub Desktop.
create enterprise
#!/usr/bin/env ruby
require 'rubygems'
require 'curb'
require 'xmlsimple'
require 'builder'
ip_server = '10.60.13.7'
id_datacenter = '1'
api_username = 'admin'
api_password = 'xabiquo'
builder = Builder::XmlMarkup.new("")
p builder.enterprise { |e|
e.cpuHard("0")
e.cpuSoft("0")
e.hdHard("0")
e.hdSoft("0")
e.publicIpsHard("0")
e.publicIpsSoft("0")
e.ramHard("0")
e.ramSoft("0")
e.storageHard("0")
e.storageSoft("0")
e.vlansHard("0")
e.vlansSoft("0")
e.repositoryHard("0")
e.repositorySoft("0")
e.name("test4")
}
enterprise_url = 'http://'+ip_server+'/api/admin/enterprises'
c = Curl::Easy.http_post(enterprise_url,builder.enterprise)
c.username = api_username
c.verbose = true
c.password = api_password
c.enable_cookies = true
c.headers['Accept'] = 'application/vnd.abiquo.enterprise+xml;version=2.2'
c.headers['Content-type'] = 'application/vnd.abiquo.enterprise+xml;version=2.2'
c.perform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment