Class: Mccloud::Provider::Core::Vm

Inherits:
Object
  • Object
show all
Includes:
VmCommand
Defined in:
lib/mccloud/provider/core/vm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from VmCommand

#adjust_rsync_path, #bg_exec, #execute, #fg_exec, #rsync, #rsync_permissions, #share, #share_file, #share_folder, #share_sync, #ssh, #ssh_bootstrap, #ssh_commandline_options, #ssh_forward, #ssh_tunnel_start, #ssh_tunnel_stop, #sudo, #sudo_string, #windows_client?

Constructor Details

#initialize(env) ⇒ Vm

Returns a new instance of Vm.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/mccloud/provider/core/vm.rb', line 58

def initialize(env)
  @env=env
  @forwardings=Array.new
  @shared_folders = Array.new
  @shared_files = Array.new
  @stacked=false
  @auto_selection=true
  @declared=true
  @provisioners=Array.new
  @port=22
  @agent_forwarding=false
  @create_options={}
  @definition=nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



116
117
118
# File 'lib/mccloud/provider/core/vm.rb', line 116

def method_missing(m, *args, &block)
    env.logger.info "There's no keyword #{m} defined for vm #{@name}-- ignoring it"
end

Instance Attribute Details

#agent_forwardingObject

Returns the value of attribute agent_forwarding.



43
44
45
# File 'lib/mccloud/provider/core/vm.rb', line 43

def agent_forwarding
  @agent_forwarding
end

#auto_selectionObject

Returns the value of attribute auto_selection.



45
46
47
# File 'lib/mccloud/provider/core/vm.rb', line 45

def auto_selection
  @auto_selection
end

#bootstrapObject

Returns the value of attribute bootstrap.



47
48
49
# File 'lib/mccloud/provider/core/vm.rb', line 47

def bootstrap
  @bootstrap
end

#bootstrap_passwordObject

Returns the value of attribute bootstrap_password.



49
50
51
# File 'lib/mccloud/provider/core/vm.rb', line 49

def bootstrap_password
  @bootstrap_password
end

#bootstrap_userObject

Returns the value of attribute bootstrap_user.



48
49
50
# File 'lib/mccloud/provider/core/vm.rb', line 48

def bootstrap_user
  @bootstrap_user
end

#create_optionsObject

Returns the value of attribute create_options.



37
38
39
# File 'lib/mccloud/provider/core/vm.rb', line 37

def create_options
  @create_options
end

#declaredObject

Returns the value of attribute declared.



56
57
58
# File 'lib/mccloud/provider/core/vm.rb', line 56

def declared
  @declared
end

#definitionObject

Returns the value of attribute definition.



35
36
37
# File 'lib/mccloud/provider/core/vm.rb', line 35

def definition
  @definition
end

#envObject (readonly)

Returns the value of attribute env.



32
33
34
# File 'lib/mccloud/provider/core/vm.rb', line 32

def env
  @env
end

#forwardingsObject

Returns the value of attribute forwardings.



52
53
54
# File 'lib/mccloud/provider/core/vm.rb', line 52

def forwardings
  @forwardings
end

#nameObject

Returns the value of attribute name.



38
39
40
# File 'lib/mccloud/provider/core/vm.rb', line 38

def name
  @name
end

#portObject

Returns the value of attribute port.



40
41
42
# File 'lib/mccloud/provider/core/vm.rb', line 40

def port
  @port
end

#private_key_pathObject

Returns the value of attribute private_key_path.



41
42
43
# File 'lib/mccloud/provider/core/vm.rb', line 41

def private_key_path
  @private_key_path
end

#providerObject

Returns the value of attribute provider.



34
35
36
# File 'lib/mccloud/provider/core/vm.rb', line 34

def provider
  @provider
end

#provisionersObject

Returns the value of attribute provisioners.



50
51
52
# File 'lib/mccloud/provider/core/vm.rb', line 50

def provisioners
  @provisioners
end

#public_key_pathObject

Returns the value of attribute public_key_path.



42
43
44
# File 'lib/mccloud/provider/core/vm.rb', line 42

def public_key_path
  @public_key_path
end

#shared_filesObject

Returns the value of attribute shared_files.



54
55
56
# File 'lib/mccloud/provider/core/vm.rb', line 54

def shared_files
  @shared_files
end

#shared_foldersObject

Returns the value of attribute shared_folders.



53
54
55
# File 'lib/mccloud/provider/core/vm.rb', line 53

def shared_folders
  @shared_folders
end

#stackedObject

Returns the value of attribute stacked.



55
56
57
# File 'lib/mccloud/provider/core/vm.rb', line 55

def stacked
  @stacked
end

#userObject

Returns the value of attribute user.



39
40
41
# File 'lib/mccloud/provider/core/vm.rb', line 39

def user
  @user
end

Instance Method Details

#auto_selected?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/mccloud/provider/core/vm.rb', line 81

def auto_selected?
  return auto_selection
end

#declared?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/mccloud/provider/core/vm.rb', line 73

def declared?
  return declared
end

#forward_port(name, remote, local) ⇒ Object



111
112
113
114
# File 'lib/mccloud/provider/core/vm.rb', line 111

def forward_port(name,remote,local)
  forwarding=Forwarding.new(name,remote,local)
  forwardings << forwarding
end

#provision(type) ⇒ Object

This function is swapped with the component provision function while reading the configuration



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/mccloud/provider/core/vm.rb', line 95

def provision(type)
  if block_given?
    case type
    when :chef_solo
      @provisioners<< Mccloud::Provisioner::ChefSolo.new(env)
    when :puppet
      @provisioners<<Mccloud::Provisioner::Puppet.new(env)
    when :shell
      @provisioners<<Mccloud::Provisioner::Shell.new(env)

    else
    end
    yield @provisioners.last
  end
end

#provisionerObject



85
86
87
88
89
90
91
# File 'lib/mccloud/provider/core/vm.rb', line 85

def provisioner
  if provisioners.nil?
    return nil
  else
    provisioners.first
  end
end

#stacked?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/mccloud/provider/core/vm.rb', line 77

def stacked?
  return stacked
end