Sha256: 70696dc1b0e19ae5751c63b2cf38bf6393adf490cd2b495c037211a0282dfc6c

Contents?: true

Size: 801 Bytes

Versions: 2

Compression:

Stored size: 801 Bytes

Contents

module ConfCtl
  class Generation::Host
    attr_reader :host, :profile, :id, :toplevel, :date, :current

    # @param host [String]
    # @param profile [String]
    # @param id [Integer]
    # @param toplevel [String]
    # @param date [Time]
    # @param mc [MachineControl]
    def initialize(host, profile, id, toplevel, date, current: false, mc: nil)
      @host = host
      @profile = profile
      @id = id
      @toplevel = toplevel
      @date = date
      @current = current
      @mc = mc
    end

    def approx_name
      @approx_name ||= date.strftime('%Y-%m-%d--%H-%M-%S')
    end

    def destroy
      raise 'machine control not available' if mc.nil?

      mc.execute('nix-env', '-p', profile, '--delete-generations', id.to_s)
    end

    protected

    attr_reader :mc
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
confctl-2.0.0 lib/confctl/generation/host.rb
confctl-1.0.0 lib/confctl/generation/host.rb