You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by GitBox <gi...@apache.org> on 2022/03/04 07:33:01 UTC
[GitHub] [libcloud] micafer commented on a change in pull request #1638: OpenStack: Move floating IP functions to use network service instead of nova
micafer commented on a change in pull request #1638:
URL: https://github.com/apache/libcloud/pull/1638#discussion_r819327937
##########
File path: libcloud/compute/drivers/openstack.py
##########
@@ -4330,6 +4331,74 @@ def ex_del_server_group(self, server_group):
)
return resp.status in (httplib.NO_CONTENT, httplib.ACCEPTED)
+ def _to_floating_ips(self, obj):
+ ip_elements = obj["floatingips"]
+ return [self._to_floating_ip(ip) for ip in ip_elements]
+
+ def _to_floating_ip(self, obj):
+ extra = {}
+
+ # In neutron version prior to 13.0.0 port_details does not exists
+ extra["port_details"] = obj.get("port_details")
+ extra["port_id"] = obj.get("port_id")
+ extra["floating_network_id"] = obj.get("floating_network_id")
+
+ return OpenStack_2_FloatingIpAddress(
+ id=obj["id"],
+ ip_address=obj["floating_ip_address"],
+ pool=None,
+ node_id=None,
+ driver=self,
+ extra=extra,
+ )
+
+ def ex_list_floating_ips(self):
+ """
+ List floating IPs
+ :rtype: ``list`` of :class:`OpenStack_2_FloatingIpAddress`
+ """
+ return self._to_floating_ips(
+ self.network_connection.request("/v2.0/floatingips").object
+ )
+
+ def ex_get_floating_ip(self, ip):
+ """
+ Get specified floating IP from the pool
+ :param ip: floating IP to get
+ :type ip: ``str``
+ :rtype: :class:`OpenStack_2_FloatingIpAddress`
+ """
+ floating_ips = self._to_floating_ips(
+ self.network_connection.request(
+ "/v2.0/floatingips?floating_ip_address" "=%s" % ip
+ ).object
+ )
+ return floating_ips[0] if floating_ips else None
+
+ def ex_create_floating_ip(self, ip_pool):
+ """
+ Create new floating IP. The ip_pool attribute is optional only if your
+ infrastructure has only one IP pool available.
+ :param ip_pool: name or id of the floating IP pool
+ :type ip_pool: ``str``
+ :rtype: :class:`OpenStack_2_FloatingIpAddress`
+ """
+ for pool in self.ex_list_floating_ip_pools():
+ if ip_pool == pool.name or ip_pool == pool.id:
Review comment:
You are right. Fixed in new commit.
##########
File path: CHANGES.rst
##########
@@ -25,6 +25,20 @@ Compute
(GITHUB-1629)
[Miguel Caballer - @micafer]
+- [OpenStack] OpenStack: Move floating IP functions to use network service
+ instead of nova.
+
+ This change affects all the floating ip related functions of the
+ ``OpenStack_2_NodeDriver`` class. Two new classes have been added
+ ``OpenStack_2_FloatingIpPool`` and ``OpenStack_2_FloatingIpAddress``.
+ The main change applies to the FloatingIP class where ``node_id``
+ property cannot be directly obtained from FloatingIP information and it
+ must be get from the related Port information with the ``get_node_id``
Review comment:
You are right. Fixed in new commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@libcloud.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org