コード例 #1
0
    def delete_service_label(self, tenant, service, label_id):

        label = label_repo.get_label_by_label_id(label_id)
        if not label:
            return 404, u"指定标签不存在", None
        body = dict()
        # 组件标签删除
        label_dict = dict()
        label_list = list()
        label_dict["label_key"] = "node-selector"
        label_dict["label_value"] = label.label_name
        label_list.append(label_dict)
        body["labels"] = label_list
        logger.debug('-------------------->{0}'.format(body))
        try:
            region_api.deleteServiceNodeLabel(service.service_region,
                                              tenant.tenant_name,
                                              service.service_alias, body)
            service_label_repo.delete_service_labels(service.service_id,
                                                     label_id)
        except region_api.CallApiError as e:
            logger.exception(e)
            return 507, u"组件异常", None

        return 200, u"success", None
コード例 #2
0
ファイル: label_service.py プロジェクト: ysice/rainbond-ui
    def delete_service_label(self, tenant, service, user, label_id):

        label = label_repo.get_label_by_label_id(label_id)
        if not label:
            return 404, u"指定标签不存在", None
        code, msg, event = event_service.create_event(tenant, service, user, "delete_label")
        if code != 200:
            return code, msg, event
        body = dict()
        body["event_id"] = event.event_id
        # 服务标签删除
        body["label_values"] = [label.label_name]
        body["enterprise_id"] = tenant.enterprise_id
        try:
            region_api.deleteServiceNodeLabel(service.service_region, tenant.tenant_name, service.service_alias,
                                              body)
            service_label_repo.delete_service_labels(service.service_id, label_id)
        except region_api.CallApiError as e:
            logger.exception(e)
            if event:
                event.message = u"删除标签失败".format(e.message)
                event.final_status = "complete"
                event.status = "failure"
                event.save()
            return 507, u"服务异常", event

        return 200, u"success", event
コード例 #3
0
    def delete_service_label(self, tenant, service, label_id):

        label = label_repo.get_label_by_label_id(label_id)
        if not label:
            return 404, u"指定标签不存在", None
        body = dict()
        # 服务标签删除
        body["label_values"] = [label.label_name]
        body["enterprise_id"] = tenant.enterprise_id
        try:
            region_api.deleteServiceNodeLabel(service.service_region, tenant.tenant_name, service.service_alias,
                                              body)
            service_label_repo.delete_service_labels(service.service_id, label_id)
        except region_api.CallApiError as e:
            logger.exception(e)
            return 507, u"服务异常", None

        return 200, u"success", None