smartdc by Ruby
Upcoming SlideShare
Loading in...5
×
 

smartdc by Ruby

on

  • 485 views

ruby-smartdc Usage CLI

ruby-smartdc Usage CLI

Statistics

Views

Total Views
485
Views on SlideShare
485
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

smartdc by Ruby smartdc by Ruby Presentation Transcript

  • ruby-smartdc Usage CLI and Program
  • Get Started with SmartDataCenter•Create Account •Get a username and password.•Customers http://www.joyent.com/customers/ ‣ http://www.joyentcloud.com/ ‣ http://z-cloud.jp/ ‣ etc...
  • CLI
  • Install and Setup•Install $ gem install smartdc Fetching: smartdc-0.3.0.gem (100%) Successfully installed smartdc-0.3.0 1 gem installed•Setup $ sdc-setup https://api.z-cloud.jp version:[~6.5] ~6.5 Username (login): your name Password: your password Successful configuration.
  • Register to generate an SSH•Generate $ ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa Generating public/private rsa key pair. ...•Register $ sdc-createkey your-key ~/.ssh/id_rsa.pub { "name": "your-key", "key": "ssh-rsa ...", "created": "2011-11-06T12:43:24+00:00", "updated": "2011-11-06T12:43:24+00:00" }
  • Provision a new Machine• Help $ sdc-createmachine -h Usage: sdc-createmachine [options] -n, --name NAME friendly name for this machine. -e, --dataset URN dataset URN. -p, --package NAME Name of the package to use on provisioning. -h, --help Datasets(urn): sdc:sdc:centos6lvm:1.1.3 sdc:sdc:smartos64:1.4.7 Packages(name): Small_1GB Medium_2GB Medium_4GB Large_8GB• Create $ sdc-createmachine -n your-machine -e sdc:sdc:smartos64:1.4.7 -p Medium_2GB {"id": "83c2902a-0093-4ce2-8abe-3b9dd6199d8f", "name": "your-machine", "type": "smartmachine", "state": "provisioning", "dataset": "sdc:sdc:smartos64:1.4.7", "ips": ["210.152.137.65"], "memory": 2048, "disk": 61440, "metadata": {}, "created": "2011-11-06T13:02:09+00:00", "updated": "2011-11-06T13:02:10+00:00"}
  • State of the machine•Get $ sdc-getmachine 83c2902a-0093-4ce2-8abe-3b9dd6199d8f {"id": "83c2902a-0093-4ce2-8abe-3b9dd6199d8f", "name": "your-machine", "type": "smartmachine", "state": "running", "dataset": "sdc:sdc:smartos64:1.4.7", "ips": ["210.152.137.65"], "memory": 2048, "disk": 61440, "metadata": {}, "created": "2011-11-06T13:02:42+00:00", "updated": "2011-11-06T13:02:42+00:00"}
  • Delete the machine• Stop $ sdc-stopmachine 83c2902a-0093-4ce2-8abe-3b9dd6199d8f true $ sdc-getmachine 83c2902a-0093-4ce2-8abe-3b9dd6199d8f {"id": "83c2902a-0093-4ce2-8abe-3b9dd6199d8f", ... "state": "stopped",• Delete $ sdc-deletemachine 83c2902a-0093-4ce2-8abe-3b9dd6199d8f true $ sdc-getmachine 83c2902a-0093-4ce2-8abe-3b9dd6199d8f {"id": "83c2902a-0093-4ce2-8abe-3b9dd6199d8f", ... "state": "deleted",
  • Program
  • Connect and Machine findrequire smartdcconfig = { "url" => "https://example.com/", "version" => "~6.5", "username" => "auth_user","password" => "auth_pass"}client = Smartdc.new(config)machines = client.machines.findmachines.each do |machine| puts "machines id: #{machine.id}, state: #{machine.state}" machine = client.machines(machine.id) puts Start the machine. machine.start puts "machine id: #{machine.read.id}, state: #{machine.read.state}"end
  • Return type of the variable# Type of a variable to mash. (Default)client.request.return_variable = mashputs client.datacenters.find #=> #<Hashie::Mash example="example.com"># Type of a variable to hash.client.request.return_variable = hashputs client.datacenters.find #=> {"example"=>"https://example.com"}# Type of a variable to json.client.request.return_variable = jsonputs client.datacenters.find #=> {"example": "https://example.com"}
  • End•RubyGems https://rubygems.org/gems/smartdc•GitHub https://github.com/ogom/ruby-smartdc•API documentation http://apidocs.joyent.com/napi/cloudapi/