Sha256: e5748e545178841ccb435c1fe2903886690e2bcdc22da21830817517370b17f9

Contents?: true

Size: 1.38 KB

Versions: 6

Compression:

Stored size: 1.38 KB

Contents

require "micro-cf-plugin/errors"

module CFMicro::Switcher
  class Base

    def initialize(config)
      @config = config

      @vmrun = CFMicro::VMrun.new(config)
    end

    #wrapper methods
    def vmx
      @vmrun.vmx
    end

    def domain
      @vmrun.domain
    end

    def ip
      @vmrun.ip
    end

    def running?
      @vmrun.running?
    end

    def start!
      @vmrun.start!
    end

    def ready?
      @vmrun.ready?
    end

    def offline?
      @vmrun.offline?
    end

    def nat?
      @config['online_connection_type'] ||= @vmrun.connection_type
      @config["online_connection_type"] == "nat"
    end

    def reset_to_nat!
      @vmrun.connection_type = 'nat'
      @vmrun.reset
    end

    def set_host_dns!
      @config['domain'] ||= @vmrun.domain
      @config['ip'] ||= @vmrun.ip
      set_nameserver(@config['domain'], @config['ip'])
    end

    def unset_host_dns!
      @config['domain'] ||= @vmrun.domain
      @config['ip'] ||= @vmrun.ip
      unset_nameserver(@config['domain'], @config['ip'])
    end

    def offline!
      if  @vmrun.offline?
        raise CFMicro::MCFError, "Micro Cloud Foundry VM already in offline mode"
      else
        @vmrun.offline!
      end
    end

    def online!
      if @vmrun.offline?
        @vmrun.online!
      else
        raise CFMirco::MCFError, "Micro Cloud Foundry already in online mode"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
micro-cf-plugin-1.0.0 lib/micro-cf-plugin/micro/switcher/base.rb
micro-cf-plugin-0.1.1.rc1 lib/micro-cf-plugin/micro/switcher/base.rb
micro-cf-plugin-0.1.0 lib/micro-cf-plugin/micro/switcher/base.rb
micro-cf-plugin-0.1.0.rc3 lib/micro-cf-plugin/micro/switcher/base.rb
micro-cf-plugin-0.1.0.rc2 lib/micro-cf-plugin/micro/switcher/base.rb
micro-cf-plugin-0.1.0.rc1 lib/micro-cf-plugin/micro/switcher/base.rb