lib/cloudstack-cli/commands/port_rule.rb in cloudstack-cli-0.3.6 vs lib/cloudstack-cli/commands/port_rule.rb in cloudstack-cli-0.3.7

- old
+ new

@@ -6,26 +6,26 @@ desc: "Port Forwarding Rules [public_ip]:port ...", aliases: '-r' option :network, required: true, aliases: '-n' option :project def create(server_name) - unless server = client.get_server(server_name) + projectid = find_project['id'] if options[:project] + unless server = client.get_server(server_name, projectid) error "Server #{server_name} not found." exit 1 end frontendip = nil - project = client.get_project(project) options[:rules].each do |pf_rule| ip = pf_rule.split(":")[0] if ip != '' - ip_addr = client.get_public_ip_address(ip) + ip_addr = client.get_public_ip_address(ip, projectid) unless ip_addr say "Error: IP #{ip} not found.", :red next end else ip_addr = frontendip ||= client.associate_ip_address( - client.get_network(options[:network], project ? project["id"] : nil)["id"] + client.get_network(options[:network], projectid) ) end port = pf_rule.split(":")[1] puts say "Create port forwarding rule #{ip_addr["ipaddress"]}:#{port} for server #{server_name}.", :yellow \ No newline at end of file