Skip to content

Instantly share code, notes, and snippets.

@Atalanta
Created March 22, 2011 16:15
Show Gist options
  • Select an option

  • Save Atalanta/881492 to your computer and use it in GitHub Desktop.

Select an option

Save Atalanta/881492 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'thor'
require 'fileutils'
require 'awesome_print'
ap ARGV
command = ARGV.first
arguments = ARGV[1..-1]
GEM_DIR = Gem.default_dir
class CucumberChef < Thor
include Thor::Actions
def initialize(args=[], options={}, config={})
super
end
def self.source_root
File.dirname(__FILE__)
end
no_tasks do
def test_platform_access(config_file)
begin
config = YAML::load( File.open(config_file))
rescue
return "Missing configuration file. Please check."
end
username = config['chef_node_name']
req = Net::HTTP.new('community.opscode.com', 80)
code = req.request_head("/users/#{username}").code
code == "200" ? "OK" : "Invalid EC2 or Opscode platform credentials. Please check."
end
end
desc "setup", "Set up a cucumber-chef test lab in Amazon EC2"
method_options :config => :string
@config_file = method_options[:config]
ap(method_options[:config])
def setup
result = test_platform_access(@config_file)
unless result == "OK"
puts result
return result
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment