kitchen-centurylink 0.1.0.dev

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eb410fd8a1261ea1d5a287d76e0dc85aee5ce835
4
+ data.tar.gz: 6b7e5d4fbe8223fff9c922788f3775433b564cee
5
+ SHA512:
6
+ metadata.gz: f3b876585a86d0b9b36b8cc0acb52587df27b0ad6f5c67d61b6bb313a3e2eb913649328ccd9e118c816564f6d408af93e7d3f75d1a17d73cf44adf129438e0ec
7
+ data.tar.gz: 106112135aa7743e8dca2b175d8683501081cd78a565344c53efc5877bdb295213512877757bc3df8d8d94af46757b738ae9cf3108a6ae7901c3373dc364546b
data/.cane ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ .idea/
2
+ *.iml
3
+ *.gem
4
+ *.rbc
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/.tailor ADDED
@@ -0,0 +1,4 @@
1
+ Tailor.config do |config|
2
+ config.formatters "text"
3
+ config.file_set 'lib/**/*.rb'
4
+ end
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.0.0
5
+ - 1.9.3
6
+ - 1.9.2
7
+ - ruby-head
8
+
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: ruby-head
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.1.0 / Unreleased
2
+
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+ gem 'clc_ruby_api', :path=> "C:/Users/Main/intellij projects/clc-ruby-api"
4
+
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ Author:: TODO: Write your name (<TODO: Write your email>)
2
+
3
+ Copyright (C) 2015, TODO: Write your name
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # <a name="title"></a> Kitchen::Centurylink
2
+
3
+ A Test Kitchen Driver for Centurylink.
4
+
5
+ ## <a name="requirements"></a> Requirements
6
+
7
+ You will need a <a href="www.centurylinkcloud.com" >CenturyLink Cloud account</a>s
8
+
9
+ ## <a name="installation"></a> Installation and Setup
10
+
11
+ Please read the [Driver usage][driver_usage] page for more details.
12
+
13
+ ## <a name="config"></a> Configuration
14
+
15
+ **TODO:** Write descriptions of all configuration options
16
+
17
+ ### <a name="config-require-chef-omnibus"></a> require\_chef\_omnibus
18
+
19
+ Determines whether or not a Chef [Omnibus package][chef_omnibus_dl] will be
20
+ installed. There are several different behaviors available:
21
+
22
+ * `true` - the latest release will be installed. Subsequent converges
23
+ will skip re-installing if chef is present.
24
+ * `latest` - the latest release will be installed. Subsequent converges
25
+ will always re-install even if chef is present.
26
+ * `<VERSION_STRING>` (ex: `10.24.0`) - the desired version string will
27
+ be passed the the install.sh script. Subsequent converges will skip if
28
+ the installed version and the desired version match.
29
+ * `false` or `nil` - no chef is installed.
30
+
31
+ The default value is unset, or `nil`.
32
+
33
+ ## <a name="development"></a> Development
34
+
35
+ * Source hosted at [GitHub][repo]
36
+ * Report issues/questions/feature requests on [GitHub Issues][issues]
37
+
38
+ Pull requests are very welcome! Make sure your patches are well tested.
39
+ Ideally create a topic branch for every separate change you make. For
40
+ example:
41
+
42
+ 1. Fork the repo
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
47
+
48
+ ## <a name="authors"></a> Authors
49
+
50
+ Created and maintained by [TODO: Write your name][author] (<TODO: Write your email>)
51
+
52
+ ## <a name="license"></a> License
53
+
54
+ Apache 2.0 (see [LICENSE][license])
55
+
56
+
57
+ [author]: https://github.com/enter-github-user
58
+ [issues]: https://github.com/enter-github-user/kitchen-centurylink/issues
59
+ [license]: https://github.com/enter-github-user/kitchen-centurylink/blob/master/LICENSE
60
+ [repo]: https://github.com/enter-github-user/kitchen-centurylink
61
+ [driver_usage]: http://docs.kitchen-ci.org/drivers/usage
62
+ [chef_omnibus_dl]: http://www.getchef.com/chef/install/
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require "bundler/gem_tasks"
2
+ require 'cane/rake_task'
3
+ require 'tailor/rake_task'
4
+
5
+ desc "Run cane to check quality metrics"
6
+ Cane::RakeTask.new do |cane|
7
+ cane.canefile = './.cane'
8
+ end
9
+
10
+ Tailor::RakeTask.new
11
+
12
+ desc "Display LOC stats"
13
+ task :stats do
14
+ puts "\n## Production Code Stats"
15
+ sh "countloc -r lib"
16
+ end
17
+
18
+ desc "Run all quality tasks"
19
+ task :quality => [:cane, :tailor, :stats]
20
+
21
+ task :default => [:quality]
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kitchen/driver/centurylink_version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'kitchen-centurylink'
8
+ spec.version = Kitchen::Driver::CENTURYLINK_VERSION
9
+ spec.authors = ['Anthony Howell', 'Jonathan Hinds']
10
+ spec.email = ['anthonyrhowell@gmail.com', 'jonathan.hinds@centurylink']
11
+ spec.description = %q{A Test Kitchen Driver for Centurylink}
12
+ spec.summary = spec.description
13
+ spec.homepage = ''
14
+ spec.license = 'Apache 2.0'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = []
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'test-kitchen', '~> 1.3.1'
22
+ spec.add_dependency 'clc_ruby_api'
23
+
24
+ spec.add_development_dependency 'clc_ruby_api'
25
+ spec.add_development_dependency 'bundler', '~> 1.3'
26
+ spec.add_development_dependency 'rake'
27
+
28
+ spec.add_development_dependency 'cane'
29
+ spec.add_development_dependency 'tailor'
30
+ spec.add_development_dependency 'countloc'
31
+ end
@@ -0,0 +1,154 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Anthony Howell (anthonyrhowell@gmail.com)
4
+ #
5
+ # Copyright (C) 2015, Anthony Howell
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require 'kitchen'
20
+ require 'clc_ruby_api.rb'
21
+ require "highline/import"
22
+ require 'pp'
23
+ module Kitchen
24
+
25
+ module Driver
26
+
27
+ # Centurylink driver for Kitchen.
28
+ #
29
+ # @author Anthony Howell
30
+ class Centurylink < Kitchen::Driver::SSHBase
31
+ default_config :username, 'root'
32
+ default_config :password, 'Kitchen123'
33
+ default_config :server_name, 'test'
34
+ default_config :alias, 'DFT'
35
+ default_config :cpu, 2
36
+ default_config :memoryGB, 4
37
+ default_config :serverTemplate, 'CENTOS-6-64-TEMPLATE'
38
+ default_config :type, 'standard'
39
+ default_config :assign_public_ip, false
40
+
41
+ @@client = ClcRubyApi
42
+
43
+ def create(state)
44
+
45
+ if !config[:token] && !state[:token]
46
+ puts "No CLC API token was found. Please enter your credentials to have one generated."
47
+ generateToken(state)
48
+ end
49
+
50
+ if !config[:groupId]
51
+ puts "No groupId was set. Please set groupId in .kitchen.yml and try again"
52
+ puts "See --> http://www.centurylinkcloud.com/api-docs/v2/#servers-create-server#request"
53
+ raise "Incorrect config"
54
+ end
55
+
56
+ @@client.setToken(config[:token] || state[:token])
57
+
58
+ queueId = create_server
59
+ serverInfo = @@client.getServerDetails(config[:alias], queueId + "?uuid=True")
60
+
61
+ info "Checking server status before continuing"
62
+
63
+ while serverInfo["status"] != "active" do
64
+ info "Server not up. Server status is: #{serverInfo["status"]}."
65
+ serverInfo = @@client.getServerDetails(config[:alias], queueId + "?uuid=True")
66
+ sleep 20
67
+ end
68
+ info serverInfo
69
+ state[:server_id] = serverInfo["id"]
70
+ info "Created server with id #{state[:server_id]}"
71
+
72
+ if config[:assign_public_ip]
73
+ info "Assigning public IP"
74
+ assign_public_ip(state)
75
+ else
76
+ state[:hostname] = serverInfo['details']['ipAddresses'][0]['internal']
77
+ end
78
+
79
+
80
+
81
+ end
82
+
83
+ def destroy(state)
84
+ info "Sending delete request for server #{state[:server_id]}"
85
+
86
+ @@client.setToken(config[:token])
87
+ response = @@client.deleteServer(config[:alias], state[:server_id])
88
+ if response['isQueued'] == true
89
+ info "Delete request is queued up"
90
+ state.delete(:server_id)
91
+ state.delete(:hostname)
92
+ end
93
+ end
94
+
95
+ def create_server
96
+ info "Sending create server request"
97
+ response = @@client.createServer(config[:alias],
98
+ {
99
+ :name => config[:server_name],
100
+ :groupId => config[:groupId],
101
+ :cpu => config[:cpu],
102
+ :memoryGB => config[:memoryGB],
103
+ :sourceServerId => config[:serverTemplate],
104
+ :type => config[:type],
105
+ :password => config[:password],
106
+ })
107
+ debug response
108
+
109
+ serverId = response['links'].select {|x| x['rel']=="self"}[0]['id']
110
+ end
111
+
112
+ def get_token(state)
113
+ puts "Hi"
114
+
115
+
116
+ end
117
+ def assign_public_ip(state)
118
+ response = @@client.addPublicIpAddress(config[:alias], state[:server_id], {
119
+ :ports => [ {:protocol => "TCP", :port => 80},
120
+ {:protocol => "TCP", :port => 8080},
121
+ {:protocol => "TCP", :port => 443},
122
+ {:protocol => "TCP", :port => 22},
123
+ ]})
124
+ puts response
125
+ statusId = response["id"]
126
+ status = @@client.getQueueStatus(config[:alias], statusId)
127
+
128
+ while status["status"] != "succeeded" do
129
+
130
+ info "Waiting for public IP job to complete. Status is #{status["status"]}"
131
+ sleep 20
132
+ status = @@client.getQueueStatus(config[:alias], statusId)
133
+ end
134
+ serverInfo = @@client.getServerDetails(config[:alias], state[:server_id])
135
+ state[:hostname] = serverInfo['details']['ipAddresses'].find {|ipSet| ipSet['public'] }['public']
136
+ info "Assigned public IP of: #{state[:hostname]}"
137
+ end
138
+
139
+ def generateToken(state)
140
+ if !config[:clc_username]
141
+ username = ask "Username:"
142
+ end
143
+ password = ask ("Password:") { |q| q.echo = false }
144
+ token = @@client.login username, password
145
+ info "Generated new token:"
146
+ info token
147
+ info "Save this to your project's .kitchen.yml file to use for future logins"
148
+
149
+ state[:token] = token
150
+
151
+ end
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: TODO: Write your name (<TODO: Write your email>)
4
+ #
5
+ # Copyright (C) 2015, TODO: Write your name
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ module Kitchen
20
+
21
+ module Driver
22
+
23
+ # Version string for Centurylink Kitchen driver
24
+ CENTURYLINK_VERSION = "0.1.0.dev"
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitchen-centurylink
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.dev
5
+ platform: ruby
6
+ authors:
7
+ - Anthony Howell
8
+ - Jonathan Hinds
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-03-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: test-kitchen
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: 1.3.1
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: 1.3.1
28
+ - !ruby/object:Gem::Dependency
29
+ name: clc_ruby_api
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: clc_ruby_api
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: bundler
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '1.3'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.3'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: cane
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: tailor
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: countloc
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: A Test Kitchen Driver for Centurylink
127
+ email:
128
+ - anthonyrhowell@gmail.com
129
+ - jonathan.hinds@centurylink
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - .cane
135
+ - .gitignore
136
+ - .tailor
137
+ - .travis.yml
138
+ - CHANGELOG.md
139
+ - Gemfile
140
+ - LICENSE
141
+ - README.md
142
+ - Rakefile
143
+ - kitchen-centurylink.gemspec
144
+ - lib/kitchen/driver/centurylink.rb
145
+ - lib/kitchen/driver/centurylink_version.rb
146
+ homepage: ''
147
+ licenses:
148
+ - Apache 2.0
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - '>'
162
+ - !ruby/object:Gem::Version
163
+ version: 1.3.1
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.0.14
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: A Test Kitchen Driver for Centurylink
170
+ test_files: []