Class: JDCMicro::Switcher::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/micro/switcher/base.rb

Direct Known Subclasses

Darwin, Dummy, Linux, Windows

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
# File 'lib/micro/switcher/base.rb', line 6

def initialize(config)
  @config = config

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

Instance Method Details

#domainObject



17
18
19
# File 'lib/micro/switcher/base.rb', line 17

def domain
  @vmrun.domain
end

#ipObject



21
22
23
# File 'lib/micro/switcher/base.rb', line 21

def ip
  @vmrun.ip
end

#nat?Boolean

Returns:

  • (Boolean)


41
42
43
44
# File 'lib/micro/switcher/base.rb', line 41

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

#offline!Object



63
64
65
66
67
68
69
# File 'lib/micro/switcher/base.rb', line 63

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

#offline?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/micro/switcher/base.rb', line 37

def offline?
  @vmrun.offline?
end

#online!Object



71
72
73
74
75
76
77
# File 'lib/micro/switcher/base.rb', line 71

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

#ready?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/micro/switcher/base.rb', line 33

def ready?
  @vmrun.ready?
end

#reset_to_nat!Object



46
47
48
49
# File 'lib/micro/switcher/base.rb', line 46

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

#running?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/micro/switcher/base.rb', line 25

def running?
  @vmrun.running?
end

#set_host_dns!Object



51
52
53
54
55
# File 'lib/micro/switcher/base.rb', line 51

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

#start!Object



29
30
31
# File 'lib/micro/switcher/base.rb', line 29

def start!
  @vmrun.start!
end

#unset_host_dns!Object



57
58
59
60
61
# File 'lib/micro/switcher/base.rb', line 57

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

#vmxObject

wrapper methods



13
14
15
# File 'lib/micro/switcher/base.rb', line 13

def vmx
  @vmrun.vmx
end