chipchilders / cloudstack_ruby_client Goto Github PK
View Code? Open in Web Editor NEWA Ruby client for CloudStack's API
License: Apache License 2.0
A Ruby client for CloudStack's API
License: Apache License 2.0
The 4.2 release with affinity groups is a major benefit to us, would love to see support for that in this gem.
As of 4.2, cloudstack supports http post for the updateVirtualMachine api call. It would be great if there were a way to specify http POST or GET for all the the api commands, and have a way to provide a json body for post requests.
I'm looking to find all states that are not equal to destroyed or expunging, so it possible for list_virtual_machines to ask for multiple machine states e.g. state = 'Running, Stopped'.
I'm trying to get the create_tags call to work, and I' struggling to decipher what format the tags parameter should be in. The API documentation says 'Map of tags (key/value pairs)'
I have tried using a hash:
cs_response = client.create_tags({ 'resourceids' => vm_id,
'resourcetype' => 'UserVm',
'tags' => { "permission" => 'guest' }
})
However this does not seem to work. Can anyone assist?
The ssl option does not curently appear to work. When setting use_ssl to true, requests fail with the following error:
/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:2564:in read_status_line': wrong status line: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">" (Net::HTTPBadResponse) from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:2551:in
read_new'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:1319:in block in transport_request' from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:1316:in
catch'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:1316:in transport_request' from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:1293:in
request'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:1286:in block in request' from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:745:in
start'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:1284:in request' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/cloudstack_ruby_client-0.2.3/lib/cloudstack_ruby_client/base_client.rb:27:in
request'
from (eval):39:in list_public_ip_addresses' from /export/home/gkremer/make_port_forward.rb:9:in
This seems to originate from lines 23 & 24 in base_client.rb being commented out. After restoring these lines, https calls worked for me.
Am I doing this right?
cs_conn = cs_connect # cloudstack-ruby-client connection def
params = Hash.new
params[:type] = "Routing"
params[:details] = "all"
result = cs_conn.list_hosts(params)
pp result
I've tried multiple ways to get the extra host information detailed on the API documentation back but to no avail.
http://cloudstack.apache.org/docs/api/apidocs-4.2/root_admin/listHosts.html
Can you advise what the format for tag search is on e.g. list_virtual_machines
I'm struggling to get it working!
when running plain test I get:
/home/xxx/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:2564:in `read_status_line': wrong status line: "\x15\x03\x01\x00\x02\x02" (Net::HTTPBadResponse)
from /home/hanuman/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
from /home/hanuman/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_request'
from /home/hanuman/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
from /home/hanuman/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
from /home/hanuman/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1293:in `request'
from /home/hanuman/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
from /home/hanuman/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:745:in `start'
from /home/hanuman/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1284:in `request'
from /home/hanuman/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/cloudstack_ruby_client-0.2.3/lib/cloudstack_ruby_client/base_client.rb:27:in `request'
As you can see, error pops out ruby standard library net/http.
Same thing with ruby 1.8.7:
/home/hanuman/.rbenv/versions/1.8.7-p371/lib/ruby/1.8/net/http.rb:2030:in `read_status_line': wrong status line: "\025\003\001\000\002\002" (Net::HTTPBadResponse)
from /home/hanuman/.rbenv/versions/1.8.7-p371/lib/ruby/1.8/net/http.rb:2017:in `read_new'
from /home/hanuman/.rbenv/versions/1.8.7-p371/lib/ruby/1.8/net/http.rb:1051:in `request'
from /home/hanuman/.rbenv/versions/1.8.7-p371/lib/ruby/1.8/net/http.rb:1037:in `request'
from /home/hanuman/.rbenv/versions/1.8.7-p371/lib/ruby/1.8/net/http.rb:543:in `start'
from /home/hanuman/.rbenv/versions/1.8.7-p371/lib/ruby/1.8/net/http.rb:1035:in `request'
from /home/hanuman/.rbenv/versions/1.8.7-p371/lib/ruby/gems/1.8/gems/cloudstack_ruby_client-0.2.3/lib/cloudstack_ruby_client/base_client.rb:27:in `request'
from (eval):39:in `list_virtual_machines'
cloudstack is running on https version 4.2.0.
Fetching with https://github.com/snumano/CloudStack-API works fine.
I am able to use various other create commands, but when I try to use:
client.create_volume(:name => "blah")
I get an error, as far as I can tell it should be working as name is the only requirement for creating volumes.
Hey Chip,
Can you verify your signature generation? I have some perl code which works, that generates the following URL to pull back the json.
Perl:
http://oak1-to-bl0001.oak1.atomz.com:8080/client/api?apiKey=K1q9NLDrswm-I3UMjR8fKlQ2Kzlb9Uv_pH-82jeMulE3DdEHaTeFcdrkEocIDtR17QxQndowZ1oAiBhwhXu1zQ&command=listVirtualMachines&response=json&signature=Uo0LO9k32a6SflTrEfDZlT1kQ7A%3D
However submitting the same values in your ruby code returns the following. Which does not work.
Returns:
401
unable to verify user credentials and/or request signature
Is there anything that I'm doing wrong, or is there a bug in signature generation?
/Alistair
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.