Skip to content

Instantly share code, notes, and snippets.

View michaelcarruthers's full-sized avatar

Michael Carrruthers michaelcarruthers

View GitHub Profile
connection.request(
:body => "dataset=77a82164-ae77-11e2-aa0c-1fc90b223177&package=awesomepkg",
:headers => headers
:method => :post,
:path => '/my/machines'
)
2013-06-26 11:10:32Z WARN: ErrorSent(requestId=06d4ac57-2c12-4715-8a51-d4f59b081820): HttpCode=400, RestCode=InvalidArgument, message=Invalid Content: Unexpected token ILLEGAL:
HttpError: Invalid Content: Unexpected token ILLEGAL
at /opt/smartdc/cloudapi/node_modules/restify/lib/error.js:21:13
# Headers
'Accept' => 'application/json',
'Authorization' => signature['Authorization'],
'Content-Type' => 'application/json',
'Date' => signature['Date'],
'X-Api-Version' => '~6.5'
"name" => 'jsmith',
"dataset" => '<random_image_id>',
"package" => '<package_name>'
"allow_restricted_traffic": true,
"allow_ip_spoofing": true,
"allow_mac_spoofing": true,
"allow_dhcp_spoofing": true,
metadata :name => "Users Agent",
:description => "Agent to list users",
:author => "Michael Carruthers",
:license => "GPLv2",
:version => "0.0.1",
:url => 'homepage
:timeout => 20
action "info", :description => "View user information" do
display :always
@michaelcarruthers
michaelcarruthers / user.rb
Created August 23, 2012 13:31
RPC Agent (Users)
module MCollective
module Agent
class User < RPC::Agent
require 'etc'
metadata :name => "User",
:description => "List user information",
:author => "Michael Carruthers",
:license => "internal-only",
action "info" do
validate :user, String
user = request[:user]
reply[:user] = user_info(user)
end
private
require 'etc'
def user_info(req_user)
@michaelcarruthers
michaelcarruthers / joyent.erb
Created August 19, 2012 15:03
SmartOS Chef Bootstrap
bash -c '
if [ ! -f /opt/local/bin/chef-client ]; then
cd /tmp
pkgin -y install gcc-compiler gcc-runtime gcc-tools-0 ruby18-base ruby18-readline scmgit-base scmgit-docs gmake
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz
tar -xzf rubygems-1.8.10.tgz
cd rubygems-1.8.10
ruby setup.rb --no-format-executable
gem install --no-ri --no-rdoc json_pure
gem install --no-ri --no-rdoc -v=0.10.10 chef -- --with-cflags=-m64 --with-ldflags=-m64
knife-staging () {
knife $* -c ~/.chef/knife.staging.rb
}
knife-production () {
knife $* -c ~/.chef/knife.production.rb
}
client = OAuth::AccessToken.new(OAuth::Consumer.new('foo', 'bar', {:site => 'https://api.cloudkick.com'}))
ruby-1.9.2-p180 :052 > client.request(:post, "/2.0/checks", "{:monitor_id => 'qc00000000000', :type => 'HTTP'}").body
=> "Unauthorized Request"
ruby-1.9.2-p180 :053 >
{
"applications.messenger.staging.working": {
"message_dispatch_adhoc": {
"count": 1
},
"messenger_retriever": {
},
"facebook_page_adhoc": {
"count": 1
},