Esempio n. 1
0
def _create_task(type_, version, host, ncontainer,
    cores, nshare, networks, spec_ips, entrypoint, env, image=''):
    network_ids = [n.id for n in networks]
    task_props = {
        'ncontainer': ncontainer,
        'entrypoint': entrypoint,
        'env': env,
        'full_cores': [c.label for c in cores.get('full', [])],
        'part_cores': [c.label for c in cores.get('part', [])],
        'nshare': nshare,
        'networks': network_ids,
        'image': image,
    }
    task = Task.create(type_, version, host, task_props)
    if not task:
        return None

    try:
        create_containers_with_macvlan.apply_async(
            args=(task.id, ncontainer, nshare, cores, network_ids, spec_ips),
            task_id='task:%d' % task.id
        )
    except Exception as e:
        logger.exception(e)
        host.release_cores(cores)

    return task
Esempio n. 2
0
def _create_task(type_, version, host, ncontainer, cores, nshare, networks, spec_ips, entrypoint, env, image=""):
    network_ids = [n.id for n in networks]
    task_props = {
        "ncontainer": ncontainer,
        "entrypoint": entrypoint,
        "env": env,
        "full_cores": [c.label for c in cores.get("full", [])],
        "part_cores": [c.label for c in cores.get("part", [])],
        "nshare": nshare,
        "networks": network_ids,
        "image": image,
    }
    task = Task.create(type_, version, host, task_props)
    if not task:
        return None

    try:
        create_containers_with_macvlan.apply_async(
            args=(task.id, ncontainer, nshare, cores, network_ids, spec_ips), task_id="task:%d" % task.id
        )
    except Exception as e:
        logger.exception(e)
        host.release_cores(cores)

    return task
Esempio n. 3
0
def _create_task(type_, version, host, ncontainer, cores, networks, entrypoint, env):
    try:
        core_ids = [c.id for c in cores]
        network_ids = [n.id for n in networks]
        task_props = {
            'ncontainer': ncontainer,
            'entrypoint': entrypoint,
            'env': env,
            'cores': core_ids,
            'networks': network_ids,
        }
        task = Task.create(type_, version, host, task_props)
        create_containers_with_macvlan.apply_async(
            args=(task.id, ncontainer, core_ids, network_ids),
            task_id='task:%d' % task.id
        )
        return task
    except Exception, e:
        logger.exception(e)
        host.release_cores(cores)