knife-rackspace 0.11.1 → 1.0.0

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
- ODQzY2Q3NmUyODY1YmQ0OTUyN2Q5NjI1N2I3MTBmMDYxOGVkY2Y5MQ==
5
- data.tar.gz: !binary |-
6
- MjY0YmQ3N2VhYTA4MjZiNmI1ZDAyZDJjMzMwMzQyYzI3ODdkZDcyOQ==
2
+ SHA1:
3
+ metadata.gz: 967c80d89cf4bd3ce780e24b678aaf50324c52f6
4
+ data.tar.gz: 68897241bb46bd04c1f61e9ed40b9ea002997a8e
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YTJlMjM3ZThmZWJhYjQ3NTlkYjYzZGJjZjQ2YTQ4ZmQ2ZTMyYjZhMTU4N2Ux
10
- NmZmOTIxMjhkYzNjYjM2ZDJmZjZjZGYyY2M2NTk4NDliM2QxMTY2ODRiYTQ1
11
- YTExNmFhNGI5NzI2NTQ2NDhlMThlNjgxMWIzYTdlNTIzMGRmMDY=
12
- data.tar.gz: !binary |-
13
- NGJiY2NiOTNiN2QzOGUxNmRkN2RlYjA0MTVmZGJmOWQ2NzA1ODBmZTEwNWI2
14
- NDliY2I2ODRlMGE5NWM3OGFlZGY4ZDZjZjNhOWNiMjdmMDMyNDI3ZTRmZjhk
15
- NWYzMDMyNDYwZDc1MWFiMDkwMjI2ZjgyMjJlNTczMDJkMDVmYzI=
6
+ metadata.gz: aeaed772b104df0db30785c4ca82f3ff121bb3e311201bc48de2c3b6f8df21b1f1784278a14e2895796acb4a68fcb6cd48a3951135ca5c75735b1278e233ffd3
7
+ data.tar.gz: f2501f2c1f7d29e6f3778d58145f2768bb6b6a9a355a0e49a778ae2573cb8ee07838587536ad42268bea2d9392563ce013fd6206d28142cb2c59701f3f4508fc
@@ -0,0 +1,21 @@
1
+ # Version:
2
+
3
+ [Version of the project installed]
4
+
5
+ # Environment: [Details about the environment such as the Operating System, cookbook details, etc...]
6
+
7
+ # Scenario:
8
+
9
+ [What you are trying to achieve and you can't?]
10
+
11
+ # Steps to Reproduce:
12
+
13
+ [If you are filing an issue what are the things we need to do in order to repro your problem?]
14
+
15
+ # Expected Result:
16
+
17
+ [What are you expecting to happen as the consequence of above reproduction steps?]
18
+
19
+ # Actual Result:
20
+
21
+ [What actually happens after the reproduction steps?]
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
- sudo: false
2
1
  language: ruby
2
+ cache: bundler
3
+ sudo: false
3
4
  rvm:
4
- - 2.2
5
- - 2.1
6
- - 2.0.0
5
+ - 2.2.5
6
+ - 2.3.1
7
7
  env:
8
8
  global:
9
9
  - excon_debug: true
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## v1.0.0
2
+ * Use fog/rackspace instead of fog gem
3
+ * Require Ruby 2.2.2 / Chef 12 and general cleanup
4
+ * Spec updates to avoid deprecation warnings
5
+ * Chefstyle fixes
6
+ * Modified server list - #118
7
+
8
+ ## v0.11.1
9
+ * Remove unused, and unsupported/ancient knife-dsl requirement
10
+ * Take it all the way to 11 (Chef 11.x) and greater
11
+
1
12
  ## v0.11.0
2
13
  * Add -B (boot volume ID) to `knife rackspace server create` - #91
3
14
 
data/Gemfile CHANGED
@@ -1,3 +1,10 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
+ # Specify your gem's dependencies in knife-rackspace.gemspec
3
4
  gemspec
5
+
6
+ gem "rspec", "~> 3.0"
7
+ gem "vcr"
8
+ gem "ansi"
9
+ gem "chefstyle"
10
+ gem "rake", "~> 11.0"
data/README.md ADDED
@@ -0,0 +1,230 @@
1
+ # Knife Rackspace
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/knife-rackspace.svg)](https://rubygems.org/gems/knife-rackspace) [![Build Status](https://travis-ci.org/chef/knife-rackspace.svg?branch=master)](https://travis-ci.org/chef/knife-rackspace)
4
+
5
+ This is the official Chef Knife plugin for Rackspace Cloud Servers. This plugin gives knife the ability to create, bootstrap, and manage servers on all the regions for Rackspace Cloud Servers.
6
+
7
+ ## Requirements
8
+
9
+ - Chef 12.0 higher
10
+ - Ruby 2.2.2 or higher
11
+
12
+ ## Installation
13
+
14
+ Using [ChefDK](https://downloads.chef.io/chef-dk/), simply install the Gem:
15
+
16
+ ```bash
17
+ chef gem install knife-rackspace
18
+ ```
19
+
20
+ ## Configuration
21
+
22
+ In order to communicate with the Rackspace Cloud API you will have to tell Knife about your Username and API Key. The easiest way to accomplish this is to create some entries in your knife.rb file:
23
+
24
+ ```ruby
25
+ knife[:rackspace_api_username] = "Your Rackspace API username"
26
+ knife[:rackspace_api_key] = "Your Rackspace API Key"
27
+ ```
28
+
29
+ If your knife.rb file will be checked into a SCM system (ie readable by others) you may want to read the values from environment variables:
30
+
31
+ ```ruby
32
+ knife[:rackspace_api_username] = "#{ENV['RACKSPACE_USERNAME']}"
33
+ knife[:rackspace_api_key] = "#{ENV['RACKSPACE_API_KEY']}"
34
+ ```
35
+
36
+ You also have the option of passing your Rackspace API Username/Key into the individual knife subcommands using the **-A** (or **--rackspace-api-username**) **-K** (or **--rackspace-api-key**) command options
37
+
38
+ ```
39
+ # provision a new 1GB Ubuntu 10.04 webserver
40
+ knife rackspace server create -I 112 -f 3 -A 'Your Rackspace API username' -K "Your Rackspace API Key" -r 'role[webserver]'
41
+ ```
42
+
43
+ To select for the previous Rackspace API (aka 'v1'), you can use the **--rackspace-version v1** command option. 'v2' is the default, so if you're still using exclusively 'v1' you will probably want to add the following to your knife.rb:
44
+
45
+ ```ruby
46
+ knife[:rackspace_version] = 'v1'
47
+ ```
48
+
49
+ This plugin also has support for authenticating against an alternate API Auth URL. This is useful if you are a using a custom endpoint, here is an example of configuring your knife.rb:
50
+
51
+ ```ruby
52
+ knife[:rackspace_auth_url] = "auth.my-custom-endpoint.com"
53
+ ```
54
+
55
+ Different regions can be specified by using the `--rackspace-region` switch or using the `knife[:rackspace_region]` in the knife.rb file. Valid regions include :dfw, :ord, :lon, and :syd.
56
+
57
+ If you are behind a proxy you can specify it in the knife.rb file as follows:
58
+
59
+ ```ruby
60
+ https_proxy https://PROXY_IP_ADDRESS:PORT
61
+ ```
62
+
63
+ SSL certificate verification can be disabled by include the following in your knife.rb file:
64
+
65
+ ```ruby
66
+ knife[:ssl_verify_peer] = false
67
+ ```
68
+
69
+ Additionally the following options may be set in your knife.rb:
70
+
71
+ - flavor
72
+ - image
73
+ - distro
74
+ - template_file
75
+
76
+ ## Knife Sub Commands
77
+
78
+ This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a --help flag
79
+
80
+ ### knife rackspace server create
81
+
82
+ Provisions a new server in the Rackspace Cloud and then perform a Chef bootstrap (using the SSH protocol). The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists (provided by the provisioning). It is primarily intended for Chef Client systems that talk to a Chef server. By default the server is bootstrapped using the {chef-full}[<https://github.com/opscode/chef/blob/master/chef/lib/chef/knife/bootstrap/chef-full.erb>] template. This can be overridden using the **-d** or **--template-file** command options.
83
+
84
+ If no name is provided, nodes created with the v1 API are named after their instance ID, with the v2 API they are given a random 'rs-XXXXXXXXX' name.
85
+
86
+ Files can be injected onto the provisioned system using the **--file** switch. For example to inject my_script.sh into **/root/initialize.sh** you would use the following switch: **--file /root/initialize.sh=my_script.sh**
87
+
88
+ Note: You can only inject text files and the maximum destination path is 255 characters.
89
+
90
+ You may specify if want to manage your disk partitioning scheme with the **--rackspace-disk-config DISKCONFIG** option. If you bootstrap a `v2` node and leave this set to the default "AUTO", larger nodes take longer to bootstrap as it grows the disk from 10G to fill the full amount of local disk provided. This option allows you to pass "MANUAL" - which give you a node (in 1/2 to 1/4 of the time) and lets you manage ignoring, or formatting the rest of the disk on your own.
91
+
92
+ <http://docs.openstack.org/essex/openstack-compute/starter/content/Launch_and_manage_instances-d1e1885.html>
93
+
94
+ You may specify a custom network using the **--network [LABEL_OR_ID]** option. You can also remove the default internal ServiceNet and PublicNet networks by specifying the **--no-default-networks** switch. To use a network other than PublicNet for the bootstrap connection, specify the **--bootstrap-network LABEL** option.
95
+
96
+ Note: If you are using one of the `performanceX-X` machines, you need to put **-f** or **--flavor** in quotes.
97
+
98
+ #### Windows
99
+
100
+ Windows Servers require special treatment with the knife-rackspace gem.
101
+
102
+ First, you'll need to ensure you've installed the knife-windows gem. Installation instructions can be found over here: <http://docs.chef.io/plugin_knife_windows.html#install-this-plugin>
103
+
104
+ Secondly, you need to make sure that the image you're using has WinRM pre-configured. Unfortunately, none of the Rackspace Windows image have this done by default, so you'll need to run the following instructions in a Windows machine, then save a Snapshot to use when creating servers with knife rackspace: <http://docs.chef.io/plugin_knife_windows.html#requirements>
105
+
106
+ Thirdly, you must pass **--bootstrap-protocol winrm** and **--distro windows-chef-client-msi** parameters to the knife rackspace create command
107
+
108
+ If you have troubles, make sure you add the **-VV** switch for extra verbosity. The **--server-create-timeout** switch may also be your friend, as Windows machines take a long time to build compared to Linux ones.
109
+
110
+ ### knife rackspace server delete
111
+
112
+ Deletes an existing server in the currently configured Rackspace Cloud account by the server/instance id. You can find the instance id by entering **knife rackspace server list**. Please note - this does not delete the associated node and client objects from the Chef server unless you pass the **-P** or **--purge** command option. Using the **--purge** option with v2 nodes will attempt to delete the node and client by the name of the node.
113
+
114
+ ### knife rackspace server list
115
+
116
+ Outputs a list of all servers in the currently configured Rackspace Cloud account. Please note - this shows all instances associated with the account, some of which may not be currently managed by the Chef server. You may need to use the **--rackspace-version** and **--rackspace-region** options to see nodes in different Rackspace regions.
117
+
118
+ ### knife rackspace flavor list
119
+
120
+ Outputs a list of all available flavors (available hardware configuration for a server) available to the currently configured Rackspace Cloud account. Each flavor has a unique combination of disk space, memory capacity and priority for CPU time. This data can be useful when choosing a flavor id to pass to the **knife rackspace server create** subcommand. You may need to use the **--rackspace-version** and **--rackspace-region** options to see nodes in different Rackspace regions.
121
+
122
+ ### knife rackspace image list
123
+
124
+ Outputs a list of all available images available to the currently configured Rackspace Cloud account. An image is a collection of files used to create or rebuild a server. Rackspace provides a number of pre-built OS images by default. This data can be useful when choosing an image id to pass to the **knife rackspace server create** subcommand. You may need to use the **--rackspace-version** and **--rackspace-region** options to see nodes in different Rackspace regions.
125
+
126
+ ### knife rackspace network list
127
+
128
+ Outputs a list of available networks to the currently configured Rackspace Cloud account. Networks can be added at a server during the creation process using the **--network [LABEL_OR_ID]** option. Knife does not currently support adding a network to an existing server.
129
+
130
+ ### knife rackspace network create
131
+
132
+ Creates a new cloud network. Both the label and the CIDR are required parameters which are specified using the **--label LABEL** and **--cidr CIDR**
133
+
134
+ respectively. The CIDR should be in the form of 172.16.0.0/24 or 2001:DB8::/64\. Refer to <http://www.rackspace.com/knowledge_center/article/using-cidr-notation-in-cloud-networks> for more information.
135
+
136
+ ### knife rackspace network delete
137
+
138
+ Deletes one or more specified networks by id. The network must be detached from all hosts before it is deleted.
139
+
140
+ ### Knife & Rackspace Rackconnect
141
+
142
+ Rackspace Rackconnect allows the creation of a hybrid setup where you can have Cloud servers which are connected to bare metal hardware like Firewalls and Load balancers. You can read more about this product at <http://www.rackspace.com/cloud/hybrid/rackconnect/>
143
+
144
+ Under the hood, this changes the behavior of how the cloud servers are configured and how IP addresses are assigned to them. So when using knife-rackspace with a 'Rack connected' cloud account you need use some additional parameters. See the sections below for more information regarding the two versions of Rack Connect.
145
+
146
+ Note: If you account is leveraging private cloud networks for Rackconnnect then you are using Rackconnect v3\. You can also find your version of Rackconnect by checking with your support team
147
+
148
+ #### Knife and Rackconnect version 2
149
+
150
+ ```
151
+ knife rackspace server create \
152
+ --server-name <name of the server> \
153
+ --image <Rackspace image id> \
154
+ --flavor <Rackspace flavor id> \
155
+ -r 'role[base]' \
156
+ --rackconnect-wait
157
+ ```
158
+
159
+ Note: If the server is also part of Rackspace Managed Operations service level you will need to add the
160
+
161
+ **--rackspace-servicelevel-wait** option.
162
+
163
+ ```
164
+ knife rackspace server create \
165
+ --server-name <name of the server> \
166
+ --image <Rackspace image id> \
167
+ --flavor <Rackspace flavor id> \
168
+ -r 'role[base]' \
169
+ --rackconnect-wait \
170
+ --rackspace-servicelevel-wait
171
+ ```
172
+
173
+ **--rackconnect-wait** does the following:
174
+
175
+ - Rackconnect version 2 changes the networking on the cloud server and forces all trafic to route via the dedicated firewall or load balancer. It also then assigns the cloud server a new public IP address. The status of this automation provided by updates to the cloud server metadata. This option makes Knife wait for the Rackconnect automation to complete by checking the metadata.
176
+
177
+ - Once the status is updated, it triggers the bootstrap process.
178
+
179
+ **--rackspace-servicelevel-wait** does the following:
180
+
181
+ - For Cloud servers in the Managed operations service level, Rackspace installs additional agents and software which enables them to provide support. This automation. like the Rackconnect one, updates the cloud server metadata of its status. Likewise, using this option, makes knife wait till the automation is complete before triggering the bootstrap process.
182
+
183
+ #### Knife and Rackconnect version 3
184
+
185
+ In case of version 3, there is a different command line option.
186
+
187
+ ```
188
+ knife rackspace server create \
189
+ --server-name <name of the server> \
190
+ --image <Rackspace image id> \
191
+ --flavor <Rackspace flavor id> \
192
+ -r 'role[base]' \
193
+ --rackconnect-v3-network-id <cloud network id>
194
+ ```
195
+
196
+ **--rackconnect-v3-network-id** does the following :-
197
+
198
+ - Create the server with the corresponding cloud network. The network id the id of an existing cloud network.
199
+ - Knife will then issue additional API calls to the Rackconnect API to assign a new public IP to the cloud server. The new IP is also stored in the Cloud Server Metadata under accessv4IP.
200
+ - Knife then waits for the IP to be provisioned before triggering the bootstrap process.
201
+
202
+ Functionally, this operates the same way as version 2\. However, behind the scenes, Rackconnect v3 is significantly different in implementation. You can learn about the differences here : <http://www.rackspace.com/knowledge_center/article/comparing-rackconnect-v30-and-rackconnect-v20>
203
+
204
+ ## Contributing
205
+
206
+ For information on contributing to this project see <https://github.com/chef/chef/blob/master/CONTRIBUTING.md>
207
+
208
+ ## License and Authors
209
+
210
+ ```text
211
+ Author:: Adam Jacob (<adam@chef.io>)
212
+ Author:: Seth Chisamore (<schisamo@chef.io>)
213
+ Author:: Matt Ray (<matt@chef.io>)
214
+ Author:: JJ Asghar (<jj@chef.io>)
215
+ Author:: Rackspace Developers
216
+ Copyright:: Copyright (c) 2019-2016 Chef Software, Inc.
217
+ License:: Apache License, Version 2.0
218
+
219
+ Licensed under the Apache License, Version 2.0 (the "License");
220
+ you may not use this file except in compliance with the License.
221
+ You may obtain a copy of the License at
222
+
223
+ http://www.apache.org/licenses/LICENSE-2.0
224
+
225
+ Unless required by applicable law or agreed to in writing, software
226
+ distributed under the License is distributed on an "AS IS" BASIS,
227
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
228
+ See the License for the specific language governing permissions and
229
+ limitations under the License.
230
+ ```
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Author:: Daniel DeLeo (<dan@opscode.com>)
4
- # Copyright:: Copyright (c) 2008, 2010 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Author:: Daniel DeLeo (<dan@chef.io>)
4
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,35 +17,35 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require 'bundler'
20
+ require "bundler"
21
21
  Bundler::GemHelper.install_tasks
22
22
 
23
- require 'rspec/core/rake_task'
23
+ require "rspec/core/rake_task"
24
24
  RSpec::Core::RakeTask.new(:spec)
25
- task :default => [:credentials, :spec, 'integration:live']
25
+ task :default => [:credentials, :spec, "integration:live"]
26
26
 
27
27
  task :credentials do
28
- if ENV['TRAVIS_SECURE_ENV_VARS'] == 'false'
28
+ if ENV["TRAVIS_SECURE_ENV_VARS"] == "false"
29
29
  puts "Setting vars"
30
- ENV['OS_USERNAME'] = '_RAX_USERNAME_'
31
- ENV['OS_PASSWORD'] = '_RAX_PASSWORD_'
32
- ENV['RS_TENANT_ID'] = '000000'
33
- ENV['RS_CDN_TENANT_NAME'] = '_CDN-TENANT-NAME_'
30
+ ENV["OS_USERNAME"] = "_RAX_USERNAME_"
31
+ ENV["OS_PASSWORD"] = "_RAX_PASSWORD_"
32
+ ENV["RS_TENANT_ID"] = "000000"
33
+ ENV["RS_CDN_TENANT_NAME"] = "_CDN-TENANT-NAME_"
34
34
  end
35
- fail "Not all required variables detected" unless ENV['OS_USERNAME'] && ENV['OS_PASSWORD'] && ENV['RS_CDN_TENANT_NAME'] && ENV['RS_TENANT_ID']
35
+ raise "Not all required variables detected" unless ENV["OS_USERNAME"] && ENV["OS_PASSWORD"] && ENV["RS_CDN_TENANT_NAME"] && ENV["RS_TENANT_ID"]
36
36
  end
37
37
 
38
38
  namespace :integration do
39
- desc 'Run the integration tests'
39
+ desc "Run the integration tests"
40
40
  RSpec::Core::RakeTask.new(:test) do |t|
41
- t.pattern = 'spec/integration/**'
41
+ t.pattern = "spec/integration/**"
42
42
  end
43
43
 
44
- desc 'Run the integration tests live (no VCR cassettes)'
44
+ desc "Run the integration tests live (no VCR cassettes)"
45
45
  task :live do
46
- unless ENV['TRAVIS'] == 'true' && ENV['TRAVIS_SECURE_ENV_VARS'] == 'false'
47
- ENV['INTEGRATION_TESTS'] = 'live'
48
- Rake::Task['integration:test'].invoke
46
+ unless ENV["TRAVIS"] == "true" && ENV["TRAVIS_SECURE_ENV_VARS"] == "false"
47
+ ENV["INTEGRATION_TESTS"] = "live"
48
+ Rake::Task["integration:test"].invoke
49
49
  end
50
50
  end
51
51
  end
@@ -6,23 +6,19 @@ Gem::Specification.new do |s|
6
6
  s.name = "knife-rackspace"
7
7
  s.version = Knife::Rackspace::VERSION
8
8
  s.has_rdoc = true
9
- s.authors = ["Adam Jacob","Seth Chisamore", "Matt Ray","Rackspace Developers","JJ Asghar"]
10
- s.email = ["adam@chef.io","schisamo@chef.io", "matt@chef.io","jj@chef.io"]
9
+ s.authors = ["Adam Jacob", "Seth Chisamore", "Matt Ray", "Rackspace Developers", "JJ Asghar"]
10
+ s.email = ["adam@chef.io", "schisamo@chef.io", "matt@chef.io", "jj@chef.io"]
11
11
  s.homepage = "https://github.com/chef/knife-rackspace"
12
12
  s.summary = "Rackspace Support for Chef's Knife Command"
13
13
  s.description = s.summary
14
- s.extra_rdoc_files = ["README.rdoc", "LICENSE" ]
14
+ s.extra_rdoc_files = ["README.md", "LICENSE" ]
15
15
 
16
+ s.required_ruby_version = ">= 2.2.2"
16
17
  s.files = `git ls-files`.split("\n")
17
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
20
  s.add_dependency "knife-windows"
20
- s.add_dependency "fog", '>= 1.35'
21
- s.add_dependency "chef", ">= 11.0.0"
21
+ s.add_dependency "fog-rackspace", ">= 0.1"
22
+ s.add_dependency "chef", ">= 12.0"
22
23
  s.require_paths = ["lib"]
23
-
24
- s.add_development_dependency "rspec"
25
- s.add_development_dependency "vcr"
26
- s.add_development_dependency "ansi"
27
- s.add_development_dependency "rake"
28
24
  end
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2011-2013 Opscode, Inc.
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
+ # Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,8 +16,8 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife'
20
- require 'fog'
19
+ require "chef/knife"
20
+ require "fog/rackspace"
21
21
 
22
22
  class Chef
23
23
  class Knife
@@ -30,10 +30,10 @@ class Chef
30
30
  includer.class_eval do
31
31
 
32
32
  deps do
33
- require 'fog'
34
- require 'net/ssh/multi'
35
- require 'readline'
36
- require 'chef/json_compat'
33
+ require "fog/rackspace"
34
+ require "net/ssh/multi"
35
+ require "readline"
36
+ require "chef/json_compat"
37
37
  end
38
38
 
39
39
  option :rackspace_api_key,
@@ -49,8 +49,8 @@ class Chef
49
49
  :proc => Proc.new { |username| Chef::Config[:knife][:rackspace_username] = username }
50
50
 
51
51
  option :rackspace_version,
52
- :long => '--rackspace-version VERSION',
53
- :description => 'Rackspace Cloud Servers API version',
52
+ :long => "--rackspace-version VERSION",
53
+ :description => "Rackspace Cloud Servers API version",
54
54
  :default => "v2",
55
55
  :proc => Proc.new { |version| Chef::Config[:knife][:rackspace_version] = version }
56
56
 
@@ -65,8 +65,8 @@ class Chef
65
65
  :proc => Proc.new { |region| Chef::Config[:knife][:rackspace_region] = region }
66
66
 
67
67
  option :file,
68
- :long => '--file DESTINATION-PATH=SOURCE-PATH',
69
- :description => 'File to inject on node',
68
+ :long => "--file DESTINATION-PATH=SOURCE-PATH",
69
+ :description => "File to inject on node",
70
70
  :proc => Proc.new {|arg|
71
71
  Chef::Config[:knife][:file] ||= []
72
72
  Chef::Config[:knife][:file] << arg
@@ -94,14 +94,14 @@ class Chef
94
94
  region_warning_for_v1
95
95
  @connection ||= begin
96
96
  connection = Fog::Compute.new(connection_params({
97
- :version => 'v1'
97
+ :version => "v1",
98
98
  }))
99
99
  end
100
100
  else
101
101
  Chef::Log.debug("rackspace v2")
102
102
  @connection ||= begin
103
103
  connection = Fog::Compute.new(connection_params({
104
- :version => 'v2'
104
+ :version => "v2",
105
105
  }))
106
106
  end
107
107
  end
@@ -113,13 +113,13 @@ class Chef
113
113
  end
114
114
  end
115
115
 
116
- def connection_params(options={})
116
+ def connection_params(options = {})
117
117
  unless locate_config_value(:rackspace_region)
118
118
  ui.error "Please specify region via the command line using the --rackspace-region switch or add a knife[:rackspace_region] = REGION to your knife file."
119
119
  exit 1
120
120
  end
121
121
 
122
- username = locate_config_value(:rackspace_username) || locate_config_value(:rackspace_api_username)
122
+ username = locate_config_value(:rackspace_username) || locate_config_value(:rackspace_api_username)
123
123
  unless username
124
124
  ui.error "Please specify an api username via the command line using the --rackspace-username switch or add a knife[:rackspace_username] = USERNAME to your knife file."
125
125
  exit 1
@@ -131,18 +131,18 @@ class Chef
131
131
  end
132
132
 
133
133
  hash = options.merge({
134
- :provider => 'Rackspace',
134
+ :provider => "Rackspace",
135
135
  :rackspace_api_key => locate_config_value(:rackspace_api_key),
136
136
  :rackspace_username => username,
137
137
  :rackspace_auth_url => auth_endpoint,
138
- :rackspace_region => locate_config_value(:rackspace_region)
138
+ :rackspace_region => locate_config_value(:rackspace_region),
139
139
  })
140
140
 
141
141
  hash[:connection_options] ||= {}
142
142
  Chef::Log.debug("https_proxy #{ Chef::Config[:https_proxy] || "<not specified>"} (config)")
143
143
  Chef::Log.debug("http_proxy #{ Chef::Config[:http_proxy] || "<not specified>"} (config)")
144
144
  if Chef::Config.has_key?(:https_proxy) || Chef::Config.has_key?(:http_proxy)
145
- hash[:connection_options] = {:proxy => Chef::Config[:https_proxy] || Chef::Config[:http_proxy] }
145
+ hash[:connection_options] = { :proxy => Chef::Config[:https_proxy] || Chef::Config[:http_proxy] }
146
146
  end
147
147
  Chef::Log.debug("using proxy #{hash[:connection_options][:proxy] || "<none>"} (config)")
148
148
  Chef::Log.debug("ssl_verify_peer #{Chef::Config[:knife].has_key?(:ssl_verify_peer) ? Chef::Config[:knife][:ssl_verify_peer] : "<not specified>"} (config)")
@@ -154,7 +154,7 @@ class Chef
154
154
  def auth_endpoint
155
155
  url = locate_config_value(:rackspace_auth_url)
156
156
  return url if url
157
- (locate_config_value(:rackspace_region) == 'lon') ? ::Fog::Rackspace::UK_AUTH_ENDPOINT : ::Fog::Rackspace::US_AUTH_ENDPOINT
157
+ (locate_config_value(:rackspace_region) == "lon") ? ::Fog::Rackspace::UK_AUTH_ENDPOINT : ::Fog::Rackspace::US_AUTH_ENDPOINT
158
158
  end
159
159
 
160
160
  def locate_config_value(key)
@@ -162,21 +162,21 @@ class Chef
162
162
  Chef::Config[:knife][key] || config[key]
163
163
  end
164
164
 
165
- def msg_pair(label, value, color=:cyan)
165
+ def msg_pair(label, value, color = :cyan)
166
166
  if value && !value.to_s.empty?
167
167
  puts "#{ui.color(label, color)}: #{value}"
168
168
  end
169
169
  end
170
170
 
171
- def ip_address(server, network='public')
171
+ def ip_address(server, network = "public")
172
172
  if version_one?
173
173
  case network
174
- when 'public'; v1_public_ip(server)
175
- when 'private'; v1_private_ip(server)
174
+ when "public" then v1_public_ip(server)
175
+ when "private" then v1_private_ip(server)
176
176
  else raise NotImplementedError
177
177
  end
178
178
  else
179
- if network == 'public' && v2_access_ip(server) != ""
179
+ if network == "public" && v2_access_ip(server) != ""
180
180
  v2_access_ip(server)
181
181
  else
182
182
  v2_ip_address(server, network)
@@ -185,7 +185,7 @@ class Chef
185
185
  end
186
186
 
187
187
  def public_dns_name(server)
188
- if public_ip_address = ip_address(server, 'public')
188
+ if public_ip_address = ip_address(server, "public")
189
189
  @public_dns_name ||= begin
190
190
  Resolv.getname(public_ip_address)
191
191
  rescue
@@ -197,11 +197,11 @@ class Chef
197
197
  private
198
198
 
199
199
  def version_one?
200
- rackspace_api_version == 'v1'
200
+ rackspace_api_version == "v1"
201
201
  end
202
202
 
203
203
  def rackspace_api_version
204
- version = locate_config_value(:rackspace_version) || 'v2'
204
+ version = locate_config_value(:rackspace_version) || "v2"
205
205
  version.downcase
206
206
  end
207
207
 
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2011-2012 Opscode, Inc.
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
+ # Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife/rackspace_base'
19
+ require "chef/knife/rackspace_base"
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -29,32 +29,32 @@ class Chef
29
29
  def run
30
30
  if version_one?
31
31
  flavor_list = [
32
- ui.color('ID', :bold),
33
- ui.color('Name', :bold),
34
- ui.color('Architecture', :bold),
35
- ui.color('RAM', :bold),
36
- ui.color('Disk', :bold)
32
+ ui.color("ID", :bold),
33
+ ui.color("Name", :bold),
34
+ ui.color("Architecture", :bold),
35
+ ui.color("RAM", :bold),
36
+ ui.color("Disk", :bold),
37
37
  ]
38
38
  else
39
39
  flavor_list = [
40
- ui.color('ID', :bold),
41
- ui.color('Name', :bold),
42
- ui.color('VCPUs', :bold),
43
- ui.color('RAM', :bold),
44
- ui.color('Disk', :bold)
40
+ ui.color("ID", :bold),
41
+ ui.color("Name", :bold),
42
+ ui.color("VCPUs", :bold),
43
+ ui.color("RAM", :bold),
44
+ ui.color("Disk", :bold),
45
45
  ]
46
46
  end
47
47
  connection.flavors.sort_by(&:id).each do |flavor|
48
- bits = flavor.respond_to?(:bits) ? "#{flavor.bits.to_s}-bit" : ""
48
+ bits = flavor.respond_to?(:bits) ? "#{flavor.bits}-bit" : ""
49
49
 
50
50
  flavor_list << flavor.id.to_s
51
51
  flavor_list << flavor.name
52
52
  flavor_list << bits if version_one?
53
53
  flavor_list << flavor.vcpus.to_s unless version_one?
54
- flavor_list << "#{flavor.ram.to_s}"
55
- flavor_list << "#{flavor.disk.to_s} GB"
54
+ flavor_list << "#{flavor.ram}"
55
+ flavor_list << "#{flavor.disk} GB"
56
56
  end
57
- puts ui.list(flavor_list, :uneven_columns_across, 5)
57
+ puts ui.list(flavor_list, :uneven_columns_across, 5)
58
58
  end
59
59
  end
60
60
  end