Class: AutoNetwork::PoolStorage

Inherits:
YAML::Store
  • Object
show all
Defined in:
lib/auto_network/pool_storage.rb

Overview

This is a specialized subclass of YAML::Store that manages data persistence for PoolManager instances.

In addition to managing serialization, the YAML::Store parent class also provides facilities for synchronizing state across multiple Vagrant processes. This subclass adds functionality for handling upgrades when the AutoNetwork serialization format changes.

Format history:

  • Version 1: A single instance of Pool instance serialized to YAML. Never formalized with a version number.

  • Version 2: A hash containing a poolfile_version set to 2 and a pools sub-hash with keys created from Vagrant provider names and values of a single Pool instance serialized to YAML.

Examples:

Version 1

--- !ruby/object:AutoNetwork::Pool
# Single serialized AutoNetwork::Pool

Version 2

---
poolfile_version: 2
pools:
  some_vagrant_provider_name: !ruby/object:AutoNetwork::Pool
    # Single serialized AutoNetwork::Pool

Since:

  • 1.0.0

Constant Summary collapse

POOLFILE_VERSION =

An integer indicating the current AutoNetwork serialization format.

Since:

  • 1.0.0

2
POOLFILE_SKELETON =

The data structure that AutoNetwork::PoolManager instances expect to be available in all pool files.

Since:

  • 1.0.0

{
  'poolfile_version' => POOLFILE_VERSION,
  'pools' => {},
}

Class Method Summary collapse

Class Method Details

.init(path) ⇒ void

This method returns an undefined value.

Creates a new pool file at a target location and fills it with default data.

Parameters:

  • path (String, Pathname)

    the location of the new pool file.

See Also:

Since:

  • 1.0.0



53
54
55
56
57
58
59
# File 'lib/auto_network/pool_storage.rb', line 53

def self.init(path)
  path = Pathname.new(path)
  dir = path.dirname

  dir.mkpath unless dir.exist?
  File.write(path, POOLFILE_SKELETON.to_yaml)
end