Skip to content

Commit

Permalink
Fix README and other cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Chirag Jog committed Jun 16, 2012
1 parent 08a533e commit af6a08b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 26 deletions.
7 changes: 4 additions & 3 deletions README.rdoc
Expand Up @@ -24,14 +24,15 @@ Alternatively, the rake utility installs the gcompute CLI utility as part of ins
= INSTALLATION (WINDOWS):
Be sure you are running the latest version Chef. Versions earlier than 0.10.0 don't support plugins:

Follow these instructions to install {Chef-Workstation on Windows}[http://wiki.opscode.com/display/chef/Workstation+Setup+for+Windows]
Follow these instructions to install Chef-Workstation on Windows: http://wiki.opscode.com/display/chef/Workstation+Setup+for+Windows

The gcompute tool can be installed on Windows, via Cygwin. Install Cygwin with Python Environment:

Follow these instructions to install {Cygwin}[http://www.cygwin.com/install.html]
Setup Python, easy_install and pip {Python for Cygwin}[http://anythingsimple.blogspot.in/2010/04/using-pip-virtualenv-and.html]
Follow these instructions to install Cygwin: http://www.cygwin.com/install.html
Setup Python, easy_install and pip: http://anythingsimple.blogspot.in/2010/04/using-pip-virtualenv-and.html

In Windows, set CYGWINPATH environment variable to point the Cygwin Installation and add %CYGWINPATH%\bin to the PATH environment variable

set CYGWINPATH=<CYGWIN INSTALLATION PATH>
set PATH=%CYGWINPATH%;%PATH%

Expand Down
3 changes: 0 additions & 3 deletions Rakefile
@@ -1,4 +1,3 @@
#
# Author:: Chirag Jog (<chiragj@websym.com>)
# Copyright:: Copyright (c) 2012 Opscode, Inc.
# License:: Apache License, Version 2.0
Expand All @@ -14,7 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'rubygems'
require 'rake/gempackagetask'
Expand Down Expand Up @@ -80,7 +78,6 @@ task :install => :package do
end

#Install the gcompute library on which the knife plugin depends on
puts("PIP CMD: #{cmd}")
shell_cmd = Mixlib::ShellOut.new(cmd)
shell_cmd.run_command
puts shell_cmd.stdout
Expand Down
22 changes: 9 additions & 13 deletions lib/chef/knife/google_server_create.rb
@@ -1,4 +1,3 @@
#
# Author:: Chirag Jog (<chiragj@websym.com>)
# Copyright:: Copyright (c) 2012 Opscode, Inc.
# License:: Apache License, Version 2.0
Expand All @@ -14,7 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'highline'
require 'net/ssh/multi'
Expand Down Expand Up @@ -170,14 +168,13 @@ def tcp_test_ssh(hostname, port)
tcp_socket && tcp_socket.close
end


def run
unless Chef::Config[:knife][:server_name]
unless Chef::Config[:knife][:server_name]
ui.error("Server Name is a compulsory parameter")
exit 1
end

unless Chef::Config[:knife][:public_key_file]
unless Chef::Config[:knife][:public_key_file]
ui.error("SSH public key file is a compulsory parameter")
exit 1
end
Expand All @@ -186,6 +183,7 @@ def run
ui.error("Project ID is a compulsory parameter")
exit 1
end

$stdout.sync = true

project_id = Chef::Config[:knife][:project]
Expand All @@ -199,6 +197,7 @@ def run
zone = locate_config_value(:availability_zone)
user = locate_config_value(:ssh_user)

puts "\n#{ui.color("Waiting for the server to be Instantiated", :magenta)}"
cmd_add_instance = "#{@gcompute} addinstance #{server_name} --machine_type #{flavor} " +
"--zone #{zone} --project_id #{project_id} --tags #{server_name} " +
"--authorized_ssh_keys #{user}:#{key_file} --network #{network} --print_json"
Expand All @@ -215,11 +214,7 @@ def run
exit 1
end

puts "\n#{ui.color("Waiting for server to be Instantiated", :magenta)}"
puts("\n")

puts "\n#{ui.color("Creating Firewall for SSH and other services", :magenta)}"
puts("\n")
tcp_ports = config[:tcp_ports] # Ensure we always open the SSH Port
udp_ports = config[:udp_ports]

Expand All @@ -228,15 +223,16 @@ def run
udp_ports.select { |port| firewall_rule << "udp:#{port}," }
firewall_rule = firewall_rule[0..-2] #eliminate last comma

cmd_add_firewall = "#{@gcompute} addfirewall #{server_name} --allowed #{firewall_rule} --network #{network} " +
"--project_id #{project_id} --print_json"
cmd_add_firewall = "#{@gcompute} addfirewall #{server_name} --allowed #{firewall_rule} " +
"--network #{network} --project_id #{project_id} --print_json"

add_fw = exec_shell_cmd(cmd_add_firewall)

if add_fw.stderr.downcase.scan("error").size > 0
ui.error("\nFailed to add firewall: #{add_fw.error}")
exit 1
end

if add_fw.stdout.downcase.scan("error").size > 0
output = to_json(add_fw.output)
ui.error("\nFailed to add firewall: #{output["error"]}")
Expand All @@ -251,14 +247,14 @@ def run
ui.error("Failed to fetch server details.")
exit 1
end
server = to_json(get_instance.stdout)

server = to_json(get_instance.stdout)
private_ip = []
public_ip = []
server["networkInterfaces"].each do |interface|
private_ip << interface["networkIP"]
interface["accessConfigs"].select { |cfg| public_ip << cfg["natIP"] }
end
end

puts "#{ui.color("Public IP Address", :cyan)}: #{public_ip[0]}"
puts "#{ui.color("Private IP Address", :cyan)}: #{private_ip[0]}"
Expand Down
10 changes: 5 additions & 5 deletions lib/chef/knife/google_server_delete.rb
Expand Up @@ -44,12 +44,12 @@ def run
project_id = Chef::Config[:knife][:project]
validate_project(project_id)

@name_args.each do |server|
confirm("Do you really want to delete the server - #{server} ?")
del_instance = exec_shell_cmd("#{@gcompute} deleteinstance #{server} --print_json --project_id=#{project_id} -f")
@name_args.each do |server|
confirm("Do you really want to delete the server - #{server} ?")
del_instance = exec_shell_cmd("#{@gcompute} deleteinstance #{server} --print_json --project_id=#{project_id} -f")

if not del_instance.stderr.downcase.scan("error").empty?
ui.error("Failed to delete server. Error: #{error}")
if not del_instance.stderr.downcase.scan("error").empty?
ui.error("Failed to delete server. Error: #{error}")
exit 1
end

Expand Down
2 changes: 0 additions & 2 deletions lib/chef/knife/google_server_list.rb
@@ -1,4 +1,3 @@
#
# Author:: Chirag Jog (<chiragj@websym.com>)
# Copyright:: Copyright (c) 2012 Opscode, Inc.
# License:: Apache License, Version 2.0
Expand All @@ -14,7 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'stringio'
require 'yajl'
Expand Down

0 comments on commit af6a08b

Please sign in to comment.