vagrant-mos 0.9.20 → 0.9.21
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.
- checksums.yaml +4 -4
- data/README.md +9 -9
- data/README_en.md +11 -11
- data/lib/vagrant-mos/action/connect_mos.rb +1 -1
- data/lib/vagrant-mos/command.rb +1 -1
- data/lib/vagrant-mos/config.rb +16 -16
- data/lib/vagrant-mos/version.rb +1 -1
- data/locales/en.yml +6 -6
- data/spec/vagrant-mos/config_spec.rb +25 -25
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45f82edbe87bfdf7054790b4e9f809b8e3b263cb
|
4
|
+
data.tar.gz: 6bcb2b58893150c21f47222e0de992527d3f8b32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d7b4b6c452f255a0800cf8c539ed383eda096e5f4d1e29066954bd813e7dc66edb611177450ab2d69d1cace595617b572c3db649c3d1346c574630823e3e639
|
7
|
+
data.tar.gz: c5ee63ab8f464dd3c20a00731db8e59dc094166b49ebf1af380bb8f2b5c94d0baa3d87acee14e68bab3357637e201fb45cd543eaca2a66d52544143f5f87c909
|
data/README.md
CHANGED
@@ -56,9 +56,9 @@ Vagrant.configure("2") do |config|
|
|
56
56
|
config.vm.box = "mos_box"
|
57
57
|
|
58
58
|
config.vm.provider :mos do |mos, override|
|
59
|
-
mos.
|
60
|
-
mos.
|
61
|
-
mos.
|
59
|
+
mos.access_key = "YOUR KEY"
|
60
|
+
mos.access_secret = "YOUR SECRET KEY"
|
61
|
+
mos.access_ur = "YOUR MOS ACCESS URL"
|
62
62
|
mos.keypair_name = "KEYPAIR NAME"
|
63
63
|
|
64
64
|
mos.template_id = "fa1026fe-c082-4ead-8458-802bf65ca64c"
|
@@ -82,9 +82,9 @@ end
|
|
82
82
|
|
83
83
|
MOS provider设置了若干参数,主要参数说明如下:
|
84
84
|
|
85
|
-
* `
|
86
|
-
* `
|
87
|
-
* `
|
85
|
+
* `access_key` - 访问美团云的key
|
86
|
+
* `access_secret` - 访问美团云的secret
|
87
|
+
* `access_ur` -访问美团云的url
|
88
88
|
* `region` - 创建主机的region,例如 "us-east-1"
|
89
89
|
* `template_id` - 创建美团云主机的镜像,例如 "fa1026fe-c082-4ead-8458-802bf65ca64c",用户可以使用`vagrant mos-templates`查看可以使用的镜像
|
90
90
|
* `instance_ready_timeout` - 等待MOS主机创建成功最长时间,单位为秒。默认为120s。
|
@@ -100,9 +100,9 @@ Vagrant.configure("2") do |config|
|
|
100
100
|
# ... other stuff
|
101
101
|
|
102
102
|
config.vm.provider :mos do |mos|
|
103
|
-
mos.
|
104
|
-
mos.
|
105
|
-
mos.
|
103
|
+
mos.access_key = "your_key"
|
104
|
+
mos.access_secret = "your_secret"
|
105
|
+
mos.access_ur = "your_access_url"
|
106
106
|
end
|
107
107
|
end
|
108
108
|
```
|
data/README_en.md
CHANGED
@@ -58,9 +58,9 @@ your information where necessary.
|
|
58
58
|
Vagrant.configure("2") do |config|
|
59
59
|
config.vm.box = "mos_box"
|
60
60
|
config.vm.provider :mos do |mos, override|
|
61
|
-
mos.
|
62
|
-
mos.
|
63
|
-
mos.
|
61
|
+
mos.access_key = "YOUR KEY"
|
62
|
+
mos.access_secret = "YOUR SECRET KEY"
|
63
|
+
mos.access_ur = "YOUR MOS ACCESS URL"
|
64
64
|
mos.keypair_name = "KEYPAIR NAME"
|
65
65
|
mos.template_id = "fa1026fe-c082-4ead-8458-802bf65ca64c"
|
66
66
|
override.ssh.username = "root"
|
@@ -97,7 +97,7 @@ provider-specific configuration for this provider.
|
|
97
97
|
|
98
98
|
This provider exposes quite a few provider-specific configuration options:
|
99
99
|
|
100
|
-
* `
|
100
|
+
* `access_key` - The access key for accessing MOS
|
101
101
|
* `template_id` - The image id to boot, such as "fa1026fe-c082-4ead-8458-802bf65ca64c"
|
102
102
|
* `instance_ready_timeout` - The number of seconds to wait for the instance
|
103
103
|
to become "ready" in MOS. Defaults to 120 seconds.
|
@@ -107,9 +107,9 @@ This provider exposes quite a few provider-specific configuration options:
|
|
107
107
|
value of this if not specified is "C1_M2".
|
108
108
|
* `keypair_name` - The name of the keypair to use to bootstrap images.
|
109
109
|
which support it.
|
110
|
-
* `
|
110
|
+
* `access_ur` - The accee url for accessing MOS
|
111
111
|
* `region` - The region to start the instance in, such as "us-east-1"
|
112
|
-
* `
|
112
|
+
* `access_secret` - The secret access key for accessing MOS
|
113
113
|
* `use_iam_profile` - If true, will use [IAM profiles](http://docs.mos.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
|
114
114
|
for credentials.
|
115
115
|
|
@@ -120,9 +120,9 @@ Vagrant.configure("2") do |config|
|
|
120
120
|
# ... other stuff
|
121
121
|
|
122
122
|
config.vm.provider :mos do |mos|
|
123
|
-
mos.
|
124
|
-
mos.
|
125
|
-
mos.
|
123
|
+
mos.access_key = "your_key"
|
124
|
+
mos.access_secret = "your_secret"
|
125
|
+
mos.access_ur = "your_access_url"
|
126
126
|
end
|
127
127
|
end
|
128
128
|
```
|
@@ -137,8 +137,8 @@ Vagrant.configure("2") do |config|
|
|
137
137
|
# ... other stuff
|
138
138
|
|
139
139
|
config.vm.provider :mos do |mos|
|
140
|
-
mos.
|
141
|
-
mos.
|
140
|
+
mos.access_key = "foo"
|
141
|
+
mos.access_secret = "bar"
|
142
142
|
mos.region = "us-east-1"
|
143
143
|
|
144
144
|
# Simple region config
|
@@ -22,7 +22,7 @@ module VagrantPlugins
|
|
22
22
|
region_config = env[:machine].provider_config.get_region_config(region)
|
23
23
|
|
24
24
|
@logger.info("Connecting to MOS...")
|
25
|
-
env[:mos_compute] = Client.new(region_config.
|
25
|
+
env[:mos_compute] = Client.new(region_config.access_key, region_config.access_secret, region_config.access_ur)
|
26
26
|
|
27
27
|
@app.call(env)
|
28
28
|
end
|
data/lib/vagrant-mos/command.rb
CHANGED
@@ -12,7 +12,7 @@ module VagrantPlugins
|
|
12
12
|
region_config = machine.provider_config.get_region_config(region)
|
13
13
|
|
14
14
|
@logger.info("Connecting to MOS...")
|
15
|
-
mos_compute = Client.new(region_config.
|
15
|
+
mos_compute = Client.new(region_config.access_key, region_config.access_secret, region_config.access_ur)
|
16
16
|
results = mos_compute.describe_templates['Template']
|
17
17
|
puts results
|
18
18
|
0
|
data/lib/vagrant-mos/config.rb
CHANGED
@@ -6,7 +6,7 @@ module VagrantPlugins
|
|
6
6
|
# The access key ID for accessing MOS.
|
7
7
|
#
|
8
8
|
# @return [String]
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :access_key
|
10
10
|
|
11
11
|
# The ID of the image to use.
|
12
12
|
#
|
@@ -46,15 +46,15 @@ module VagrantPlugins
|
|
46
46
|
# The secret access key for accessing MOS.
|
47
47
|
#
|
48
48
|
# @return [String]
|
49
|
-
attr_accessor :
|
49
|
+
attr_accessor :access_secret
|
50
50
|
|
51
51
|
# The secret access url for accessing MOS.
|
52
52
|
#
|
53
53
|
# @return [String]
|
54
|
-
attr_accessor :
|
54
|
+
attr_accessor :access_ur
|
55
55
|
|
56
56
|
# Use IAM Instance Role for authentication to MOS instead of an
|
57
|
-
# explicit access_id and
|
57
|
+
# explicit access_id and access_secret
|
58
58
|
#
|
59
59
|
# @return [Boolean]
|
60
60
|
attr_accessor :use_iam_profile
|
@@ -75,7 +75,7 @@ module VagrantPlugins
|
|
75
75
|
attr_accessor :ssh_host_attribute
|
76
76
|
|
77
77
|
def initialize(region_specific=false)
|
78
|
-
@
|
78
|
+
@access_key = UNSET_VALUE
|
79
79
|
@template_id = UNSET_VALUE
|
80
80
|
@instance_ready_timeout = UNSET_VALUE
|
81
81
|
@name = UNSET_VALUE
|
@@ -83,8 +83,8 @@ module VagrantPlugins
|
|
83
83
|
@keypair_name = UNSET_VALUE
|
84
84
|
@region = UNSET_VALUE
|
85
85
|
@version = UNSET_VALUE
|
86
|
-
@
|
87
|
-
@
|
86
|
+
@access_secret = UNSET_VALUE
|
87
|
+
@access_ur = UNSET_VALUE
|
88
88
|
@use_iam_profile = UNSET_VALUE
|
89
89
|
@terminate_on_shutdown = UNSET_VALUE
|
90
90
|
@ssh_host_attribute = UNSET_VALUE
|
@@ -157,9 +157,9 @@ module VagrantPlugins
|
|
157
157
|
def finalize!
|
158
158
|
# Try to get access keys from standard MOS environment variables; they
|
159
159
|
# will default to nil if the environment variables are not present.
|
160
|
-
@
|
161
|
-
@
|
162
|
-
@
|
160
|
+
@access_key = ENV['MOS_ACCESS_KEY'] if @access_key == UNSET_VALUE
|
161
|
+
@access_secret = ENV['MOS_SECRET_KEY'] if @access_secret == UNSET_VALUE
|
162
|
+
@access_ur = ENV['MOS_SECRET_URL'] if @access_ur == UNSET_VALUE
|
163
163
|
|
164
164
|
# Template_id must be nil, since we can't default that
|
165
165
|
@template_id = nil if @template_id == UNSET_VALUE
|
@@ -226,12 +226,12 @@ module VagrantPlugins
|
|
226
226
|
config = get_region_config(@region)
|
227
227
|
|
228
228
|
if !config.use_iam_profile
|
229
|
-
errors << I18n.t("vagrant_mos.config.
|
230
|
-
config.
|
231
|
-
errors << I18n.t("vagrant_mos.config.
|
232
|
-
config.
|
233
|
-
errors << I18n.t("vagrant_mos.config.
|
234
|
-
config.
|
229
|
+
errors << I18n.t("vagrant_mos.config.access_key_required") if \
|
230
|
+
config.access_key.nil?
|
231
|
+
errors << I18n.t("vagrant_mos.config.access_secret_required") if \
|
232
|
+
config.access_secret.nil?
|
233
|
+
errors << I18n.t("vagrant_mos.config.access_ur_required") if \
|
234
|
+
config.access_ur.nil?
|
235
235
|
end
|
236
236
|
|
237
237
|
errors << I18n.interpolate("vagrant_mos.config.template_id_required", :region => @region) if config.template_id.nil?
|
data/lib/vagrant-mos/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -39,18 +39,18 @@ en:
|
|
39
39
|
was declined.
|
40
40
|
|
41
41
|
config:
|
42
|
-
|
43
|
-
An access key ID must be specified via "
|
42
|
+
access_key_required: |-
|
43
|
+
An access key ID must be specified via "access_key"
|
44
44
|
template_id_required: |-
|
45
45
|
An template_id must be configured via "template_id" (region: #{region})
|
46
46
|
private_key_missing: |-
|
47
47
|
The specified private key for MOS could not be found
|
48
48
|
region_required: |-
|
49
49
|
A region must be specified via "region"
|
50
|
-
|
51
|
-
A secret access key is required via "
|
52
|
-
|
53
|
-
A secret access url is required via "
|
50
|
+
access_secret_required: |-
|
51
|
+
A secret access key is required via "access_secret"
|
52
|
+
access_ur_required: |-
|
53
|
+
A secret access url is required via "access_ur"
|
54
54
|
|
55
55
|
errors:
|
56
56
|
mos_error: |-
|
@@ -15,15 +15,15 @@ describe VagrantPlugins::MOS::Config do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
its("
|
18
|
+
its("access_key") { should be_nil }
|
19
19
|
its("template_id") { should be_nil }
|
20
20
|
its("instance_ready_timeout") { should == 120 }
|
21
21
|
its("name") { should be_nil }
|
22
22
|
its("instance_type") { should == "C1_M2" }
|
23
23
|
its("keypair_name") { should be_nil }
|
24
24
|
its("region") { should == "us-east-1" }
|
25
|
-
its("
|
26
|
-
its("
|
25
|
+
its("access_secret") { should be_nil }
|
26
|
+
its("access_ur") { should be_nil }
|
27
27
|
its("use_iam_profile") { should be_false }
|
28
28
|
its("terminate_on_shutdown") { should == false }
|
29
29
|
its("ssh_host_attribute") { should be_nil }
|
@@ -34,9 +34,9 @@ describe VagrantPlugins::MOS::Config do
|
|
34
34
|
# simple boilerplate test, so I cut corners here. It just sets
|
35
35
|
# each of these attributes to "foo" in isolation, and reads the value
|
36
36
|
# and asserts the proper result comes back out.
|
37
|
-
[:
|
37
|
+
[:access_key, :template_id, :instance_ready_timeout,:name,
|
38
38
|
:instance_type, :keypair_name, :ssh_host_attribute,
|
39
|
-
:region, :
|
39
|
+
:region, :access_secret, :access_ur, :terminate_on_shutdown,
|
40
40
|
:use_iam_profile].each do |attribute|
|
41
41
|
|
42
42
|
it "should not default #{attribute} if overridden" do
|
@@ -60,9 +60,9 @@ describe VagrantPlugins::MOS::Config do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
its("
|
64
|
-
its("
|
65
|
-
its("
|
63
|
+
its("access_key") { should be_nil }
|
64
|
+
its("access_secret") { should be_nil }
|
65
|
+
its("access_ur") { should be_nil }
|
66
66
|
end
|
67
67
|
|
68
68
|
context "with MOS credential environment variables" do
|
@@ -78,31 +78,31 @@ describe VagrantPlugins::MOS::Config do
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
its("
|
82
|
-
its("
|
83
|
-
its("
|
81
|
+
its("access_key") { should == "access_key" }
|
82
|
+
its("access_secret") { should == "secret_key" }
|
83
|
+
its("access_ur") { should == "secret_url" }
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
describe "region config" do
|
88
|
-
let(:
|
88
|
+
let(:config_access_key) { "foo" }
|
89
89
|
let(:config_template_id) { "foo" }
|
90
90
|
let(:config_instance_type) { "foo" }
|
91
91
|
let(:config_name) { "foo" }
|
92
92
|
let(:config_keypair_name) { "foo" }
|
93
93
|
let(:config_region) { "foo" }
|
94
|
-
let(:
|
95
|
-
let(:
|
94
|
+
let(:config_access_secret) { "foo" }
|
95
|
+
let(:config_access_ur) { "foo" }
|
96
96
|
|
97
97
|
def set_test_values(instance)
|
98
|
-
instance.
|
98
|
+
instance.access_key = config_access_key
|
99
99
|
instance.template_id = config_template_id
|
100
100
|
instance.instance_type = config_instance_type
|
101
101
|
instance.name = config_name
|
102
102
|
instance.keypair_name = config_keypair_name
|
103
103
|
instance.region = config_region
|
104
|
-
instance.
|
105
|
-
instance.
|
104
|
+
instance.access_secret = config_access_secret
|
105
|
+
instance.access_ur = config_access_ur
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should raise an exception if not finalized" do
|
@@ -122,14 +122,14 @@ describe VagrantPlugins::MOS::Config do
|
|
122
122
|
instance.get_region_config("us-east-1")
|
123
123
|
end
|
124
124
|
|
125
|
-
its("
|
125
|
+
its("access_key") { should == config_access_key }
|
126
126
|
its("template_id") { should == config_template_id }
|
127
127
|
its("instance_type") { should == config_instance_type }
|
128
128
|
its("name") { should == config_name }
|
129
129
|
its("keypair_name") { should == config_keypair_name }
|
130
130
|
its("region") { should == config_region }
|
131
|
-
its("
|
132
|
-
its("
|
131
|
+
its("access_secret") { should == config_access_secret }
|
132
|
+
its("access_ur") { should == config_access_ur }
|
133
133
|
end
|
134
134
|
|
135
135
|
context "with a specific config set" do
|
@@ -148,14 +148,14 @@ describe VagrantPlugins::MOS::Config do
|
|
148
148
|
instance.get_region_config(region_name)
|
149
149
|
end
|
150
150
|
|
151
|
-
its("
|
151
|
+
its("access_key") { should == config_access_key }
|
152
152
|
its("template_id") { should == config_template_id }
|
153
153
|
its("instance_type") { should == config_instance_type }
|
154
154
|
its("name") { should == config_name }
|
155
155
|
its("keypair_name") { should == config_keypair_name }
|
156
156
|
its("region") { should == region_name }
|
157
|
-
its("
|
158
|
-
its("
|
157
|
+
its("access_secret") { should == config_access_secret }
|
158
|
+
its("access_ur") { should == config_access_ur }
|
159
159
|
end
|
160
160
|
|
161
161
|
describe "inheritance of parent config" do
|
@@ -168,7 +168,7 @@ describe VagrantPlugins::MOS::Config do
|
|
168
168
|
end
|
169
169
|
|
170
170
|
# Set some top-level values
|
171
|
-
instance.
|
171
|
+
instance.access_key = "parent"
|
172
172
|
instance.template_id = "parent"
|
173
173
|
|
174
174
|
# Finalize and get the region
|
@@ -176,7 +176,7 @@ describe VagrantPlugins::MOS::Config do
|
|
176
176
|
instance.get_region_config(region_name)
|
177
177
|
end
|
178
178
|
|
179
|
-
its("
|
179
|
+
its("access_key") { should == "parent" }
|
180
180
|
its("template_id") { should == "child" }
|
181
181
|
end
|
182
182
|
|