示例#1
0
文件: fabfile.py 项目: rishieee/magma
def package(vcs='hg',
            all_deps="False",
            cert_file=DEFAULT_CERT,
            proxy_config=DEFAULT_PROXY,
            destroy_vm='False',
            vm='magma',
            os="debian"):
    """ Builds the magma package """
    all_deps = False if all_deps == "False" else True
    destroy_vm = bool(strtobool(destroy_vm))

    # If a host list isn't specified, default to the magma vagrant vm
    if not env.hosts:
        vagrant_setup(vm, destroy_vm=destroy_vm)

    if not hasattr(env, 'debug_mode'):
        print("Error: The Deploy target isn't specified. Specify one with\n\n"
              "\tfab [dev|test] package")
        exit(1)

    hash = pkg.get_commit_hash(vcs)

    with cd('~/magma/lte/gateway'):
        # Generate magma dependency packages
        run('mkdir -p ~/magma-deps')
        print('Generating lte/setup.py and orc8r/setup.py '
              'magma dependency packages')
        run('./release/pydep finddep --install-from-repo -b --build-output ' +
            '~/magma-deps' + (' -l ./release/magma.lockfile.%s' % os) +
            ' python/setup.py' + (' %s/setup.py' % ORC8R_AGW_PYTHON_ROOT))

        print('Building magma package, picking up commit %s...' % hash)
        run('make clean')
        build_type = "Debug" if env.debug_mode else "RelWithDebInfo"

        run('./release/build-magma.sh -h "%s" -t %s --cert %s --proxy %s --os %s'
            % (hash, build_type, cert_file, proxy_config, os))

        run('rm -rf ~/magma-packages')
        run('mkdir -p ~/magma-packages')
        try:
            run('cp -f ~/magma-deps/*.deb ~/magma-packages')
        except Exception:
            # might be a problem if no deps found, but don't handle here
            pass
        run('mv *.deb ~/magma-packages')

        with cd('release'):
            mirrored_packages_file = 'mirrored_packages'
            if vm and vm.startswith('magma_'):
                mirrored_packages_file += vm[5:]

            run('cat {}'.format(mirrored_packages_file) +
                ' | xargs -I% sudo aptitude download -q2 %')
            run('cp *.deb ~/magma-packages')
            run('sudo rm -f *.deb')

        if all_deps:
            pkg.download_all_pkgs()
            run('cp /var/cache/apt/archives/*.deb ~/magma-packages')
示例#2
0
文件: fabfile.py 项目: go-magma/magma
def _push_archive_to_s3(vcs, target):
    pkg_name = "magma_feg_%s" % pkg.get_commit_hash(vcs)
    with cd(target):
        run('zip -r %s *' % (pkg_name))
    zip_name = "%s.zip" % pkg_name
    local("rm -rf %s" % target)
    local("mkdir -p %s" % target)
    get('%s/%s' % (target, zip_name), '%s/%s' % (target, zip_name))
    with lcd(target):
        local('%s s3 cp %s s3://magma-images/feg/' % (AWS, zip_name))
    puts("Deployment bundle: s3://magma-images/feg/%s" % zip_name)
    return zip_name
示例#3
0
def package(vcs='hg',
            all_deps="False",
            cert_file=DEFAULT_CERT,
            proxy_config=DEFAULT_PROXY):
    """ Builds the magma package """
    all_deps = False if all_deps == "False" else True

    # If a host list isn't specified, default to the magma vagrant vm
    if not env.hosts:
        setup_env_vagrant()

    if not hasattr(env, 'debug_mode'):
        print("Error: The Deploy target isn't specified. Specify one with\n\n"
              "\tfab [dev|test] package")
        exit(1)

    hash = pkg.get_commit_hash(vcs)

    with cd('~/magma/lte/gateway'):
        print("Building magma package, picking up commit %s..." % hash)
        run('make clean')
        build_type = "Debug" if env.debug_mode else "RelWithDebInfo"
        run('./release/build-magma.sh -h "%s" -t %s --cert %s --proxy %s' %
            (hash, build_type, cert_file, proxy_config))

        # Generate magma dependency packages
        run('mkdir -p ~/magma-deps')
        print("Generating lte/setup.py magma dependency packages")
        run('./release/pydep finddep -b --build-output ~/magma-deps python/setup.py'
            )

        print("Generating orc8r/setup.py magma dependency packages")
        run('./release/pydep finddep -b --build-output ~/magma-deps %s/setup.py'
            % ORC8R_AGW_PYTHON_ROOT)

        run('rm -rf ~/magma-packages')
        run('mkdir -p ~/magma-packages')
        try:
            run('cp -f ~/magma-deps/*.deb ~/magma-packages')
        except Exception:
            # might be a problem if no deps found, but don't handle here
            pass
        run('mv *.deb ~/magma-packages')

        with cd('release'):
            run('cat mirrored_packages | '
                'xargs -I% sudo aptitude download -q2 %')
            run('cp *.deb ~/magma-packages')
            run('sudo rm -f *.deb')

        if all_deps:
            pkg.download_all_pkgs()
            run('cp /var/cache/apt/archives/*.deb ~/magma-packages')
示例#4
0
def package(service,
            cloud_host="",
            vcs="hg",
            force="False",
            docker="False",
            version="latest"):
    """
    Create deploy package and push to S3. This defaults to running on local
    vagrant cloud VM machines, but can also be pointed to an arbitrary host
    (e.g. amazon) by specifying a VM.

    cloud_host: The ssh address string of the machine to run the package
        command. Formatted as "<user>@<host>:<port>". If not specified,
        defaults to the `cloud` vagrant VM.

    vcs: version control system used, "hg" or "git".

    force: Bypass local commits or changes check if set to True.

    docker: Build package for deploying using docker

    version: Package version (used for docker pull)
    """
    # Check that we have no local changes or commits at this point
    if force != "True" and pkg.check_commit_changes():
        abort("Local changes or commits not allowed")

    _validate_service(service)

    # Use same temp folder name for local and VM operations
    folder = "/tmp/magmadeploy_%s" % service
    commit_hash = pkg.get_commit_hash(vcs)
    local("rm -rf %s" % folder)
    local("mkdir -p %s" % folder)

    if docker == "True":
        zip_name = _package_docker_zip(service, folder, commit_hash, version)
    else:
        zip_name = _package_vagrant_zip(service, folder, cloud_host,
                                        commit_hash)

    # Push the zip archive to s3
    _push_archive_to_s3(service, folder, zip_name)
    local('rm -rf %s' % folder)
    return zip_name
示例#5
0
文件: fabfile.py 项目: wlm328cs/magma
def package(vcs='hg',
            all_deps="False",
            cert_file=DEFAULT_CERT,
            proxy_config=DEFAULT_PROXY):
    """ Builds the magma package """
    all_deps = False if all_deps == "False" else True

    # If a host list isn't specified, default to the magma vagrant vm
    if not env.hosts:
        setup_env_vagrant()

    if not hasattr(env, 'debug_mode'):
        print("Error: The Deploy target isn't specified. Specify one with\n\n"
              "\tfab [dev|test] package")
        exit(1)

    hash = pkg.get_commit_hash(vcs)

    with cd('~/magma/lte/gateway'):
        print("Building magma package, picking up commit %s..." % hash)
        run('make clean')
        build_type = "Debug" if env.debug_mode else "RelWithDebInfo"
        run('./release/build-magma.sh -h "%s" -t %s --cert %s --proxy %s' %
            (hash, build_type, cert_file, proxy_config))

        # Generate magma dependency packages
        print("Generating magma dependency packages")
        with cd('python'):
            run('../release/pydep finddep -b ../python/setup.py')
            run('mv *.deb ../')
        run('rm -rf ~/magma-packages')
        run('mkdir -p ~/magma-packages')
        run('mv *.deb ~/magma-packages')

        if all_deps:
            pkg.download_all_pkgs()
            run('cp /var/cache/apt/archives/*.deb ~/magma-packages')