Last active
August 29, 2015 14:00
-
-
Save chechuironman/de20a5cab4d3c1afa4a1 to your computer and use it in GitHub Desktop.
Simple Provisioning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
################################################################################## | |
# Create CCI | |
# ©Copyright IBM Corporation 2014. | |
# LICENSE: MIT (http://opensource.org/licenses/MIT) | |
# gems used: | |
# rubygems, softlayer-api | |
################################################################################## | |
require 'rubygems' | |
require 'softlayer_api' | |
$SL_API_USERNAME = "xxxxx" | |
$SL_API_KEY = "xxxx" | |
# These are the services we'll be using | |
softlayer_product_package = SoftLayer::Service.new("SoftLayer_Product_Package"); | |
softLayer_product_item_price = SoftLayer::Service.new("SoftLayer_Product_Item_Price"); | |
softLayer_product_order = SoftLayer::Service.new( "SoftLayer_Product_Order"); | |
location=265592 | |
Virtual_Guest_Package_ID = 46 | |
$product_order = { | |
'complexType' => 'SoftLayer_Container_Product_Order_Virtual_Guest', # a constant that will tell the server what type of thing we're sending it. | |
'quantity' => 1, # We only want 1 virtual guest. | |
'virtualGuests' => [ | |
{ | |
'hostname' => 'test', # in your own code you would replace this with your own hostname | |
'domain' => 'test.com' # in your own code you would replace this with your own domain name | |
} | |
], | |
# These are fields we'll fill in below with more explaination | |
'location' => location, | |
'packageId' => Virtual_Guest_Package_ID, | |
'prices' => nil, | |
'sshKeys' => 'test', | |
'useHourlyPricing'=> 1 | |
} | |
#$product_order["packageId"] = Virtual_Guest_Package_ID | |
# This creates a proxy of the product package service with the virtual guest package ID already | |
# "integrated" into it. | |
$virtual_guest_package = softlayer_product_package.object_with_id(Virtual_Guest_Package_ID) | |
$product_order["prices"] = [ | |
{ "id" => 26125 }, # 1640 -- 1 x 2.0 GHz Cores [Computing Instance] | |
{ "id" => 27884 }, # 1645 -- 2 GB [Ram] | |
{ "id" => 23070 }, # 905 -- Reboot / Remote Console [Remote Management] | |
{ "id" => 26737 }, # 273 -- 100 Mbps public & private networks - default | |
{ "id" => 34183 }, # 22505 1800 36 613 -- 1000 GB Bandwidth for Public bandwidth - default..1800 due to incopatibility.. | |
{ "id" => 34807 }, # 21 -- 1 IP Address [Primary IP Addresses] | |
{ "id" => 24013}, # 13899 -- First disk: 25 GB | |
{ "id" => 28309 }, # 17446 -- Ubuntu Linux 12.04 LTS Precise Pangolin - Minimal Install (64 bit) | |
{ "id" => 34241 }, # 55 -- Host Ping [Monitoring] and tcp | |
{ "id" => 32500 }, # 57 -- Email and Ticket [Notification] | |
{ "id" => 32627 }, # 58 -- Automated Notification [Response] | |
{ "id" => 33483 }, # 420 -- Unlimited SSL VPN Users & 1 PPTP VPN User per account [VPN Management - Private Network] | |
{ "id" => 35310 }, # 418 -- Nessus Vulnerability Assessment & Reporting [Vulnerability Assessments & Management] | |
{ "id" => 32139 } # 22429 -- Advanced monitoring | |
] | |
puts $product_order.inspect | |
begin | |
result = softLayer_product_order.verifyOrder($product_order) | |
puts "The order was verified successfully" | |
# softLayer_product_order.placeOrder($product_order) | |
rescue => error_reason | |
puts "The order could not be verified by the server #{error_reason}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment