vagrant-rackspace 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NWFiODQ5NDFhYjkyYThhN2QzOGI3ZTFmMDA0ODQ0MzcxNGMwOTlmNg==
5
- data.tar.gz: !binary |-
6
- YjNhNTNmNGIyN2ViOTAwNjZiMDlmNTMxNTIyN2NmOTE1MzNmY2ZlNg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ZWEzZDlmNGNjOTMzOGQ0ZDJkN2E0M2E0MzEzZWM1YmUyNjBkZjIwZGRmMGVj
10
- NjQzYTQ5YWEzNmZjNjEwYTNiNWUyZWMzZmM3NmJlY2RkZmI1MmI4MDIxN2U0
11
- ODgxZjlhNWFiZDEwMzcyYjdjYjYzZjYyYzdjNmUzOGQ2Y2E1YzE=
12
- data.tar.gz: !binary |-
13
- ZjdiYjcwYjQ0OGE0Mjg4YjYyYTk3M2JkNGY4MGY4NGIxMzNiY2JkNzE3MWVi
14
- NGM5OTM2MzYzZDRmMzcyNzYzMWU3YTdhMjIyNmM4ZmI0ODA4ZDZjOTY4ZTUy
15
- MzRjODhmMTE5YTVhNjhkMDM1MmE3ZjJlMDJiM2QzZDI3ZThlZjU=
2
+ SHA1:
3
+ metadata.gz: 7fe21c6407d830b5385525127b4a603868d1633e
4
+ data.tar.gz: 844c3ce48da303288e07f98908f139d15883c98b
5
+ SHA512:
6
+ metadata.gz: 01154897155ab913685c7521b06dd44019e35cb0437ab267089e611ef36376dab5fccb94c96bcc61b5c498e1c3d990228f51913fdaed13f7bba8c738122db9c3
7
+ data.tar.gz: 094f97a4d92ade0439411eb3d8e944f1401c2fee5925dc355066e9b71807cfda563e41df2b8ee10be058a126ffe453665d094019951260b03a12a29cc2f17620
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # 0.1.7 (March 13, 2014)
2
+
3
+ FEATURES:
4
+
5
+ - Adds commands to list available images and flavors [GH-73]
6
+ - Adds support for creating images from running VMs [GH-74]
7
+
8
+ IMPROVEMENTS:
9
+
10
+ - Adds support for rsync --include directives [GH-56]
11
+ - Adds ability to add server metadata [GH-72]
12
+ - Cleans up chef node and client from chef server [GH-67]
13
+
1
14
  # 0.1.6 (January 8, 2014)
2
15
 
3
16
  BUG FIXES:
data/Gemfile CHANGED
@@ -3,12 +3,13 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem "appraisal", "1.0.0.beta2"
6
- gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
6
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.4.3"
7
7
 
8
8
  group :development do
9
9
  # We depend on Vagrant for development, but we don't add it as a
10
10
  # gem dependency because we expect to be installed within the
11
11
  # Vagrant environment itself using `vagrant plugin`.
12
12
  gem 'coveralls', require: false
13
+ gem 'pry'
13
14
  end
14
15
 
data/README.md CHANGED
@@ -36,7 +36,7 @@ The default configuration of the RHEL family of Linux distributions requires a t
36
36
  > sudo: sorry, you must have a tty to run sudo
37
37
 
38
38
  The best way to take deal with this error is to upgrade to Vagrant 1.4 or later, and enable:
39
- ```
39
+ ```ruby
40
40
  config.ssh.pty = true
41
41
  ```
42
42
 
@@ -55,15 +55,16 @@ $ vagrant box add dummy https://github.com/mitchellh/vagrant-rackspace/raw/maste
55
55
  And then make a Vagrantfile that looks like the following, filling in
56
56
  your information where necessary.
57
57
 
58
- ```
58
+ ```ruby
59
59
  Vagrant.configure("2") do |config|
60
60
  config.vm.box = "dummy"
61
61
 
62
62
  config.vm.provider :rackspace do |rs|
63
63
  rs.username = "YOUR USERNAME"
64
64
  rs.api_key = "YOUR API KEY"
65
- rs.flavor = /512MB/
65
+ rs.flavor = /1 GB Performance/
66
66
  rs.image = /Ubuntu/
67
+ rs.metadata = {"key" => "value"} # optional
67
68
  end
68
69
  end
69
70
  ```
@@ -78,6 +79,27 @@ Note that normally a lot of this boilerplate is encoded within the box
78
79
  file, but the box file used for the quick start, the "dummy" box, has
79
80
  no preconfigured defaults.
80
81
 
82
+ ## Custom Commands
83
+
84
+ The plugin includes several Rackspace-specific vagrant commands. You can get the
85
+ list of available commands with `vagrant rackspace -h`.
86
+
87
+ If you want to know what images or flavors are available for a machine, you can use:
88
+
89
+ ```
90
+ $ vagrant rackspace images
91
+ $ vagrant rackspace flavors
92
+ ```
93
+
94
+ In a multi-machine Vagrantfile you can also query for a single machine:
95
+ ```
96
+ $ vagrant rackspace images <name>
97
+ $ vagrant rackspace flavors <name>
98
+ ```
99
+
100
+ These command will connect to Rackspace using the settings associated with the machine,
101
+ and query the region to get the list of available images or flavors.
102
+
81
103
  ## Box Format
82
104
 
83
105
  Every provider in Vagrant must introduce a custom box format. This
@@ -96,7 +118,7 @@ This provider exposes quite a few provider-specific configuration options:
96
118
  * `api_key` - The API key for accessing Rackspace.
97
119
  * `flavor` - The server flavor to boot. This can be a string matching
98
120
  the exact ID or name of the server, or this can be a regular expression
99
- to partially match some server flavor.
121
+ to partially match some server flavor. Flavors are listed [here](#flavors).
100
122
  * `image` - The server image to boot. This can be a string matching the
101
123
  exact ID or name of the image, or this can be a regular expression to
102
124
  partially match some image.
@@ -116,6 +138,8 @@ vagrant will authenticate against the UK authentication endpoint.
116
138
  can be overridden with this.
117
139
  * `username` - The username with which to access Rackspace.
118
140
  * `disk_config` - Disk Configuration 'AUTO' or 'MANUAL'
141
+ * `metadata` - A set of key pair values that will be passed to the instance
142
+ for configuration.
119
143
 
120
144
  These can be set like typical provider-specific configuration:
121
145
 
@@ -130,6 +154,29 @@ Vagrant.configure("2") do |config|
130
154
  end
131
155
  ```
132
156
 
157
+ ### Flavors
158
+
159
+ As of February 2, 2014, the available flavor names are:
160
+
161
+ * 512MB Standard Instance
162
+ * 1GB Standard Instance
163
+ * 2GB Standard Instance
164
+ * 4GB Standard Instance
165
+ * 8GB Standard Instance
166
+ * 15GB Standard Instance
167
+ * 30GB Standard Instance
168
+ * 1 GB Performance
169
+ * 2 GB Performance
170
+ * 4 GB Performance
171
+ * 8 GB Performance
172
+ * 120 GB Performance
173
+ * 15 GB Performance
174
+ * 30 GB Performance
175
+ * 60 GB Performance
176
+ * 90 GB Performance
177
+
178
+ Please note that the standard instances are deprecated in favor of our performance flavors.
179
+
133
180
  ## Networks
134
181
 
135
182
  Networking features in the form of `config.vm.network` are not
data/RELEASE.md ADDED
@@ -0,0 +1,18 @@
1
+ # Release process
2
+
3
+ This is vagrant-rackspace's current release process, documented so people know what is
4
+ currently done.
5
+
6
+ ## Prepare the release
7
+
8
+ * Update the version in "lib/vagrant-rackspace/version.rb"
9
+ * Update the version in CHANGELOG.md
10
+ * Use "rake release". This will make sure to tag that commit and push it RubyGems.
11
+ * Create new [github release](https://github.com/mitchellh/vagrant-rackspace/releases)
12
+ * Update the version again in both files to a dev version for working again.
13
+
14
+ The CHANGELOG.md should be maintained in a similar format to Vagrant:
15
+
16
+ https://github.com/mitchellh/vagrant/blob/master/CHANGELOG.md
17
+
18
+
data/Vagrantfile CHANGED
@@ -15,6 +15,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
15
15
  config.vm.provider :rackspace do |rs|
16
16
  rs.username = ENV['RAX_USERNAME']
17
17
  rs.api_key = ENV['RAX_API_KEY']
18
+ rs.flavor = /1 GB Performance/
19
+ rs.image = /Ubuntu/
20
+ rs.rackspace_region = :iad
21
+
22
+ # rs.rsync_include 'PATTERN' # per man page for rsync
18
23
  end
19
24
  # The url from where the 'config.vm.box' box will be fetched if it
20
25
  # doesn't already exist on the user's system.
data/Vagrantfile.multi ADDED
@@ -0,0 +1,19 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+ REGIONS = [:dfw, :ord, :syd]
8
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
9
+ Vagrant.require_plugin "vagrant-rackspace"
10
+
11
+ REGIONS.each do |region|
12
+ config.vm.define region do |machine|
13
+ machine.vm.provider :rackspace do |rs|
14
+ rs.username = ENV['RAX_USERNAME']
15
+ rs.api_key = ENV['RAX_API_KEY']
16
+ end
17
+ end
18
+ end
19
+ end
@@ -57,7 +57,7 @@ Scenario: Create a single server (rackspace_compute_url)
57
57
  rs.server_name = 'vagrant-single-server'
58
58
  rs.username = ENV['RAX_USERNAME']
59
59
  rs.api_key = ENV['RAX_API_KEY']
60
- rs.rackspace_compute_url = "https://#{ENV['RAX_REGION'].downcase}.servers.api.rackspacecloud.com/v2"
60
+ rs.rackspace_compute_url = "https://#{ENV['RAX_REGION'].downcase}.servers.api.rackspacecloud.com/v2/#{ENV['RAX_TENANT_ID']}"
61
61
  rs.flavor = /1 GB Performance/
62
62
  rs.image = /Ubuntu/
63
63
  rs.public_key_path = "~/.ssh/id_rsa.pub" unless Fog.mock?
@@ -0,0 +1,53 @@
1
+ require "fog/rackspace"
2
+ require "log4r"
3
+
4
+ require 'vagrant/util/retryable'
5
+
6
+ module VagrantPlugins
7
+ module Rackspace
8
+ module Action
9
+ # Creates an Image
10
+ class CreateImage
11
+ include Vagrant::Util::Retryable
12
+
13
+ attr_reader :env
14
+
15
+ def initialize(app, env)
16
+ @app, @env = app, env
17
+ end
18
+
19
+ def call(env)
20
+ env[:ui].info(I18n.t("vagrant_rackspace.creating_image"))
21
+
22
+ server = env[:rackspace_compute].servers.get(env[:machine].id)
23
+
24
+ config = env[:machine].provider_config
25
+ image_name = config.server_name || env[:machine].name
26
+
27
+ image = server.create_image(image_name)
28
+
29
+ retryable(:on => Fog::Errors::TimeoutError, :tries => 200) do
30
+ # If we're interrupted don't worry about waiting
31
+ next if env[:interrupted]
32
+
33
+ env[:ui].clear_line
34
+ env[:ui].report_progress(image.progress, 100, false)
35
+
36
+ begin
37
+ image.wait_for(5) { ready? }
38
+ rescue RuntimeError => e
39
+ # If we don't have an error about a state transition, then
40
+ # we just move on.
41
+ raise if e.message !~ /should have transitioned/
42
+ raise Errors::CreateBadState, :state => server.state
43
+ end
44
+ end
45
+
46
+ env[:ui].info(I18n.t("vagrant_rackspace.image_ready"))
47
+
48
+ @app.call(env)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -55,7 +55,8 @@ module VagrantPlugins
55
55
  options = {
56
56
  :flavor_id => flavor.id,
57
57
  :image_id => image.id,
58
- :name => server_name
58
+ :name => server_name,
59
+ :metadata => config.metadata
59
60
  }
60
61
 
61
62
  if config.key_name
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Action
4
+ class ListFlavors
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ compute_service = env[:rackspace_compute]
11
+ env[:ui].info ('%-36s %s' % ['Flavor ID', 'Flavor Name'])
12
+ compute_service.flavors.sort_by(&:id).each do |flavor|
13
+ env[:ui].info ('%-36s %s' % [flavor.id, flavor.name])
14
+ end
15
+ @app.call(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Action
4
+ class ListImages
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ compute_service = env[:rackspace_compute]
11
+ env[:ui].info ('%-36s %s' % ['Image ID', 'Image Name'])
12
+ compute_service.images.sort_by(&:name).each do |image|
13
+ env[:ui].info ('%-36s %s' % [image.id.to_s, image.name])
14
+ end
15
+ @app.call(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -19,6 +19,9 @@ module VagrantPlugins
19
19
 
20
20
  ssh_info = env[:machine].ssh_info
21
21
 
22
+ config = env[:machine].provider_config
23
+ rsync_includes = config.rsync_includes.to_a
24
+
22
25
  env[:machine].config.vm.synced_folders.each do |id, data|
23
26
  hostpath = File.expand_path(data[:hostpath], env[:root_path])
24
27
  guestpath = data[:guestpath]
@@ -41,6 +44,12 @@ module VagrantPlugins
41
44
  env[:machine].communicate.sudo(
42
45
  "chown -R #{ssh_info[:username]} '#{guestpath}'")
43
46
 
47
+ # Generate rsync include commands
48
+ includes = rsync_includes.each_with_object([]) { |incl, incls|
49
+ incls << "--include"
50
+ incls << incl
51
+ }
52
+
44
53
  # Rsync over to the guest path using the SSH info. add
45
54
  # .hg/ to exclude list as that isn't covered in
46
55
  # --cvs-exclude
@@ -48,9 +57,11 @@ module VagrantPlugins
48
57
  "rsync", "--verbose", "--archive", "-z",
49
58
  "--cvs-exclude",
50
59
  "--exclude", ".hg/",
60
+ *includes,
51
61
  "-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no #{ssh_key_options(ssh_info)}",
52
62
  hostpath,
53
63
  "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
64
+ command.compact!
54
65
 
55
66
  # during rsync, ignore files specified in .hgignore and
56
67
  # .gitignore traditional .gitignore or .hgignore files
@@ -20,6 +20,7 @@ module VagrantPlugins
20
20
 
21
21
  b2.use ConnectRackspace
22
22
  b2.use DeleteServer
23
+ b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
23
24
  end
24
25
  end
25
26
  end
@@ -107,6 +108,40 @@ module VagrantPlugins
107
108
  end
108
109
  end
109
110
 
111
+ def self.action_create_image
112
+ Vagrant::Action::Builder.new.tap do |b|
113
+ b.use ConfigValidate
114
+ b.use Call, IsCreated do |env, b2|
115
+ created = env[:result]
116
+
117
+ if !created
118
+ b2.use MessageNotCreated
119
+ next
120
+ end
121
+
122
+ b2.use ConnectRackspace
123
+ b2.use CreateImage
124
+ end
125
+ end
126
+ end
127
+
128
+ # Extended actions
129
+ def self.action_list_images
130
+ Vagrant::Action::Builder.new.tap do |b|
131
+ # b.use ConfigValidate # is this per machine?
132
+ b.use ConnectRackspace
133
+ b.use ListImages
134
+ end
135
+ end
136
+
137
+ def self.action_list_flavors
138
+ Vagrant::Action::Builder.new.tap do |b|
139
+ # b.use ConfigValidate # is this per machine?
140
+ b.use ConnectRackspace
141
+ b.use ListFlavors
142
+ end
143
+ end
144
+
110
145
  # The autoload farm
111
146
  action_root = Pathname.new(File.expand_path("../action", __FILE__))
112
147
  autoload :ConnectRackspace, action_root.join("connect_rackspace")
@@ -118,6 +153,9 @@ module VagrantPlugins
118
153
  autoload :ReadSSHInfo, action_root.join("read_ssh_info")
119
154
  autoload :ReadState, action_root.join("read_state")
120
155
  autoload :SyncFolders, action_root.join("sync_folders")
156
+ autoload :CreateImage, action_root.join("create_image")
157
+ autoload :ListImages, action_root.join("list_images")
158
+ autoload :ListFlavors, action_root.join("list_flavors")
121
159
  end
122
160
  end
123
161
  end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Command
4
+ class CreateImage < Vagrant.plugin("2", :command)
5
+ def execute
6
+ options = {}
7
+ opts = OptionParser.new do |o|
8
+ o.banner = "Usage: vagrant rackspace images create [options]"
9
+ end
10
+
11
+ argv = parse_options(opts)
12
+ return if !argv
13
+
14
+ with_target_vms(argv, :provider => :rackspace) do |machine|
15
+ machine.action('create_image')
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Command
4
+ class Flavors < Vagrant.plugin("2", :command)
5
+ def execute
6
+ options = {}
7
+ opts = OptionParser.new do |o|
8
+ o.banner = "Usage: vagrant rackspace flavors [options]"
9
+ end
10
+
11
+ argv = parse_options(opts)
12
+ return if !argv
13
+
14
+ with_target_vms(argv, :provider => :rackspace) do |machine|
15
+ machine.action('list_flavors')
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,59 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Command
4
+ class Images < Vagrant.plugin("2", :command)
5
+ def initialize(argv, env)
6
+ @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
7
+
8
+ @subcommands = Vagrant::Registry.new
9
+ @subcommands.register(:list) do
10
+ require File.expand_path("../list_images", __FILE__)
11
+ ListImages
12
+ end
13
+ @subcommands.register(:create) do
14
+ require File.expand_path("../create_image", __FILE__)
15
+ CreateImage
16
+ end
17
+
18
+ super(argv, env)
19
+ end
20
+
21
+ def execute
22
+ if @main_args.include?("-h") || @main_args.include?("--help")
23
+ # Print the help for all the rackspace commands.
24
+ return help
25
+ end
26
+
27
+ command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
28
+ return help if !command_class || !@sub_command
29
+ @logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
30
+
31
+ # Initialize and execute the command class
32
+ command_class.new(@sub_args, @env).execute
33
+ end
34
+
35
+ def help
36
+ opts = OptionParser.new do |opts|
37
+ opts.banner = "Usage: vagrant rackspace images <subcommand> [<args>]"
38
+ opts.separator ""
39
+ opts.separator "Available subcommands:"
40
+
41
+ # Add the available subcommands as separators in order to print them
42
+ # out as well.
43
+ keys = []
44
+ @subcommands.each { |key, value| keys << key.to_s }
45
+
46
+ keys.sort.each do |key|
47
+ opts.separator " #{key}"
48
+ end
49
+
50
+ opts.separator ""
51
+ opts.separator "For help on any individual subcommand run `vagrant rackspace images <subcommand> -h`"
52
+ end
53
+
54
+ @env.ui.info(opts.help, :prefix => false)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Rackspace
3
+ module Command
4
+ class ListImages < Vagrant.plugin("2", :command)
5
+ def execute
6
+ options = {}
7
+ opts = OptionParser.new do |o|
8
+ o.banner = "Usage: vagrant rackspace images list [options]"
9
+ end
10
+
11
+ argv = parse_options(opts)
12
+ return if !argv
13
+
14
+ with_target_vms(argv, :provider => :rackspace) do |machine|
15
+ machine.action('list_images')
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,65 @@
1
+ require 'vagrant-rackspace/action'
2
+
3
+ module VagrantPlugins
4
+ module Rackspace
5
+ module Command
6
+ class Root < Vagrant.plugin("2", :command)
7
+ def self.synopsis
8
+ "query Rackspace for available images or flavors"
9
+ end
10
+
11
+ def initialize(argv, env)
12
+ @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
13
+
14
+ @subcommands = Vagrant::Registry.new
15
+ @subcommands.register(:images) do
16
+ require File.expand_path("../images", __FILE__)
17
+ Images
18
+ end
19
+ @subcommands.register(:flavors) do
20
+ require File.expand_path("../flavors", __FILE__)
21
+ Flavors
22
+ end
23
+
24
+ super(argv, env)
25
+ end
26
+
27
+ def execute
28
+ if @main_args.include?("-h") || @main_args.include?("--help")
29
+ # Print the help for all the rackspace commands.
30
+ return help
31
+ end
32
+
33
+ command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
34
+ return help if !command_class || !@sub_command
35
+ @logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
36
+
37
+ # Initialize and execute the command class
38
+ command_class.new(@sub_args, @env).execute
39
+ end
40
+
41
+ def help
42
+ opts = OptionParser.new do |opts|
43
+ opts.banner = "Usage: vagrant rackspace <subcommand> [<args>]"
44
+ opts.separator ""
45
+ opts.separator "Available subcommands:"
46
+
47
+ # Add the available subcommands as separators in order to print them
48
+ # out as well.
49
+ keys = []
50
+ @subcommands.each { |key, value| keys << key.to_s }
51
+
52
+ keys.sort.each do |key|
53
+ opts.separator " #{key}"
54
+ end
55
+
56
+ opts.separator ""
57
+ opts.separator "For help on any individual subcommand run `vagrant rackspace <subcommand> -h`"
58
+ end
59
+
60
+ @env.ui.info(opts.help, :prefix => false)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -60,6 +60,11 @@ module VagrantPlugins
60
60
  # @return [String]
61
61
  attr_accessor :key_name
62
62
 
63
+ # A Hash of metadata that will be sent to the instance for configuration
64
+ #
65
+ # @return [Hash]
66
+ attr_accessor :metadata
67
+
63
68
  # The option that indicates RackConnect usage or not.
64
69
  #
65
70
  # @return [Boolean]
@@ -92,6 +97,11 @@ module VagrantPlugins
92
97
  # @return [Array]
93
98
  attr_accessor :networks
94
99
 
100
+ # Opt files/directories in to the rsync operation performed by this provider
101
+ #
102
+ # @return [Array]
103
+ attr_accessor :rsync_includes
104
+
95
105
  # Default Rackspace Cloud Network IDs
96
106
  SERVICE_NET_ID = '11111111-1111-1111-1111-111111111111'
97
107
  PUBLIC_NET_ID = '00000000-0000-0000-0000-000000000000'
@@ -109,6 +119,7 @@ module VagrantPlugins
109
119
  @username = UNSET_VALUE
110
120
  @disk_config = UNSET_VALUE
111
121
  @networks = []
122
+ @rsync_includes = []
112
123
  end
113
124
 
114
125
  def finalize!
@@ -120,9 +131,11 @@ module VagrantPlugins
120
131
  @image = /Ubuntu/ if @image == UNSET_VALUE
121
132
  @rackconnect = nil if @rackconnect == UNSET_VALUE
122
133
  @server_name = nil if @server_name == UNSET_VALUE
134
+ @metadata = nil if @metadata == UNSET_VALUE
123
135
  @username = nil if @username == UNSET_VALUE
124
136
  @disk_config = nil if @disk_config == UNSET_VALUE
125
137
  @networks = nil if @networks.empty?
138
+ @rsync_includes = nil if @rsync_includes.empty?
126
139
 
127
140
  if @public_key_path == UNSET_VALUE
128
141
  @public_key_path = Vagrant.source_root.join("keys/vagrant.pub")
@@ -159,6 +172,10 @@ module VagrantPlugins
159
172
  end
160
173
  end
161
174
 
175
+ def rsync_include(inc)
176
+ @rsync_includes << inc
177
+ end
178
+
162
179
  def validate(machine)
163
180
  errors = _detected_errors
164
181
 
@@ -32,6 +32,11 @@ module VagrantPlugins
32
32
  require_relative "provider"
33
33
  Provider
34
34
  end
35
+
36
+ command('rackspace') do
37
+ require_relative "command/root"
38
+ Command::Root
39
+ end
35
40
  end
36
41
  end
37
42
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Rackspace
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.7"
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -2,12 +2,16 @@ en:
2
2
  vagrant_rackspace:
3
3
  already_created: |-
4
4
  The server is already created.
5
+ creating_image: |-
6
+ Creating image...
5
7
  deleting_server: |-
6
8
  Deleting server...
7
9
  finding_flavor: |-
8
10
  Finding flavor for server...
9
11
  finding_image: |-
10
12
  Finding image for server...
13
+ image_ready: |-
14
+ Image created
11
15
  launching_server: |-
12
16
  Launching a server with the following settings...
13
17
  not_created: |-
@@ -43,6 +47,8 @@ en:
43
47
  A username is required.
44
48
  invalid_uri: |-
45
49
  The value for %{key} is not a valid URI: %{uri}
50
+ metadata_must_be_hash: |-
51
+ Metadata must be a hash.
46
52
 
47
53
  errors:
48
54
  create_bad_state: |-
@@ -0,0 +1,20 @@
1
+ if ENV['COVERAGE'] != 'false'
2
+ require 'simplecov'
3
+ require 'coveralls'
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ]
8
+ SimpleCov.start
9
+
10
+ # Normally classes are lazily loaded, so any class without a test
11
+ # is missing from the report. This ensures they show up so we can
12
+ # see uncovered methods.
13
+ require 'vagrant'
14
+ Dir["lib/**/*.rb"].each do|file|
15
+ require_string = file.match(/lib\/(.*)\.rb/)[1]
16
+ require require_string
17
+ end
18
+ end
19
+
20
+ require 'fog'
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+ require "vagrant-rackspace/action/list_flavors"
3
+
4
+ describe VagrantPlugins::Rackspace::Action::ListFlavors do
5
+ let(:app) { lambda { |env| } }
6
+ let(:ui) { Vagrant::UI::Silent.new }
7
+ let(:flavors) {
8
+ Fog.mock!
9
+ Fog::Compute.new({
10
+ :provider => :rackspace,
11
+ :rackspace_region => :dfw,
12
+ :rackspace_api_key => 'anything',
13
+ :rackspace_username => 'anything',
14
+ }).flavors
15
+ }
16
+ let(:compute_connection) { double('fog connection') }
17
+ let(:env) do
18
+ {
19
+ :rackspace_compute => compute_connection,
20
+ :ui => ui
21
+ }
22
+ end
23
+
24
+ subject(:action) { described_class.new(app, env) }
25
+
26
+ before do
27
+ allow(compute_connection).to receive(:flavors).and_return flavors
28
+ end
29
+
30
+ it 'get flavors from Fog' do
31
+ expect(compute_connection).to receive(:flavors).and_return flavors
32
+ action.call(env)
33
+ end
34
+
35
+ it 'writes a sorted, formatted flavor table to Vagrant::UI' do
36
+ header_line = '%-36s %s' % ['Flavor ID', 'Flavor Name']
37
+ expect(ui).to receive(:info).with(header_line)
38
+ flavors.sort_by(&:id).each do |flavor|
39
+ formatted_line = '%-36s %s' % [flavor.id, flavor.name]
40
+ expect(ui).to receive(:info).with formatted_line
41
+ end
42
+ action.call(env)
43
+ end
44
+
45
+ it 'continues the middleware chain' do
46
+ expect(app).to receive(:call).with(env)
47
+ action.call(env)
48
+ end
49
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+ require "vagrant-rackspace/action/list_images"
3
+
4
+ describe VagrantPlugins::Rackspace::Action::ListImages do
5
+ let(:app) { lambda { |env| } }
6
+ let(:ui) { Vagrant::UI::Silent.new }
7
+ let(:images) {
8
+ Fog.mock!
9
+ Fog::Compute.new({
10
+ :provider => :rackspace,
11
+ :rackspace_region => :dfw,
12
+ :rackspace_api_key => 'anything',
13
+ :rackspace_username => 'anything',
14
+ }).images
15
+ }
16
+ let(:compute_connection) { double('fog connection') }
17
+ let(:env) do
18
+ {
19
+ :rackspace_compute => compute_connection,
20
+ :ui => ui
21
+ }
22
+ end
23
+
24
+ subject(:action) { described_class.new(app, env) }
25
+
26
+ before do
27
+ allow(compute_connection).to receive(:images).and_return images
28
+ end
29
+
30
+ it 'get images from Fog' do
31
+ expect(compute_connection).to receive(:images).and_return images
32
+ action.call(env)
33
+ end
34
+
35
+ it 'writes a sorted, formatted image table to Vagrant::UI' do
36
+ header_line = '%-36s %s' % ['Image ID', 'Image Name']
37
+ expect(ui).to receive(:info).with(header_line)
38
+ images.sort_by(&:name).each do |image|
39
+ formatted_line = '%-36s %s' % [image.id.to_s, image.name]
40
+ expect(ui).to receive(:info).with formatted_line
41
+ end
42
+ action.call(env)
43
+ end
44
+
45
+ it 'continues the middleware chain' do
46
+ expect(app).to receive(:call).with(env)
47
+ action.call(env)
48
+ end
49
+ end
@@ -1,15 +1,5 @@
1
- if ENV['COVERAGE'] != 'false'
2
- require 'simplecov'
3
- require 'coveralls'
4
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
- SimpleCov::Formatter::HTMLFormatter,
6
- Coveralls::SimpleCov::Formatter
7
- ]
8
- SimpleCov.start
9
- end
10
-
1
+ require 'spec_helper'
11
2
  require "vagrant-rackspace/config"
12
- require 'fog'
13
3
 
14
4
  describe VagrantPlugins::Rackspace::Config do
15
5
  describe "defaults" do
@@ -33,6 +23,7 @@ describe VagrantPlugins::Rackspace::Config do
33
23
  its(:username) { should be_nil }
34
24
  its(:disk_config) { should be_nil }
35
25
  its(:networks) { should be_nil }
26
+ its(:rsync_includes) { should be_nil }
36
27
  end
37
28
 
38
29
  describe "overriding defaults" do
@@ -62,6 +53,13 @@ describe VagrantPlugins::Rackspace::Config do
62
53
  subject.send(:networks).should include(VagrantPlugins::Rackspace::Config::PUBLIC_NET_ID)
63
54
  subject.send(:networks).should include(VagrantPlugins::Rackspace::Config::SERVICE_NET_ID)
64
55
  end
56
+
57
+ it "should not default rsync_includes if overridden" do
58
+ inc = "core"
59
+ subject.send(:rsync_include, inc)
60
+ subject.finalize!
61
+ subject.send(:rsync_includes).should include(inc)
62
+ end
65
63
  end
66
64
 
67
65
  describe "validation" do
@@ -15,8 +15,8 @@ Gem::Specification.new do |gem|
15
15
  gem.add_runtime_dependency "fog", "~> 1.18"
16
16
 
17
17
  gem.add_development_dependency "rake"
18
- gem.add_development_dependency "rspec", "~> 2.13.0"
19
- gem.add_development_dependency "aruba"
18
+ gem.add_development_dependency "rspec", "~> 2.14.0"
19
+ gem.add_development_dependency "aruba", "~> 0.5.4"
20
20
 
21
21
  gem.files = `git ls-files`.split($/)
22
22
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-rackspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hashimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-09 00:00:00.000000000 Z
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.18'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.18'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.13.0
47
+ version: 2.14.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.13.0
54
+ version: 2.14.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: aruba
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.5.4
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.5.4
69
69
  description: Enables Vagrant to manage machines in RackSpace Cloud.
70
70
  email:
71
71
  - mitchell@hashicorp.com
@@ -73,15 +73,17 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
78
  - Appraisals
79
79
  - CHANGELOG.md
80
80
  - Gemfile
81
81
  - LICENSE.txt
82
82
  - README.md
83
+ - RELEASE.md
83
84
  - Rakefile
84
85
  - Vagrantfile
86
+ - Vagrantfile.multi
85
87
  - dummy.box
86
88
  - example_box/README.md
87
89
  - example_box/metadata.json
@@ -97,20 +99,31 @@ files:
97
99
  - lib/vagrant-rackspace.rb
98
100
  - lib/vagrant-rackspace/action.rb
99
101
  - lib/vagrant-rackspace/action/connect_rackspace.rb
102
+ - lib/vagrant-rackspace/action/create_image.rb
100
103
  - lib/vagrant-rackspace/action/create_server.rb
101
104
  - lib/vagrant-rackspace/action/delete_server.rb
102
105
  - lib/vagrant-rackspace/action/is_created.rb
106
+ - lib/vagrant-rackspace/action/list_flavors.rb
107
+ - lib/vagrant-rackspace/action/list_images.rb
103
108
  - lib/vagrant-rackspace/action/message_already_created.rb
104
109
  - lib/vagrant-rackspace/action/message_not_created.rb
105
110
  - lib/vagrant-rackspace/action/read_ssh_info.rb
106
111
  - lib/vagrant-rackspace/action/read_state.rb
107
112
  - lib/vagrant-rackspace/action/sync_folders.rb
113
+ - lib/vagrant-rackspace/command/create_image.rb
114
+ - lib/vagrant-rackspace/command/flavors.rb
115
+ - lib/vagrant-rackspace/command/images.rb
116
+ - lib/vagrant-rackspace/command/list_images.rb
117
+ - lib/vagrant-rackspace/command/root.rb
108
118
  - lib/vagrant-rackspace/config.rb
109
119
  - lib/vagrant-rackspace/errors.rb
110
120
  - lib/vagrant-rackspace/plugin.rb
111
121
  - lib/vagrant-rackspace/provider.rb
112
122
  - lib/vagrant-rackspace/version.rb
113
123
  - locales/en.yml
124
+ - spec/spec_helper.rb
125
+ - spec/vagrant-rackspace/actions/list_flavors_spec.rb
126
+ - spec/vagrant-rackspace/actions/list_images_spec.rb
114
127
  - spec/vagrant-rackspace/config_spec.rb
115
128
  - vagrant-rackspace.gemspec
116
129
  homepage: http://www.vagrantup.com
@@ -122,17 +135,17 @@ require_paths:
122
135
  - lib
123
136
  required_ruby_version: !ruby/object:Gem::Requirement
124
137
  requirements:
125
- - - ! '>='
138
+ - - ">="
126
139
  - !ruby/object:Gem::Version
127
140
  version: '0'
128
141
  required_rubygems_version: !ruby/object:Gem::Requirement
129
142
  requirements:
130
- - - ! '>='
143
+ - - ">="
131
144
  - !ruby/object:Gem::Version
132
145
  version: '0'
133
146
  requirements: []
134
147
  rubyforge_project:
135
- rubygems_version: 2.0.3
148
+ rubygems_version: 2.2.0
136
149
  signing_key:
137
150
  specification_version: 4
138
151
  summary: Enables Vagrant to manage machines in RackSpace Cloud.
@@ -143,4 +156,7 @@ test_files:
143
156
  - features/support/env.rb
144
157
  - features/support/fog_mock.rb
145
158
  - features/vagrant-rackspace.feature
159
+ - spec/spec_helper.rb
160
+ - spec/vagrant-rackspace/actions/list_flavors_spec.rb
161
+ - spec/vagrant-rackspace/actions/list_images_spec.rb
146
162
  - spec/vagrant-rackspace/config_spec.rb