Skip to content

Commit 13a2dee

Browse files
committed
Some cosmetic changes and fixing issue #98 where command line arguments are being ignored in the stack create command.
1 parent 88e20fc commit 13a2dee

2 files changed

Lines changed: 18 additions & 19 deletions

File tree

lib/chef/knife/cs_stack_create.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ class CsStackCreate < Chef::Knife
6060

6161
def run
6262
validate_base_options
63-
63+
if @name_args.first.nil?
64+
ui.error "Please specify json file eg: knife cs stack create JSON_FILE"
65+
exit 1
66+
end
6467
file_path = File.expand_path(@name_args.first)
6568
unless File.exist?(file_path) then
6669
ui.error "Stack file '#{file_path}' not found. Please check the path."
@@ -98,6 +101,12 @@ def create_server(server)
98101
cmd = KnifeCloudstack::CsServerCreate.new([server[:name]])
99102
# configure and run command
100103
# TODO: validate parameters
104+
cmd.config[:cloudstack_url] = config[:cloudstack_url]
105+
cmd.config[:cloudstack_api_key] = config[:cloudstack_api_key]
106+
cmd.config[:cloudstack_secret_key] = config[:cloudstack_secret_key]
107+
cmd.config[:cloudstack_proxy] = config[:cloudstack_proxy]
108+
cmd.config[:cloudstack_no_ssl_verify] = config[:cloudstack_no_ssl_verify]
109+
cmd.config[:cloudstack_project] = config[:cloudstack_project]
101110
cmd.config[:ssh_user] = config[:ssh_user]
102111
cmd.config[:ssh_password] = config[:ssh_password]
103112
cmd.config[:ssh_port] = config[:ssh_port] || "22" # Chef::Config[:knife][:ssh_port]

lib/chef/knife/cs_stack_delete.rb

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616
# limitations under the License.
1717
#
1818

19+
require 'chef/knife/cs_base'
20+
1921
module KnifeCloudstack
2022
class CsStackDelete < Chef::Knife
2123

24+
include Chef::Knife::KnifeCloudstackBase
25+
2226
deps do
2327
require 'chef/json_compat'
2428
require 'chef/mash'
@@ -30,25 +34,11 @@ class CsStackDelete < Chef::Knife
3034

3135
banner "knife cs stack delete JSON_FILE (options)"
3236

33-
option :cloudstack_url,
34-
:short => "-U URL",
35-
:long => "--cloudstack-url URL",
36-
:description => "The CloudStack endpoint URL",
37-
:proc => Proc.new { |url| Chef::Config[:knife][:cloudstack_url] = url }
38-
39-
option :cloudstack_api_key,
40-
:short => "-A KEY",
41-
:long => "--cloudstack-api-key KEY",
42-
:description => "Your CloudStack API key",
43-
:proc => Proc.new { |key| Chef::Config[:knife][:cloudstack_api_key] = key }
44-
45-
option :cloudstack_secret_key,
46-
:short => "-K SECRET",
47-
:long => "--cloudstack-secret-key SECRET",
48-
:description => "Your CloudStack secret key",
49-
:proc => Proc.new { |key| Chef::Config[:knife][:cloudstack_secret_key] = key }
50-
5137
def run
38+
if @name_args.first.nil?
39+
ui.error "Please specify json file eg: knife cs stack delete JSON_FILE"
40+
exit 1
41+
end
5242
file_path = File.expand_path(@name_args.first)
5343
unless File.exist?(file_path) then
5444
ui.error "Stack file '#{file_path}' not found. Please check the path."

0 commit comments

Comments
 (0)