lib/cloudstack-cli/commands/stack.rb in cloudstack-cli-0.7.1 vs lib/cloudstack-cli/commands/stack.rb in cloudstack-cli-0.7.2

- old
+ new

@@ -7,11 +7,11 @@ projectid = find_project(stack["project"])['id'] if stack["project"] jobs = [] client.verbose = false stack["servers"].each do |instance| instance["name"].gsub(', ', ',').split(',').each do |name| - server = client.get_server(name, projectid) + server = client.get_server(name: name, project_id: projectid) if server say "Server #{name} (#{server["state"]}) already exists.", :yellow jobs << { id: 0, name: "Create server #{name}", @@ -25,11 +25,11 @@ displayname: instance["decription"], zone: instance["zone"] || stack["zone"], template: instance["template"], iso: instance["iso"] , offering: instance["offering"], - networks: string_to_array(instance["networks"]), + networks: load_string_or_array(instance["networks"]), project: stack["project"], disk_offering: instance["disk_offering"], disk_size: instance["disk_size"], group: instance["group"] || stack["group"], keypair: instance["keypair"] || stack["keypair"], @@ -46,11 +46,11 @@ say "Check for port forwarding rules...", :green jobs = [] stack["servers"].each do |instance| instance["name"].gsub(', ', ',').split(',').each do |name| if port_rules = string_to_array(instance["port_rules"]) - server = client(quiet: true).get_server(name, projectid) + server = client(quiet: true).get_server(name, project_id: projectid) create_port_rules(server, port_rules, false).each_with_index do |job_id, index| jobs << { id: job_id, name: "Create port forwarding ##{index + 1} rules for server #{name}" } @@ -78,11 +78,11 @@ end if options[:force] || yes?("Destroy the following servers #{servers.join(', ')}?", :yellow) jobs = [] servers.each do |name| - server = client(quiet: true).get_server(name, projectid) + server = client(quiet: true).get_server(name, project_id: projectid) if server jobs << { id: client.destroy_server( server['id'], false )['jobid'], @@ -103,9 +103,13 @@ $stderr.puts "Can't find the stack file #{stackfile}." rescue JSON::ParserError => e $stderr.puts "Error parsing json file.\n#{e.message}." exit end + end + + def load_string_or_array(item) + item.is_a?(Array) ? item : [item] end def string_to_array(string) string ? string.gsub(', ', ',').split(',') : nil end \ No newline at end of file