コード例 #1
0
 def _create_component(snap):
     # component
     component = TenantServiceInfo(**snap["service_base"])
     # component source
     component_source = ServiceSourceInfo(**snap["service_source"])
     # environment
     envs = [TenantServiceEnvVar(**env) for env in snap["service_env_vars"]]
     # ports
     ports = [TenantServicesPort(**port) for port in snap["service_ports"]]
     # service_extend_method
     extend_info = ServiceExtendMethod(**snap["service_extend_method"])
     # volumes
     volumes = [TenantServiceVolume(**volume) for volume in snap["service_volumes"]]
     # configuration files
     config_files = [TenantServiceConfigurationFile(**config_file) for config_file in snap["service_config_file"]]
     # probe
     probes = [ServiceProbe(**probe) for probe in snap["service_probes"]]
     # monitors
     monitors = [ServiceMonitor(**monitor) for monitor in snap["service_monitors"]]
     # graphs
     graphs = [ComponentGraph(**graph) for graph in snap["component_graphs"]]
     return Component(
         component=component,
         component_source=component_source,
         envs=envs,
         ports=ports,
         volumes=volumes,
         config_files=config_files,
         probe=probes[0] if probes else None,
         extend_info=extend_info,
         monitors=monitors,
         graphs=graphs,
         plugin_deps=[],
     )
コード例 #2
0
    def add_app_extend_info(self, service, service_key, app_version):

        logger.debug(
            "group.publish",
            u'group.share.service. now add group shared service extend method for service {0} ok'.format(service.service_id))
        count = ServiceExtendMethod.objects.filter(service_key=service_key, app_version=app_version).count()
        if count == 0:
            extend_method = ServiceExtendMethod(
                service_key=service_key,
                app_version=app_version,
                min_node=service.min_node,
                max_node=20,
                step_node=1,
                min_memory=service.min_memory,
                max_memory=65536,
                step_memory=128,
                is_restart=False)
            extend_method.save()
        else:
            ServiceExtendMethod.objects.filter(service_key=service_key, app_version=app_version) \
                .update(min_node=service.min_node, min_memory=service.min_memory)
コード例 #3
0
 def _create_component(self, snap):
     # component
     component = TenantServiceInfo(**snap["service_base"])
     # component source
     component_source = ServiceSourceInfo(**snap["service_source"])
     # environment
     envs = [TenantServiceEnvVar(**env) for env in snap["service_env_vars"]]
     # ports
     ports = [TenantServicesPort(**port) for port in snap["service_ports"]]
     # service_extend_method
     extend_info = None
     if snap.get("service_extend_method"):
         extend_info = ServiceExtendMethod(
             **snap.get("service_extend_method"))
     # volumes
     volumes = [
         TenantServiceVolume(**volume) for volume in snap["service_volumes"]
     ]
     # configuration files
     config_files = [
         TenantServiceConfigurationFile(**config_file)
         for config_file in snap["service_config_file"]
     ]
     # probe
     probes = [ServiceProbe(**probe) for probe in snap["service_probes"]]
     # monitors
     monitors = [
         ServiceMonitor(**monitor) for monitor in snap["service_monitors"]
     ]
     # graphs
     graphs = [
         ComponentGraph(**graph) for graph in snap["component_graphs"]
     ]
     service_labels = [
         ServiceLabels(**label) for label in snap["service_labels"]
     ]
     cpt = Component(
         component=component,
         component_source=component_source,
         envs=envs,
         ports=ports,
         volumes=volumes,
         config_files=config_files,
         probes=probes,
         extend_info=extend_info,
         monitors=monitors,
         graphs=graphs,
         plugin_deps=[],
         labels=service_labels,
         support_labels=self.support_labels,
     )
     cpt.action_type = snap.get("action_type", ActionType.BUILD.value)
     return cpt
コード例 #4
0
 def _template_to_extend_info(self, component, extend_info):
     if not extend_info:
         return None
     version = component.version
     if len(version) > 255:
         version = version[:255]
     return ServiceExtendMethod(
         service_key=component.service_key,
         app_version=version,
         min_node=extend_info["min_node"],
         max_node=extend_info["max_node"],
         step_node=extend_info["step_node"],
         min_memory=extend_info["min_memory"],
         max_memory=extend_info["max_memory"],
         step_memory=extend_info["step_memory"],
         is_restart=extend_info["is_restart"])
コード例 #5
0
 def _template_to_extend_info(self, component, extend_info):
     if not extend_info:
         return None
     version = component.version
     if len(version) > 255:
         version = version[:255]
     container_cpu = extend_info.get("container_cpu")
     if container_cpu is None:
         container_cpu = baseService.calculate_service_cpu(component.service_region, component.min_memory)
     return ServiceExtendMethod(
         service_key=component.service_key,
         app_version=version,
         min_node=extend_info["min_node"],
         max_node=extend_info["max_node"],
         step_node=extend_info["step_node"],
         min_memory=extend_info["min_memory"],
         max_memory=extend_info["max_memory"],
         step_memory=extend_info["step_memory"],
         is_restart=extend_info["is_restart"],
         container_cpu=container_cpu)