Permalink
Browse files

Merge branch 'greenalto/KNIFE_EC2-39'

  • Loading branch information...
2 parents 76cc836 + 5a4e7c7 commit 6bce5d546dde37f9338a66876eb707bf6c71473c @stevendanna stevendanna committed Apr 6, 2012
Showing with 114 additions and 8 deletions.
  1. +4 −0 Gemfile
  2. +88 −0 Gemfile.lock
  3. +1 −0 knife-ec2.gemspec
  4. +21 −8 spec/unit/ec2_server_create_spec.rb
View
@@ -2,3 +2,7 @@ source "http://rubygems.org"
# Specify your gem's dependencies in knife-rackspace.gemspec
gemspec
+
+group :development do
+ gem 'rspec', '~> 2.7.0'
+end
View
@@ -0,0 +1,88 @@
+PATH
+ remote: .
+ specs:
+ knife-ec2 (0.5.11)
+ chef (~> 0.10)
+ fog (~> 0.8.2)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ builder (3.0.0)
+ bunny (0.7.8)
+ chef (0.10.8)
+ bunny (>= 0.6.0)
+ erubis
+ highline
+ json (>= 1.4.4, <= 1.6.1)
+ mixlib-authentication (>= 1.1.0)
+ mixlib-cli (>= 1.1.0)
+ mixlib-config (>= 1.1.2)
+ mixlib-log (>= 1.3.0)
+ moneta
+ net-ssh (~> 2.1.3)
+ net-ssh-multi (~> 1.1.0)
+ ohai (>= 0.6.0)
+ rest-client (>= 1.0.4, < 1.7.0)
+ treetop (~> 1.4.9)
+ uuidtools
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ excon (0.6.6)
+ fog (0.8.2)
+ builder
+ excon (~> 0.6.1)
+ formatador (>= 0.1.3)
+ json
+ mime-types
+ net-ssh (>= 2.1.3)
+ nokogiri (>= 1.4.4)
+ ruby-hmac
+ formatador (0.2.1)
+ highline (1.6.9)
+ json (1.6.1)
+ mime-types (1.17.2)
+ mixlib-authentication (1.1.4)
+ mixlib-log
+ mixlib-cli (1.2.2)
+ mixlib-config (1.1.2)
+ mixlib-log (1.3.0)
+ moneta (0.6.0)
+ net-ssh (2.1.4)
+ net-ssh-gateway (1.1.0)
+ net-ssh (>= 1.99.1)
+ net-ssh-multi (1.1)
+ net-ssh (>= 2.1.4)
+ net-ssh-gateway (>= 0.99.0)
+ nokogiri (1.5.0)
+ ohai (0.6.10)
+ mixlib-cli
+ mixlib-config
+ mixlib-log
+ systemu (~> 2.2.0)
+ yajl-ruby
+ polyglot (0.3.3)
+ rest-client (1.6.7)
+ mime-types (>= 1.16)
+ rspec (2.7.0)
+ rspec-core (~> 2.7.0)
+ rspec-expectations (~> 2.7.0)
+ rspec-mocks (~> 2.7.0)
+ rspec-core (2.7.1)
+ rspec-expectations (2.7.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.7.0)
+ ruby-hmac (0.4.0)
+ systemu (2.2.0)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ uuidtools (2.1.2)
+ yajl-ruby (1.1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ knife-ec2!
+ rspec (~> 2.7.0)
View
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.add_dependency "fog", "~> 0.8.2"
+ s.add_dependency "chef", "~> 0.10"
s.require_paths = ["lib"]
end
@@ -17,15 +17,26 @@
#
require File.expand_path('../../spec_helper', __FILE__)
+require 'fog'
+require 'chef/knife/bootstrap'
describe Chef::Knife::Ec2ServerCreate do
before do
- @knife_ec2_create = Chef::Knife::Ec2ServerCreate.new()
- @knife_ec2_create.name_args = ['role[base]']
+ @knife_ec2_create = Chef::Knife::Ec2ServerCreate.new
@knife_ec2_create.initial_sleep_delay = 0
@knife_ec2_create.stub!(:tcp_test_ssh).and_return(true)
- @ec2_connection = mock()
+ {
+ :image => 'image',
+ :aws_ssh_key_id => 'aws_ssh_key_id',
+ :aws_access_key_id => 'aws_access_key_id',
+ :aws_secret_access_key => 'aws_secret_access_key'
+ }.each do |key, value|
+ Chef::Config[:knife][key] = value
+ end
+
+ @ec2_connection = mock(Fog::AWS::Compute)
+ @ec2_connection.stub_chain(:images, :get).and_return mock('ami', :root_device_type => 'not_ebs')
@ec2_servers = mock()
@new_ec2_server = mock()
@@ -36,9 +47,10 @@
:key_name => 'my_ssh_key',
:groups => ['group1', 'group2'],
:dns_name => 'ec2-75.101.253.10.compute-1.amazonaws.com',
- :ip_address => '75.101.253.10',
+ :public_ip_address => '75.101.253.10',
:private_dns_name => 'ip-10-251-75-20.ec2.internal',
- :private_ip_address => '10.251.75.20' }
+ :private_ip_address => '10.251.75.20',
+ :root_device_type => 'not_ebs' }
@ec2_server_attribs.each_pair do |attrib, value|
@new_ec2_server.stub!(attrib).and_return(value)
@@ -75,8 +87,9 @@
@knife_ec2_create.config[:chef_node_name] = "blarf"
@knife_ec2_create.config[:template_file] = '~/.chef/templates/my-bootstrap.sh.erb'
@knife_ec2_create.config[:distro] = 'ubuntu-10.04-magic-sparkles'
+ @knife_ec2_create.config[:run_list] = ['role[base]']
- @bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server)
+ @bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server, @new_ec2_server.dns_name)
end
it "should set the bootstrap 'name argument' to the hostname of the EC2 server" do
@@ -106,7 +119,7 @@
it "configures the bootstrap to use the EC2 server id if no explicit node name is set" do
@knife_ec2_create.config[:chef_node_name] = nil
- bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server)
+ bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server, @new_ec2_server.dns_name)
bootstrap.config[:chef_node_name].should == @new_ec2_server.id
end
@@ -115,7 +128,7 @@
@knife_ec2_create.config[:prerelease] = true
- bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server)
+ bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server, @new_ec2_server.dns_name)
bootstrap.config[:prerelease].should be_true
end

0 comments on commit 6bce5d5

Please sign in to comment.