Skip to content

Instantly share code, notes, and snippets.

View arax's full-sized avatar

Boris Parak arax

  • Brno, Czech Republic
View GitHub Profile
@arax
arax / gist:4033686
Created November 7, 2012 19:07
rOCCI 3.0.0.alpha.0 issues
################################################
# GET (describe) will fail for recently created
# resources.
#
# to reproduce, run examples/x509auth_example.rb
################################################
D, [2012-11-07T20:02:07.836934 #18365] DEBUG -- : Parsed collection: empty? true
[~/.rvm/gems/ruby-1.9.3-p194/gems/occi-3.0.0.alpha.0/lib/occi/collection.rb:134:in `as_json': undefined method `size' for nil:NilClass (NoMethodError)
from ~/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/json/encoding.rb:47:in `block in encode'
@arax
arax / gist:4226541
Created December 6, 2012 17:56
VCR - ignore specific requests
VCR.configure do |c|
c.hook_into :webmock
c.cassette_library_dir = 'spec/cassettes'
c.default_cassette_options = { :record => :new_episodes }
## Ignore some requests based on the hosts involved.
c.ignore_hosts 'localhost', '8.8.8.8', 'our.local.test.server.org'
## Ignore some requests based on their properties.
# The block passed to c.ignore_request has to
@arax
arax / gist:4442828
Created January 3, 2013 11:29
rOCCI 3.0.0.beta.1 -- Create Compute -- HTTP POST request
POST /compute/ HTTP/1.1
Accept: text/uri-list
Content-Type: application/occi+json
Connection: close
Host: localhost
Content-Length: 599
{"resources":[{"kind":"http://schemas.ogf.org/occi/infrastructure#compute","mixins":["https://occi.localhost/occi/infrastructure/resource_tpl#medium"]}],"links":[{"kind":"http://schemas.ogf.org/occi/infrastructure#storagelink","rel":"http://schemas.ogf.org/occi/infrastructure#storage","target":"https://localhost/storage/e60aa2b8-0c86-5973-b93e-30c5c46d6eac"},{"kind":"http://schemas.ogf.org/occi/infrastructure#networkinterface","rel":"http://schemas.ogf.org/occi/core#resource","target":"https://localhost/network/d71df087-9a55-5228-822b-1f1a57107851"}]}
@arax
arax / gist:4442902
Created January 3, 2013 11:40
rOCCI-server 0.5.2 -- Create Compute -- log
D, [2013-01-03T12:19:26.894193 #6645] DEBUG -- : ### Client Accept: ["text/uri-list"]
D, [2013-01-03T12:19:26.894599 #6645] DEBUG -- : ### Client Request method: POST
D, [2013-01-03T12:19:26.894722 #6645] DEBUG -- : ### Client Request Media Type: application/occi+json
D, [2013-01-03T12:19:26.894989 #6645] DEBUG -- : ### Client Request header: {"HTTPS"=>"on", "HTTP_ACCEPT"=>"text/uri-list", "HTTP_CONNECTION"=>"close", "HTTP_HOST"=>"localhost"}
D, [2013-01-03T12:19:26.895720 #6645] DEBUG -- : ### Client Request body: {"resources":[{"kind":"http://schemas.ogf.org/occi/infrastructure#compute","mixins":["https://occi.localhost/occi/infrastructure/resource_tpl#medium"]}],"links":[{"kind":"http://schemas.ogf.org/occi/infrastructure#storagelink","rel":"http://schemas.ogf.org/occi/infrastructure#storage","target":"https://localhost/storage/e60aa2b8-0c86-5973-b93e-30c5c46d6eac"},{"kind":"http://schemas.ogf.org/occi/infrastructure#networkinterface","rel":"http://schemas.ogf.org/occi/core#resource","target":"https://loca
@arax
arax / gist:4710994
Created February 5, 2013 00:12
rOCCI VOMS authn exception in jRuby
OpenSSL::SSL::SSLError: Received fatal alert: decrypt_error
connect at org/jruby/ext/openssl/SSLSocket.java:170
connect at jar:file:/tmp/jruby7520675521007850409extract/jruby-stdlib-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:799
timeout at org/jruby/ext/timeout/Timeout.java:105
connect at jar:file:/tmp/jruby7520675521007850409extract/jruby-stdlib-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:799
do_start at jar:file:/tmp/jruby7520675521007850409extract/jruby-stdlib-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:755
start at jar:file:/tmp/jruby7520675521007850409extract/jruby-stdlib-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:744
request at jar:file:/tmp/jruby7520675521007850409extract/jruby-stdlib-1.7.2.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:1292
perform at /home/arax/.rvm/gems/jruby-1.7.2/gems/httparty-0.10.2/lib/httparty/request.rb:91
perform_request at /home/arax/.rvm/ge
@arax
arax / CloudAuth.rb
Last active December 12, 2015 05:29
OpenNebula -- fix for X.509 authn username lookup in src/cloud/common/CloudAuth.rb
# Gets the username associated with a password
# password:: _String_ the password
# [return] _Hash_ with the username
def get_username(password)
xpath = "USER[PASSWORD=\"#{password}\"]/NAME"
username = retrieve_from_userpool(xpath)
# No exact match, trying to match password with each
# of the pipe-separated DNs stored in USER/PASSWORD
if username.nil?
@arax
arax / gist:4731144
Last active December 12, 2015 06:39
Reading PKCS#12 credentials in jRuby using Java's java.security.KeyStore
require 'java'
require 'highline/import'
keystore = Java::JavaSecurity::KeyStore.getInstance("PKCS12")
path = ask "Enter full path to the PKCS#12 file: "
fis = Java::JavaIo::FileInputStream.new(path)
password = ask("Enter you PKCS#12 password: ") { |q| q.echo = false }
password = Java::JavaLang::String.new(password).to_char_array
@arax
arax / gist:5013092
Created February 22, 2013 12:29
rOCCI-server v0.5.3/rOCCI v2.5.13 crash on POST /compute/
Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind"
Category: small;scheme="https://occi.my.scheme/occi/infrastructure/resource_tpl#";class="mixin"
X-OCCI-Attribute: occi.core.title="My Test VM"
Link: </storage/e60aa2b8-0c86-5973-b93e-30c5c46d6eac>;rel="http://schemas.ogf.org/occi/infrastructure#storage";category="http://schemas.ogf.org/occi/infrastructure#storagelink";occi.core.target="/storage/e60aa2b8-0c86-5973-b93e-30c5c46d6eac"
Link: </network/e4bd81c4-adda-5626-840d-39bb7959db97>;rel="http://schemas.ogf.org/occi/core#resource";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.target="/network/e4bd81c4-adda-5626-840d-39bb7959db97"
D, [2013-02-22T13:20:35.249918 #31553] DEBUG -- : ### Prepare response ###
D, [2013-02-22T13:20:35.250061 #31553] DEBUG -- : ### Initialize response OCCI collection ###
D, [2013-02-22T13:20:35.250307 #31553] DEBUG -- : ### Reset OCCI model ###
@arax
arax / gist:5527509
Created May 6, 2013 19:31
HTTPi with curb and SPNEGO, based on https://gist.github.com/pullmonkey/3179054
require 'rubygems'
require 'httpi'
require 'curb'
require 'pp'
require 'json'
################################
# kinit user@REALM
# kinit -k -t /ticket/path
################################
@arax
arax / gist:5561005
Created May 11, 2013 19:01
rOCCI -- parsing error from the new parser
~/.rvm/gems/ruby-1.9.3-p392/gems/occi-3.2.0.alpha.1/lib/occi/parser/text.rb:134:in `category': could not match Category: egicf2012_demo;scheme="https://occi.schema/occi/infrastructure/os_tpl#";class="mixin";title="egicf2012-demo";rel="http://schemas.ogf.org/occi/infrastructure#os_tpl";location="/mixins/egicf2012_demo/" (RuntimeError)
from /home/arax/.rvm/gems/ruby-1.9.3-p392/gems/occi-3.2.0.alpha.1/lib/occi/parser/text.rb:73:in `block in categories'
from /home/arax/.rvm/gems/ruby-1.9.3-p392/gems/occi-3.2.0.alpha.1/lib/occi/parser/text.rb:71:in `each'
from /home/arax/.rvm/gems/ruby-1.9.3-p392/gems/occi-3.2.0.alpha.1/lib/occi/parser/text.rb:71:in `categories'
from /home/arax/.rvm/gems/ruby-1.9.3-p392/gems/occi-3.2.0.alpha.1/lib/occi/parser.rb:41:in `parse'