UpCloudLtd / upcloud-python-api

Python client for UpCloud's API
MIT License
53 stars 21 forks source link

add comment support for firewall rules #17

Closed juusowtf closed 8 years ago

juusowtf commented 8 years ago

It seems that Upcloud's API now has a new "comment" attribute for firewall rules:


➜  ~ curl https://api.upcloud.com/1.2/server/uuid/firewall_rule --user user:pass
{
   "firewall_rules" : {
      "firewall_rule" : [
         {
            "action" : "accept",
            "comment" : "",
            "destination_address_end" : "",
            "destination_address_start" : "",
            "destination_port_end" : "53",
            "destination_port_start" : "53",
            "direction" : "in",
            "family" : "IPv4",
            "icmp_type" : "",
            "position" : "1",
            "protocol" : "udp",
            "source_address_end" : "",
            "source_address_start" : "",
            "source_port_end" : "",
            "source_port_start" : ""
         },
         {
            "action" : "accept",
            "comment" : "",
            "destination_address_end" : "",
            "destination_address_start" : "",
            "destination_port_end" : "22",
            "destination_port_start" : "22",
            "direction" : "in",
            "family" : "IPv4",
            "icmp_type" : "",
            "position" : "2",
            "protocol" : "tcp",
            "source_address_end" : "",
            "source_address_start" : "",
            "source_port_end" : "",
            "source_port_start" : ""
         },
         {
            "action" : "reject",
            "comment" : "",
            "destination_address_end" : "",
            "destination_address_start" : "",
            "destination_port_end" : "",
            "destination_port_start" : "",
            "direction" : "in",
            "family" : "",
            "icmp_type" : "",
            "position" : "3",
            "protocol" : "",
            "source_address_end" : "",
            "source_address_start" : "",
            "source_port_end" : "",
            "source_port_start" : ""
         }
      ]
   }
}

However, the API client doesn't seem to have support for the new attribute yet. At the moment, the lack of support breaks the upcloud_firewall.py Ansible module you guys have made, since it wants to check the existing firewall rules via the API first.

A quick fix I found was to add a new "comment": None attribute to the attributes hash in upcloud_api/firewall.py. Obviously that doesn't qualify as support, but at least you can use the Ansible modules without errors.

elnygren commented 8 years ago

thanks @juusostr - going to ship a fix later today.

elnygren commented 8 years ago

upcloud_api 0.3.5 (available at via pip) contains a fix - sorry for the inconvenience.