コード例 #1
0
    def _create_cluster_service_fip(self, pod_name, pod_namespace, vmi_uuid):
        """
        Isolated Pods in the cluster will be allocated a floating ip
        from the cluster service network, so that the pods can talk
        to cluster services.
        """
        if not self._service_fip_pool:
            return

        # Construct parent ref.
        fip_pool_obj = FloatingIpPool()
        fip_pool_obj.uuid = self._service_fip_pool.uuid
        fip_pool_obj.fq_name = self._service_fip_pool.fq_name
        fip_pool_obj.name = self._service_fip_pool.name

        # Create Floating-Ip object.
        obj_uuid = str(uuid.uuid1())
        display_name = VncCommon.make_display_name(pod_namespace, pod_name)
        name = VncCommon.make_name(pod_name, obj_uuid)
        fip_obj = FloatingIp(name="cluster-svc-fip-%s"% (name),
                             parent_obj=fip_pool_obj,
                             floating_ip_traffic_direction='egress',
                             display_name=display_name)
        fip_obj.uuid = obj_uuid

        # Creation of fip requires the vmi vnc object.
        vmi_obj = self._vnc_lib.virtual_machine_interface_read(id=vmi_uuid)
        fip_obj.set_virtual_machine_interface(vmi_obj)

        FloatingIpKM.add_annotations(self, fip_obj, pod_namespace, pod_name)

        try:
            fip_uuid = self._vnc_lib.floating_ip_create(fip_obj)
        except RefsExistError:
            fip_uuid = self._vnc_lib.floating_ip_update(fip_obj)

        # Cached service floating ip.
        FloatingIpKM.locate(fip_uuid)

        return
コード例 #2
0
    def _create_cluster_service_fip(self, pod_name, pod_namespace, vmi_uuid):
        """
        Isolated Pods in the cluster will be allocated a floating ip
        from the cluster service network, so that the pods can talk
        to cluster services.
        """
        if not self._service_fip_pool:
            return

        # Construct parent ref.
        fip_pool_obj = FloatingIpPool()
        fip_pool_obj.uuid = self._service_fip_pool.uuid
        fip_pool_obj.fq_name = self._service_fip_pool.fq_name
        fip_pool_obj.name = self._service_fip_pool.name

        # Create Floating-Ip object.
        obj_uuid = str(uuid.uuid1())
        display_name = VncCommon.make_display_name(pod_namespace, pod_name)
        name = VncCommon.make_name(pod_name, obj_uuid)
        fip_obj = FloatingIp(name="cluster-svc-fip-%s" % (name),
                             parent_obj=fip_pool_obj,
                             floating_ip_traffic_direction='egress',
                             display_name=display_name)
        fip_obj.uuid = obj_uuid

        # Creation of fip requires the vmi vnc object.
        vmi_obj = self._vnc_lib.virtual_machine_interface_read(id=vmi_uuid)
        fip_obj.set_virtual_machine_interface(vmi_obj)

        FloatingIpKM.add_annotations(self, fip_obj, pod_namespace, pod_name)

        try:
            fip_uuid = self._vnc_lib.floating_ip_create(fip_obj)
        except RefsExistError:
            fip_uuid = self._vnc_lib.floating_ip_update(fip_obj)

        # Cached service floating ip.
        FloatingIpKM.locate(fip_uuid)

        return