def package(feg_host=None, vcs="hg", force=False): """ Create deploy package and push to S3. This defaults to running on local vagrant feg VM machines, but can also be pointed to an arbitrary host (e.g. amazon) by specifying a VM. feg_host: The ssh address string of the machine to run the package command. Formatted as "<user>@<host>:<port>". If not specified, defaults to the `feg` vagrant VM. vcs: version control system used, "hg" or "git". force: Bypass local commits or changes check if set to True. """ if not force and pkg.check_commit_changes(): abort("Local changes or commits not allowed") if feg_host: env.host_string = feg_host (env.user, _, _) = split_hoststring(feg_host) else: setup_env_vagrant("feg") target = "/tmp/magmadeploy_feg" run("rm -rf %s" % target) run("mkdir -p %s" % target) _package_python(target) _package_go(target) _package_scripts(target) return _push_archive_to_s3(vcs, target)
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
def package(service, cloud_host=None, vcs="hg", force=False): """ 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. """ # Check that we have no local changes or commits at this point if not force and pkg.check_commit_changes(): abort("Local changes or commits not allowed") _validate_service(service) if cloud_host: env.host_string = cloud_host (env.user, _, _) = split_hoststring(cloud_host) else: _vagrant() # Use same temp folder name for local and VM operations folder = "/tmp/magmadeploy_%s" % service local("rm -rf %s" % folder) local("mkdir -p %s" % folder) run("rm -rf %s" % folder) run("mkdir -p %s" % folder) with cd('magma/orc8r/cloud/deploy'): run('cp -pr aws/%s_appspec.yml %s/appspec.yml' % (service, folder)) run('cp -pr aws/scripts %s/.' % folder) run("mkdir -p %s/ansible/roles" % folder) run('cp -pr %s.yml %s/ansible/main.yml' % (service, folder)) run('cp -pr roles/%s %s/ansible/roles/.' % (service, folder)) run('cp -pr roles/aws_setup %s/ansible/roles/.' % folder) run('cp -pr roles/osquery %s/ansible/roles/.' % folder) run('cp -pr roles/service_registry %s/ansible/roles/.' % folder) if service == "controller": run('cp -pr /etc/magma %s/configs' % folder) run('cp -pr files/scripts/setup_swagger_ui %s/scripts/.' % folder) run('cp -pr files/static/apidocs %s/.' % folder) if service == "proxy": run('cp -pr /etc/magma %s/configs' % folder) run('cp -pr roles/disk_metrics %s/ansible/roles/.' % folder) run('cp -pr ../../../orc8r/tools/ansible/roles/pkgrepo ' '%s/ansible/roles/.' % folder) if service == 'prometheus': run('cp -pr roles/prometheus %s/ansible/roles/.' % folder) run('mkdir -p %s/bin' % folder) # To make CodeDeploy happy # Build Go binaries and plugins build() run('cp -pr go/plugins %s' % folder) _copy_go_binaries(service, folder) # Zip and push to s3 pkg_name = "magma_%s_%s" % (service, pkg.get_commit_hash(vcs)) _push_archive_to_s3(service, folder, pkg_name) run('rm -rf %s' % folder) local('rm -rf %s' % folder) return "%s.zip" % pkg_name