示例#1
0
 def generate_event(self, service, action):
     old_deploy_version = ""
     events = ServiceEvent.objects.filter(
         service_id=service.service_id).order_by("-start_time")
     if events:
         last_event = events[0]
         if last_event.final_status == "":
             if not baseService.checkEventTimeOut(last_event):
                 return "often", None
         old_deploy_version = last_event.deploy_version
     event = ServiceEvent(event_id=make_uuid(),
                          service_id=service.service_id,
                          tenant_id=self.tenant.tenant_id,
                          type=action,
                          deploy_version=service.deploy_version,
                          old_deploy_version=old_deploy_version,
                          user_name=self.user.nick_name,
                          start_time=datetime.datetime.now())
     event.save()
     if action == "deploy":
         last_all_deploy_event = ServiceEvent.objects.filter(
             service_id=service.service_id,
             type="deploy").order_by("-start_time")
         if last_all_deploy_event:
             last_deploy_event = last_all_deploy_event[0]
             old_code_version = last_deploy_event.code_version
             event.old_code_version = old_code_version
             event.save()
     return "success", event
示例#2
0
 def create_service_event(self, service, tenant, action):
     event = ServiceEvent(event_id=make_uuid(), service_id=service.service_id,
                          tenant_id=tenant.tenant_id, type="{0}".format(action),
                          deploy_version=service.deploy_version,
                          old_deploy_version=service.deploy_version,
                          user_name=self.user.nick_name, start_time=datetime.datetime.now())
     event.save()
     return event
 def create_publish_event(self, record_event, user_name, event_type):
     import datetime
     event = ServiceEvent(event_id=make_uuid(),
                          service_id=record_event.service_id,
                          tenant_id=record_event.team_id,
                          type=event_type,
                          user_name=user_name,
                          start_time=datetime.datetime.now())
     event.save()
     return event