vagrant-rackspace 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +19 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +154 -0
- data/Rakefile +21 -0
- data/dummy.box +0 -0
- data/example_box/README.md +13 -0
- data/example_box/metadata.json +3 -0
- data/lib/vagrant-rackspace.rb +53 -0
- data/lib/vagrant-rackspace/action.rb +95 -0
- data/lib/vagrant-rackspace/action/connect_rackspace.rb +37 -0
- data/lib/vagrant-rackspace/action/create_server.rb +126 -0
- data/lib/vagrant-rackspace/action/delete_server.rb +26 -0
- data/lib/vagrant-rackspace/action/is_created.rb +16 -0
- data/lib/vagrant-rackspace/action/message_already_created.rb +16 -0
- data/lib/vagrant-rackspace/action/message_not_created.rb +16 -0
- data/lib/vagrant-rackspace/action/read_ssh_info.rb +42 -0
- data/lib/vagrant-rackspace/action/read_state.rb +38 -0
- data/lib/vagrant-rackspace/action/sync_folders.rb +57 -0
- data/lib/vagrant-rackspace/action/warn_networks.rb +19 -0
- data/lib/vagrant-rackspace/config.rb +79 -0
- data/lib/vagrant-rackspace/errors.rb +27 -0
- data/lib/vagrant-rackspace/plugin.rb +37 -0
- data/lib/vagrant-rackspace/provider.rb +50 -0
- data/lib/vagrant-rackspace/version.rb +5 -0
- data/locales/en.yml +82 -0
- data/spec/vagrant-rackspace/config_spec.rb +65 -0
- data/vagrant-rackspace.gemspec +24 -0
- metadata +129 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Rackspace
|
5
|
+
module Errors
|
6
|
+
class VagrantRackspaceError < Vagrant::Errors::VagrantError
|
7
|
+
error_namespace("vagrant_rackspace.errors")
|
8
|
+
end
|
9
|
+
|
10
|
+
class CreateBadState < VagrantRackspaceError
|
11
|
+
error_key(:create_bad_state)
|
12
|
+
end
|
13
|
+
|
14
|
+
class NoMatchingFlavor < VagrantRackspaceError
|
15
|
+
error_key(:no_matching_flavor)
|
16
|
+
end
|
17
|
+
|
18
|
+
class NoMatchingImage < VagrantRackspaceError
|
19
|
+
error_key(:no_matching_image)
|
20
|
+
end
|
21
|
+
|
22
|
+
class RsyncError < VagrantRackspaceError
|
23
|
+
error_key(:rsync_error)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The RackSpace Cloud provider must be run within Vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
# This is a sanity check to make sure no one is attempting to install
|
8
|
+
# this into an early Vagrant version.
|
9
|
+
if Vagrant::VERSION < "1.1.0"
|
10
|
+
raise "RackSpace Cloud provider is only compatible with Vagrant 1.1+"
|
11
|
+
end
|
12
|
+
|
13
|
+
module VagrantPlugins
|
14
|
+
module Rackspace
|
15
|
+
class Plugin < Vagrant.plugin("2")
|
16
|
+
name "RackSpace Cloud"
|
17
|
+
description <<-DESC
|
18
|
+
This plugin enables Vagrant to manage machines in RackSpace Cloud.
|
19
|
+
DESC
|
20
|
+
|
21
|
+
config(:rackspace, :provider) do
|
22
|
+
require_relative "config"
|
23
|
+
Config
|
24
|
+
end
|
25
|
+
|
26
|
+
provider(:rackspace) do
|
27
|
+
# Setup some things
|
28
|
+
Rackspace.init_i18n
|
29
|
+
Rackspace.init_logging
|
30
|
+
|
31
|
+
# Load the actual provider
|
32
|
+
require_relative "provider"
|
33
|
+
Provider
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
require "vagrant-rackspace/action"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Rackspace
|
7
|
+
class Provider < Vagrant.plugin("2", :provider)
|
8
|
+
def initialize(machine)
|
9
|
+
@machine = machine
|
10
|
+
end
|
11
|
+
|
12
|
+
def action(name)
|
13
|
+
# Attempt to get the action method from the Action class if it
|
14
|
+
# exists, otherwise return nil to show that we don't support the
|
15
|
+
# given action.
|
16
|
+
action_method = "action_#{name}"
|
17
|
+
return Action.send(action_method) if Action.respond_to?(action_method)
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def ssh_info
|
22
|
+
# Run a custom action called "read_ssh_info" which does what it
|
23
|
+
# says and puts the resulting SSH info into the `:machine_ssh_info`
|
24
|
+
# key in the environment.
|
25
|
+
env = @machine.action("read_ssh_info")
|
26
|
+
env[:machine_ssh_info]
|
27
|
+
end
|
28
|
+
|
29
|
+
def state
|
30
|
+
# Run a custom action we define called "read_state" which does
|
31
|
+
# what it says. It puts the state in the `:machine_state_id`
|
32
|
+
# key in the environment.
|
33
|
+
env = @machine.action("read_state")
|
34
|
+
|
35
|
+
state_id = env[:machine_state_id]
|
36
|
+
|
37
|
+
# Get the short and long description
|
38
|
+
short = I18n.t("vagrant_rackspace.states.short_#{state_id}")
|
39
|
+
long = I18n.t("vagrant_rackspace.states.long_#{state_id}")
|
40
|
+
|
41
|
+
# Return the MachineState object
|
42
|
+
Vagrant::MachineState.new(state_id, short, long)
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_s
|
46
|
+
"RackSpace Cloud"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
en:
|
2
|
+
vagrant_rackspace:
|
3
|
+
already_created: |-
|
4
|
+
The server is already created.
|
5
|
+
deleting_server: |-
|
6
|
+
Deleting server...
|
7
|
+
finding_flavor: |-
|
8
|
+
Finding flavor for server...
|
9
|
+
finding_image: |-
|
10
|
+
Finding image for server...
|
11
|
+
launching_server: |-
|
12
|
+
Launching a server with the following settings...
|
13
|
+
not_created: |-
|
14
|
+
The server hasn't been created yet. Run `vagrant up` first.
|
15
|
+
ready: |-
|
16
|
+
The server is ready!
|
17
|
+
rsync_folder: |-
|
18
|
+
Rsyncing folder: %{hostpath} => %{guestpath}
|
19
|
+
waiting_for_build: |-
|
20
|
+
Waiting for the server to be built...
|
21
|
+
waiting_for_ssh: |-
|
22
|
+
Waiting for SSH to become available...
|
23
|
+
warn_insecure_ssh: |-
|
24
|
+
Warning! By not specifying a custom public/private keypair,
|
25
|
+
Vagrant is defaulting to use the insecure keypair that ships with
|
26
|
+
Vagrant. While this isn't much of a big deal for local development,
|
27
|
+
this is quite insecure for remote servers. Please specify a custom
|
28
|
+
public/private keypair.
|
29
|
+
warn_networks: |-
|
30
|
+
Warning! The Rackspace provider doesn't support any of the Vagrant
|
31
|
+
high-level network configurations (`config.vm.network`). They
|
32
|
+
will be silently ignored.
|
33
|
+
|
34
|
+
config:
|
35
|
+
api_key_required: |-
|
36
|
+
An API key is required.
|
37
|
+
public_key_not_found: |-
|
38
|
+
The public key file could not be found. Please make sure
|
39
|
+
you specified a valid path.
|
40
|
+
username_required: |-
|
41
|
+
A username is required.
|
42
|
+
|
43
|
+
errors:
|
44
|
+
create_bad_state: |-
|
45
|
+
While creating the server, it transitioned to an unexpected
|
46
|
+
state: '%{state}', instead of properly booting. Run `vagrant status`
|
47
|
+
to find out what can be done about this state, or `vagrant destroy`
|
48
|
+
if you want to start over.
|
49
|
+
no_matching_flavor: |-
|
50
|
+
No matching flavor was found! Please check your flavor setting
|
51
|
+
to make sure you have a valid flavor chosen.
|
52
|
+
no_matching_image: |-
|
53
|
+
No matching image was found! Please check your image setting to
|
54
|
+
make sure you have a valid image chosen.
|
55
|
+
rsync_error: |-
|
56
|
+
There was an error when attemping to rsync a share folder.
|
57
|
+
Please inspect the error message below for more info.
|
58
|
+
|
59
|
+
Host path: %{hostpath}
|
60
|
+
Guest path: %{guestpath}
|
61
|
+
Error: %{stderr}
|
62
|
+
|
63
|
+
states:
|
64
|
+
short_active: |-
|
65
|
+
active
|
66
|
+
long_active: |-
|
67
|
+
The server is up and running. Run `vagrant ssh` to access it.
|
68
|
+
short_build: |-
|
69
|
+
building
|
70
|
+
long_build: |-
|
71
|
+
The server is currently being built. You must wait for this to
|
72
|
+
complete before you can access it. You can delete the server, however,
|
73
|
+
by running `vagrant destroy`.
|
74
|
+
short_error: |-
|
75
|
+
error
|
76
|
+
long_error: |-
|
77
|
+
The server is in an erroneous state. Contact RackSpace support
|
78
|
+
or destroy the machine with `vagrant destroy`.
|
79
|
+
short_not_created: |-
|
80
|
+
not created
|
81
|
+
long_not_created: |-
|
82
|
+
The server is not created. Run `vagrant up` to create it.
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "vagrant-rackspace/config"
|
2
|
+
|
3
|
+
describe VagrantPlugins::Rackspace::Config do
|
4
|
+
describe "defaults" do
|
5
|
+
let(:vagrant_public_key) { Vagrant.source_root.join("keys/vagrant.pub") }
|
6
|
+
|
7
|
+
subject do
|
8
|
+
super().tap do |o|
|
9
|
+
o.finalize!
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
its(:api_key) { should be_nil }
|
14
|
+
its(:endpoint) { should be_nil }
|
15
|
+
its(:flavor) { should eq(/512MB/) }
|
16
|
+
its(:image) { should eq(/Ubuntu/) }
|
17
|
+
its(:public_key_path) { should eql(vagrant_public_key) }
|
18
|
+
its(:server_name) { should be_nil }
|
19
|
+
its(:username) { should be_nil }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "overriding defaults" do
|
23
|
+
[:api_key,
|
24
|
+
:endpoint,
|
25
|
+
:flavor,
|
26
|
+
:image,
|
27
|
+
:public_key_path,
|
28
|
+
:server_name,
|
29
|
+
:username].each do |attribute|
|
30
|
+
it "should not default #{attribute} if overridden" do
|
31
|
+
subject.send("#{attribute}=".to_sym, "foo")
|
32
|
+
subject.finalize!
|
33
|
+
subject.send(attribute).should == "foo"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "validation" do
|
39
|
+
let(:machine) { double("machine") }
|
40
|
+
|
41
|
+
subject do
|
42
|
+
super().tap do |o|
|
43
|
+
o.finalize!
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "with good values" do
|
48
|
+
it "should validate"
|
49
|
+
end
|
50
|
+
|
51
|
+
context "the API key" do
|
52
|
+
it "should error if not given"
|
53
|
+
end
|
54
|
+
|
55
|
+
context "the public key path" do
|
56
|
+
it "should have errors if the key doesn't exist"
|
57
|
+
it "should not have errors if the key exists with an absolute path"
|
58
|
+
it "should not have errors if the key exists with a relative path"
|
59
|
+
end
|
60
|
+
|
61
|
+
context "the username" do
|
62
|
+
it "should error if not given"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-rackspace/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "vagrant-rackspace"
|
8
|
+
gem.version = VagrantPlugins::Rackspace::VERSION
|
9
|
+
gem.authors = ["Mitchell Hashimoto"]
|
10
|
+
gem.email = ["mitchell@hashicorp.com"]
|
11
|
+
gem.description = "Enables Vagrant to manage machines in RackSpace Cloud."
|
12
|
+
gem.summary = "Enables Vagrant to manage machines in RackSpace Cloud."
|
13
|
+
gem.homepage = "http://www.vagrantup.com"
|
14
|
+
|
15
|
+
gem.add_runtime_dependency "fog", "~> 1.9.0"
|
16
|
+
|
17
|
+
gem.add_development_dependency "rake"
|
18
|
+
gem.add_development_dependency "rspec", "~> 2.13.0"
|
19
|
+
|
20
|
+
gem.files = `git ls-files`.split($/)
|
21
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
22
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
23
|
+
gem.require_paths = ["lib"]
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-rackspace
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mitchell Hashimoto
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fog
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.9.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.9.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.13.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.13.0
|
62
|
+
description: Enables Vagrant to manage machines in RackSpace Cloud.
|
63
|
+
email:
|
64
|
+
- mitchell@hashicorp.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- CHANGELOG.md
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- dummy.box
|
76
|
+
- example_box/README.md
|
77
|
+
- example_box/metadata.json
|
78
|
+
- lib/vagrant-rackspace.rb
|
79
|
+
- lib/vagrant-rackspace/action.rb
|
80
|
+
- lib/vagrant-rackspace/action/connect_rackspace.rb
|
81
|
+
- lib/vagrant-rackspace/action/create_server.rb
|
82
|
+
- lib/vagrant-rackspace/action/delete_server.rb
|
83
|
+
- lib/vagrant-rackspace/action/is_created.rb
|
84
|
+
- lib/vagrant-rackspace/action/message_already_created.rb
|
85
|
+
- lib/vagrant-rackspace/action/message_not_created.rb
|
86
|
+
- lib/vagrant-rackspace/action/read_ssh_info.rb
|
87
|
+
- lib/vagrant-rackspace/action/read_state.rb
|
88
|
+
- lib/vagrant-rackspace/action/sync_folders.rb
|
89
|
+
- lib/vagrant-rackspace/action/warn_networks.rb
|
90
|
+
- lib/vagrant-rackspace/config.rb
|
91
|
+
- lib/vagrant-rackspace/errors.rb
|
92
|
+
- lib/vagrant-rackspace/plugin.rb
|
93
|
+
- lib/vagrant-rackspace/provider.rb
|
94
|
+
- lib/vagrant-rackspace/version.rb
|
95
|
+
- locales/en.yml
|
96
|
+
- spec/vagrant-rackspace/config_spec.rb
|
97
|
+
- vagrant-rackspace.gemspec
|
98
|
+
homepage: http://www.vagrantup.com
|
99
|
+
licenses: []
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
hash: -1659033496405794754
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
segments:
|
120
|
+
- 0
|
121
|
+
hash: -1659033496405794754
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 1.8.23
|
125
|
+
signing_key:
|
126
|
+
specification_version: 3
|
127
|
+
summary: Enables Vagrant to manage machines in RackSpace Cloud.
|
128
|
+
test_files:
|
129
|
+
- spec/vagrant-rackspace/config_spec.rb
|