def create_instance_from_saved_state(): saved_state = load_state() cloud = saved_state['cloud'] specified_cloud = env.config.get('cloud') if specified_cloud and specified_cloud != cloud: log_red("The specified cloud: {} does not match the cloud " "specified in the saved state file: {}".format( specified_cloud, cloud)) sys.exit(1) distro = Distribution(saved_state['distro']) region = saved_state['region'] config = _get_platform_config(cloud, region, distro) log_green('Reusing instance from saved state...') instance_factory = _get_cloud_instance_factory(cloud) instance = instance_factory.create_from_saved_state( config, saved_state['state']) log_green('...Done') _setup_fab_for_instance(instance) _save_state_from_instance(instance) specified_distribution = env.config.get('distribution') if (specified_distribution and specified_distribution != instance.distro.value): log_red("The specified distribution: {} does not match the distro " "specified in the saved state file: {}".format( specified_distribution, instance.distro.value)) sys.exit(1) return instance
def get_config(): if not has_state(): raise Exception("Can't get a config without a state file") saved_state = load_state() cloud = saved_state['cloud'] config = parse_config(CLOUD_YAML_FILE[cloud]) return config
def status(): """ returns current status of the instance """ config = get_config() pp = PrettyPrinter(indent=4) pp.pprint(config) if has_state(): state = load_state() pp.pprint(state)