Esempio n. 1
0
def get_blueprints():
    """get_blueprints()

    Return a list of all blueprints.
    """
    blueprints = []
    for bp in cache.get_blueprints():
        bp = cache.get_blueprint(bp['id'])
        blueprints.append(application.appdef_from_app(bp))
    return blueprints
Esempio n. 2
0
def do_save(args, env):
    """The "ravello save" command."""

    with env.let(quiet=True):
        login.default_login()
        keypair.default_keypair()
        manif = manifest.default_manifest(required=False)

    app = application.default_application(args.application)
    appname = app["name"]
    project, defname, instance = appname.split(":")

    state = application.get_application_state(app)
    if state not in ("STOPPED", "STARTED"):
        error.raise_error(
            "Application `{0}:{1}` is currently in state {2}.\n" "Can only create blueprint when STOPPED or STARTED.",
            defname,
            instance,
            state,
        )

    if state == "STARTED" and not env.always_confirm:
        console.info("Application `{0}:{1}` is currently running.", defname, instance)
        result = console.confirm("Do you want to continue with a live snapshot")
        if not result:
            console.info("Not confirmed.")
            return error.EX_OK

    template = "{0}:{1}".format(project, defname)
    bpname = util.get_unused_name(template, cache.get_blueprints())
    parts = bpname.split(":")

    console.info("Saving blueprint as `{0}:{1}`.", parts[1], parts[2])

    blueprint = env.api.create_blueprint(bpname, app)
    env.blueprint = blueprint  # for tests

    console.info("Blueprint creation process started.")
    console.info("Use 'ravtest ps -b' to monitor progress.")

    return error.EX_OK
Esempio n. 3
0
def new_blueprint_name(template):
    """Return a new blueprint name based on *template*."""
    name = util.get_unused_name(template, cache.get_blueprints())
    return name