Ejemplo n.º 1
0
def service_create(image, name, start, target_num_instances, instance_size, run_command, env, ports, exposes,
                   volumes, links, namespace, scaling_info, custom_domain_name, region_name):
    image_name, image_tag = util.parse_image_name_tag(image)
    instance_ports, port_list = util.parse_instance_ports(ports)
    expose_list = util.merge_internal_external_ports(port_list, exposes)
    instance_ports.extend(expose_list)
    instance_envvars = util.parse_envvars(env)
    links = util.parse_links(links)
    volumes = util.parse_volumes(volumes)
    scaling_mode, scaling_cfg = util.parse_autoscale_info(scaling_info)
    if scaling_mode is None:
        scaling_mode = 'MANUAL'
    service = Service(name=name,
                      image_name=image_name,
                      image_tag=image_tag,
                      target_num_instances=target_num_instances,
                      instance_size=instance_size,
                      run_command=run_command,
                      instance_ports=instance_ports,
                      instance_envvars=instance_envvars,
                      volumes=volumes,
                      links=links,
                      namespace=namespace,
                      scaling_mode=scaling_mode,
                      autoscaling_config=scaling_cfg,
                      custom_domain_name=custom_domain_name,
                      region_name=region_name)
    if start:
        service.run()
    else:
        service.create()
Ejemplo n.º 2
0
def service_create(image, name, start, target_num_instances, instance_size,
                   run_command, env, ports, exposes, volumes, links, namespace,
                   scaling_info, custom_domain_name, region_name):
    image_name, image_tag = util.parse_image_name_tag(image)
    instance_ports, port_list = util.parse_instance_ports(ports)
    expose_list = util.merge_internal_external_ports(port_list, exposes)
    instance_ports.extend(expose_list)
    instance_envvars = util.parse_envvars(env)
    links = util.parse_links(links)
    volumes = util.parse_volumes(volumes)
    scaling_mode, scaling_cfg = util.parse_autoscale_info(scaling_info)
    if scaling_mode is None:
        scaling_mode = 'MANUAL'
    service = Service(name=name,
                      image_name=image_name,
                      image_tag=image_tag,
                      target_num_instances=target_num_instances,
                      instance_size=instance_size,
                      run_command=run_command,
                      instance_ports=instance_ports,
                      instance_envvars=instance_envvars,
                      volumes=volumes,
                      links=links,
                      namespace=namespace,
                      scaling_mode=scaling_mode,
                      autoscaling_config=scaling_cfg,
                      custom_domain_name=custom_domain_name,
                      region_name=region_name)
    if start:
        service.run()
    else:
        service.create()
Ejemplo n.º 3
0
def service_enable_autoscaling(name, namespace, autoscaling_config):
    _, scaling_cfg = util.parse_autoscale_info(("AUTO", autoscaling_config))
    service = Service.fetch(name, namespace)
    service.enable_autoscaling(scaling_cfg)
Ejemplo n.º 4
0
def load_scaling_info(service_data):
    autoscaling_config = service_data.get('autoscaling_config')
    if autoscaling_config is None:
        return util.parse_autoscale_info(None)
    return util.parse_autoscale_info((True, autoscaling_config))
Ejemplo n.º 5
0
def service_enable_autoscaling(name, namespace, autoscaling_config):
    _, scaling_cfg = util.parse_autoscale_info(('AUTO', autoscaling_config))
    service = Service.fetch(name, namespace)
    service.enable_autoscaling(scaling_cfg)
Ejemplo n.º 6
0
def load_scaling_info(service_data):
    autoscaling_config = service_data.get('autoscaling_config')
    if autoscaling_config is None:
        return util.parse_autoscale_info(None)
    return util.parse_autoscale_info((True, autoscaling_config))