def get_server_public_ip(server, cached_rules=nil, cached_nat=nil)
      return nil unless server
      # find the public ip
      nic = get_server_default_nic(server)

      ssh_rule = get_ssh_port_forwarding_rule(server, cached_rules)
      return ssh_rule['ipaddress'] if ssh_rule

      winrm_rule = get_winrm_port_forwarding_rule(server, cached_rules)
      return winrm_rule['ipaddress'] if winrm_rule

      #check for static NAT
      if cached_nat
        ip_addr = cached_nat.find {|v| v['virtualmachineid'] == server['id']}
      else
        ip_addr = list_public_ip_addresses.find {|v| v['virtualmachineid'] == server['id']}
      end
      if ip_addr
        return ip_addr['ipaddress']
      end
      if nic.empty?
        return []
      end
      nic['ipaddress'] || []
    end
def get_server_public_ip(server, cached_rules=nil, cached_nat=nil)
      return nil unless server
      # find the public ip
      nic = get_server_default_nic(server)

      ssh_rule = get_ssh_port_forwarding_rule(server, cached_rules)
      return ssh_rule['ipaddress'] if ssh_rule

      winrm_rule = get_winrm_port_forwarding_rule(server, cached_rules)
      return winrm_rule['ipaddress'] if winrm_rule

      #check for static NAT
      if cached_nat
        ip_addr = cached_nat.find {|v| v['virtualmachineid'] == server['id']}
      else
        ip_addr = list_public_ip_addresses.find {|v| v['virtualmachineid'] == server['id']}
      end
      if ip_addr
        return ip_addr['ipaddress']
      end
      if nic.empty?
        return []
      end
      nic['ipaddress'] || []
    end
Finds the public ip for a server