kitchen-scalr 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/lib/kitchen/driver/ScalrAPI.rb +12 -7
- data/lib/kitchen/driver/scalr.rb +18 -50
- data/lib/kitchen/driver/scalr_farm_role.rb +22 -0
- data/lib/kitchen/driver/scalr_version.rb +1 -1
- metadata +26 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1715811767a16402db132ab1dd8e5416ed1c269e
|
4
|
+
data.tar.gz: 347d47af5833f7d1c1726bc79bb00f4143ae7bae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d129980743e7eb5cae182eaf40811a2009c5ef1e84fd25df6a96e1fb9c31bc5f74c0688c914c77a2d553586d0d68df6f5e73465a7b71d57de0073376fa918789
|
7
|
+
data.tar.gz: 8c465dc682af31fc18833fdeb529a032fe9cad38290bdd8088aa3afcaf6338d5fc512f9151583a2fba3be673f94d60d3255c7c3df3028ff4656feaeddc09e15b
|
data/README.md
CHANGED
@@ -26,8 +26,11 @@ Please read the [Driver usage][driver_usage] page for more details.
|
|
26
26
|
### scalr_platform
|
27
27
|
**Required in Role mode** This is the identifier of the underlying cloud platform. Examples: "ec2", "gce", "openstack".
|
28
28
|
### scalr_location
|
29
|
-
**Required** This is a string corresponding to the cloud location used to create the instance. Example: "us-east-1"
|
30
|
-
|
29
|
+
**Required in Role mode** This is a string corresponding to the cloud location used to create the instance. Example: "us-east-1"
|
30
|
+
### scalr_base_farm_role
|
31
|
+
**Optional** This is a yaml representation of a Farm Role Object as described in the APIv2 in Scalr. When kitchen-scalr creates a server, it merges this object with the previously-described parameters and creates the corresponding Farm Role. This section can be used to configure Security Groups, Networking etc... You can put the same parameters there as the ones you would get with a `scalr-ctl farm-roles get`.
|
32
|
+
### scalr_use_private_ip
|
33
|
+
**Optional** If set to true, kitchen will use Scalr private ips for the instances, otherwise it will use the public one.
|
31
34
|
## Configuration example
|
32
35
|
---
|
33
36
|
driver:
|
@@ -49,6 +52,12 @@ Please read the [Driver usage][driver_usage] page for more details.
|
|
49
52
|
scalr_use_role: 12345
|
50
53
|
scalr_platform: 'ec2'
|
51
54
|
scalr_location: 'us-east-1'
|
55
|
+
scalr_base_farm_role:
|
56
|
+
security:
|
57
|
+
securityGroups:
|
58
|
+
- id: 'sg-3b3d9153'
|
59
|
+
- id: 'sg-349a765f'
|
60
|
+
- id: 'sg-4a9a7621'
|
52
61
|
|
53
62
|
## <a name="development"></a> Development
|
54
63
|
|
@@ -66,13 +66,18 @@ class ScalrAPI
|
|
66
66
|
if body != ""
|
67
67
|
headers['Content-Type'] = 'application/json'
|
68
68
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
69
|
+
begin
|
70
|
+
response = ::RestClient::Request.execute(
|
71
|
+
:method => method,
|
72
|
+
:url => @api_url + url,
|
73
|
+
:headers => headers,
|
74
|
+
:payload => body
|
75
|
+
)
|
76
|
+
rescue RestClient::ExceptionWithResponse => e
|
77
|
+
puts "Scalr server returned an error: "
|
78
|
+
puts e.response
|
79
|
+
raise e
|
80
|
+
end
|
76
81
|
if response == ""
|
77
82
|
response = "{}"
|
78
83
|
end
|
data/lib/kitchen/driver/scalr.rb
CHANGED
@@ -22,6 +22,7 @@ require "kitchen/driver/scalr_version"
|
|
22
22
|
require "kitchen/driver/scalr_ssh_script_template"
|
23
23
|
require "kitchen/driver/scalr_cred"
|
24
24
|
require "kitchen/driver/scalr_ps_script_template"
|
25
|
+
require "kitchen/driver/scalr_farm_role"
|
25
26
|
require "json"
|
26
27
|
require 'os'
|
27
28
|
require 'securerandom'
|
@@ -36,6 +37,8 @@ module Kitchen
|
|
36
37
|
class Scalr < Kitchen::Driver::Base
|
37
38
|
include CredentialsManager
|
38
39
|
|
40
|
+
include FarmRoleObjectBuilder
|
41
|
+
|
39
42
|
kitchen_driver_api_version 2
|
40
43
|
|
41
44
|
plugin_version Kitchen::Driver::SCALR_VERSION
|
@@ -66,6 +69,10 @@ module Kitchen
|
|
66
69
|
|
67
70
|
default_config :scalr_location, ''
|
68
71
|
|
72
|
+
default_config :scalr_base_farm_role, Hash.new
|
73
|
+
|
74
|
+
default_config :scalr_use_private_ip, false
|
75
|
+
|
69
76
|
def create(state)
|
70
77
|
if config[:scalr_api_key_id]==''
|
71
78
|
#We have to find some other way of getting the credentials
|
@@ -96,32 +103,7 @@ module Kitchen
|
|
96
103
|
end
|
97
104
|
#Now create the farm role object
|
98
105
|
puts "Creating the Farm Role"
|
99
|
-
|
100
|
-
farmRoleObject = {
|
101
|
-
"alias" => fruuid,
|
102
|
-
"placement" => {
|
103
|
-
"placementConfigurationType" => placementConfigurationType(state[:imagePlatform]),
|
104
|
-
"region" => state[:imageLocation]
|
105
|
-
},
|
106
|
-
"instance" => {
|
107
|
-
"instanceConfigurationType" => instanceConfigurationType(state[:imagePlatform]),
|
108
|
-
"instanceType" => {
|
109
|
-
"id" => config[:scalr_server_instanceType]
|
110
|
-
}
|
111
|
-
},
|
112
|
-
"platform" => state[:imagePlatform],
|
113
|
-
"role" => {
|
114
|
-
"id" => state[:roleId]
|
115
|
-
},
|
116
|
-
"scaling" => {
|
117
|
-
"considerSuspendedServers" => "running",
|
118
|
-
"enabled" => true,
|
119
|
-
"maxInstances" => 1,
|
120
|
-
"minInstances" => 1,
|
121
|
-
"scalingBehavior" => "launch-terminate",
|
122
|
-
"rules" => []
|
123
|
-
}
|
124
|
-
}
|
106
|
+
farmRoleObject = buildFarmRoleObject(state, config)
|
125
107
|
response = scalr_api.create('/api/v1beta0/user/%s/farms/%d/farm-roles/' % [config[:scalr_env_id], state[:farmId]], farmRoleObject)
|
126
108
|
puts "Farm Role created"
|
127
109
|
state[:farmRoleId] = response['id']
|
@@ -137,10 +119,11 @@ module Kitchen
|
|
137
119
|
if response.size == 0 then
|
138
120
|
raise "No running server in the farm!"
|
139
121
|
end
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
122
|
+
if config[:scalr_use_private_ip] then
|
123
|
+
state[:hostname] = response[0]['privateIp'][0]
|
124
|
+
else
|
125
|
+
state[:hostname] = response[0]['publicIp'][0]
|
126
|
+
end
|
144
127
|
state[:ssh_key] = state[:keyfileName]
|
145
128
|
#state[:proxy_command] =
|
146
129
|
#state[:rdp_port] =
|
@@ -215,11 +198,11 @@ module Kitchen
|
|
215
198
|
end
|
216
199
|
|
217
200
|
def destroy(state)
|
218
|
-
if config[:scalr_api_key_id]==''
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
201
|
+
if config[:scalr_api_key_id]=='' then
|
202
|
+
#We have to find some other way of getting the credentials
|
203
|
+
loadCredentials
|
204
|
+
end
|
205
|
+
scalr_api = ScalrAPI.new(config[:scalr_api_url], config[:scalr_api_key_id], config[:scalr_api_key_secret])
|
223
206
|
cleanup_scalr(scalr_api, state)
|
224
207
|
end
|
225
208
|
|
@@ -242,21 +225,6 @@ module Kitchen
|
|
242
225
|
raise "Server status timeout!"
|
243
226
|
end
|
244
227
|
|
245
|
-
def placementConfigurationType(cloudPlatform)
|
246
|
-
return {
|
247
|
-
"ec2" => "AwsClassicPlacementConfiguration",
|
248
|
-
"openstack" => "OpenStackPlacementConfiguration",
|
249
|
-
"gce" => "GcePlacementConfiguration",
|
250
|
-
"cloudstack" => "CloudStackPlacementConfiguration"
|
251
|
-
}[cloudPlatform]
|
252
|
-
end
|
253
|
-
|
254
|
-
def instanceConfigurationType(cloudPlatform)
|
255
|
-
return {
|
256
|
-
"ec2" => "AwsInstanceConfiguration"
|
257
|
-
}[cloudPlatform]
|
258
|
-
end
|
259
|
-
|
260
228
|
def createCustomRole(scalr_api,state)
|
261
229
|
#Get the imageId for the provided image
|
262
230
|
puts 'Getting the imageId for image %s' % [config[:scalr_server_image]]
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Kitchen
|
2
|
+
module Driver
|
3
|
+
module FarmRoleObjectBuilder
|
4
|
+
def buildFarmRoleObject(state, config)
|
5
|
+
fruuid = "KITCHEN-ROLE-" + state[:suuid]
|
6
|
+
farmRoleObject = {
|
7
|
+
"alias" => fruuid,
|
8
|
+
"cloudPlatform" => state[:imagePlatform],
|
9
|
+
"cloudLocation" => state[:imageLocation],
|
10
|
+
"instanceType" => {
|
11
|
+
"id" => config[:scalr_server_instanceType]
|
12
|
+
},
|
13
|
+
"role" => {
|
14
|
+
"id" => state[:roleId]
|
15
|
+
}
|
16
|
+
}
|
17
|
+
farmRoleObject = farmRoleObject.deep_merge(config[:scalr_base_farm_role])
|
18
|
+
return farmRoleObject
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-scalr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mohammed HAWARI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
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: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rest-client
|
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: :runtime
|
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: os
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.3'
|
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
68
|
version: '1.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: cane
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: tailor
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: countloc
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
description: A Test Kitchen Driver for Scalr
|
@@ -129,10 +129,10 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
-
- .cane
|
133
|
-
- .gitignore
|
134
|
-
- .tailor
|
135
|
-
- .travis.yml
|
132
|
+
- ".cane"
|
133
|
+
- ".gitignore"
|
134
|
+
- ".tailor"
|
135
|
+
- ".travis.yml"
|
136
136
|
- CHANGELOG.md
|
137
137
|
- Gemfile
|
138
138
|
- LICENSE
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/kitchen/driver/dbapi.rb
|
144
144
|
- lib/kitchen/driver/scalr.rb
|
145
145
|
- lib/kitchen/driver/scalr_cred.rb
|
146
|
+
- lib/kitchen/driver/scalr_farm_role.rb
|
146
147
|
- lib/kitchen/driver/scalr_ps_script_template.rb
|
147
148
|
- lib/kitchen/driver/scalr_ssh_script_template.rb
|
148
149
|
- lib/kitchen/driver/scalr_version.rb
|
@@ -156,17 +157,17 @@ require_paths:
|
|
156
157
|
- lib
|
157
158
|
required_ruby_version: !ruby/object:Gem::Requirement
|
158
159
|
requirements:
|
159
|
-
- -
|
160
|
+
- - ">="
|
160
161
|
- !ruby/object:Gem::Version
|
161
162
|
version: '0'
|
162
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
164
|
requirements:
|
164
|
-
- -
|
165
|
+
- - ">="
|
165
166
|
- !ruby/object:Gem::Version
|
166
167
|
version: '0'
|
167
168
|
requirements: []
|
168
169
|
rubyforge_project:
|
169
|
-
rubygems_version: 2.
|
170
|
+
rubygems_version: 2.6.8
|
170
171
|
signing_key:
|
171
172
|
specification_version: 4
|
172
173
|
summary: A Test Kitchen Driver for Scalr
|