Пример #1
0
    def set_haproxy_config(self,
                           si_id,
                           lb_version,
                           lb_uuid,
                           conf,
                           device_owner=None):
        si = ServiceInstanceSM.get(si_id)
        if not si:
            return

        for kv in si.kvps or []:
            if kv['key'] == 'haproxy_config':
                if kv['value'] == conf:
                    return

        si_obj = ServiceInstance()
        si_obj.uuid = si.uuid
        si_obj.fq_name = si.fq_name
        kvp = KeyValuePair('lb_version', lb_version)
        si_obj.add_service_instance_bindings(kvp)
        kvp = KeyValuePair('lb_uuid', lb_uuid)
        si_obj.add_service_instance_bindings(kvp)
        kvp = KeyValuePair('haproxy_config', conf)
        si_obj.add_service_instance_bindings(kvp)
        if device_owner and device_owner == 'K8S:LOADBALANCER':
            kvp = KeyValuePair('orchestrator', 'kubernetes')
            si_obj.add_service_instance_bindings(kvp)
        try:
            self._api.service_instance_update(si_obj)
        except NoIdError:
            return
Пример #2
0
    def set_haproxy_config(self, si_id, lb_version, lb_uuid, conf, device_owner=None):
        si = ServiceInstanceSM.get(si_id)
        if not si:
            return

        for kv in si.kvps or []:
            if kv['key'] == 'haproxy_config':
                if kv['value'] == conf:
                    return

        si_obj = ServiceInstance()
        si_obj.uuid = si.uuid
        si_obj.fq_name = si.fq_name
        kvp = KeyValuePair('lb_version', lb_version)
        si_obj.add_service_instance_bindings(kvp)
        kvp = KeyValuePair('lb_uuid', lb_uuid)
        si_obj.add_service_instance_bindings(kvp)
        kvp = KeyValuePair('haproxy_config', conf)
        si_obj.add_service_instance_bindings(kvp)
        if device_owner and device_owner == 'K8S:LOADBALANCER':
            kvp = KeyValuePair('orchestrator', 'kubernetes')
            si_obj.add_service_instance_bindings(kvp)
        try:
            self._api.service_instance_update(si_obj)
        except NoIdError:
            return
Пример #3
0
    def set_haproxy_config(self, si_id, lb_uuid, conf):
        si = ServiceInstanceSM.get(si_id)
        if not si:
            return

        for kv in si.kvps or []:
            if kv['key'] == 'haproxy_config':
                if kv['value'] == conf:
                    return

        si_obj = ServiceInstance()
        si_obj.uuid = si.uuid
        si_obj.fq_name = si.fq_name
        kvp = KeyValuePair('haproxy_config', conf)
        si_obj.add_service_instance_bindings(kvp)
        kvp = KeyValuePair('lb_uuid', lb_uuid)
        si_obj.add_service_instance_bindings(kvp)
        try:
            self._api.service_instance_update(si_obj)
        except NoIdError:
            return
Пример #4
0
    def set_haproxy_config(self, si_id, lb_uuid, conf):
        si = ServiceInstanceSM.get(si_id)
        if not si:
            return

        for kv in si.kvps or []:
            if kv['key'] == 'haproxy_config':
                if kv['value'] == conf:
                    return

        si_obj = ServiceInstance()
        si_obj.uuid = si.uuid
        si_obj.fq_name = si.fq_name
        kvp = KeyValuePair('haproxy_config', conf)
        si_obj.add_service_instance_bindings(kvp)
        kvp = KeyValuePair('lb_uuid', lb_uuid)
        si_obj.add_service_instance_bindings(kvp)
        try:
            self._api.service_instance_update(si_obj)
        except NoIdError:
            return