Example #1
0
def main():
    options = setup_parser()
    logging.basicConfig(level=options.log_level)

    curdir = os.getcwd()
    if not options.revisions:
        options.revisions = os.path.join(curdir, 'revisions.json')

    tmpdir = None
    if options.bundle_only is False:
        tmpdir = tempfile.mkdtemp()
        os.chdir(tmpdir)

    logging.info("Fetching Bundle")
    get_bundle(options.bundle, devel=options.devel)
    configs = glob.glob('bundle/*.yaml')
    if not configs:
        raise ValueError("%s missing YAML files" % options.bundle)

    if options.bundle_only:
        return 0

    c = ConfigStack(configs)
    if not options.deployment and len(c.keys()) == 1:
        options.deployment = c.keys()[0]

    if not options.deployment:
        raise ValueError("Ambigious bundle deployment, use -n")
    deployment = c.get(options.deployment)

    logging.info("Fetching Charms from bundle")
    deployment.fetch_charms()

    logging.info("Gathering Revisions")
    current = {}
    for charm in deployment.get_charms():
        current[charm.name] = get_bzr_revno(charm.path)
    existing = load_revisions(options.revisions)

    if tmpdir:
        shutil.rmtree(tmpdir)
    if current != existing:
        logging.debug("Recored revisions: %s" % options.revisions)
        record_revisions(options.revisions, current)
        logging.info("BUILD: exit 0")
        return 0

    logging.info("SKIP: exit 1")
    return 1
Example #2
0
def main():
    options = setup_parser()
    logging.basicConfig(level=options.log_level)

    curdir = os.getcwd()
    if not options.revisions:
        options.revisions = os.path.join(curdir, 'revisions.json')

    tmpdir = None
    if options.bundle_only is False:
        tmpdir = tempfile.mkdtemp()
        os.chdir(tmpdir)

    logging.info("Fetching Bundle")
    get_bundle(options.bundle, devel=options.devel)
    configs = glob.glob('bundle/*.yaml')
    if not configs:
        raise ValueError("%s missing YAML files" % options.bundle)

    if options.bundle_only:
        return 0

    c = ConfigStack(configs)
    if not options.deployment and len(c.keys()) == 1:
        options.deployment = c.keys()[0]

    if not options.deployment:
        raise ValueError("Ambigious bundle deployment, use -n")
    deployment = c.get(options.deployment)

    logging.info("Fetching Charms from bundle")
    deployment.fetch_charms()

    logging.info("Gathering Revisions")
    current = {}
    for charm in deployment.get_charms():
        current[charm.name] = get_bzr_revno(charm.path)
    existing = load_revisions(options.revisions)

    if tmpdir:
        shutil.rmtree(tmpdir)
    if current != existing:
        logging.debug("Recored revisions: %s" % options.revisions)
        record_revisions(options.revisions, current)
        logging.info("BUILD: exit 0")
        return 0

    logging.info("SKIP: exit 1")
    return 1
Example #3
0
def fetch_deployment(bundle_yaml, deployment=None):
    """Use bundle file to pull relevant charms"""
    if not bundle_yaml or not os.path.exists(bundle_yaml):
        raise OSError("Missing required bundle file: %s" % bundle_yaml)
    c = ConfigStack([bundle_yaml])
    if not deployment and len(c.keys()) == 1:
        deployment = c.get(c.keys()[0])
    elif deployment:
        deployment = c.get(deployment)
    else:
        raise KeyError("Ambigious Deployment, None specified")
    deployment.fetch_charms()  # update=True)
    return deployment