Class: OpsManager::Appliance::Vsphere
- Includes:
- Logging
- Defined in:
- lib/ops_manager/appliance/vsphere.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
Methods included from Logging
Methods inherited from Base
Constructor Details
This class inherits a constructor from OpsManager::Appliance::Base
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/ops_manager/appliance/vsphere.rb', line 11 def config @config end |
Instance Method Details
#deploy_vm ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/ops_manager/appliance/vsphere.rb', line 13 def deploy_vm print '====> Deploying ova ...'.green vcenter_target= "vi://#{vcenter_username}:#{vcenter_password}@#{config[:opts][:vcenter][:host]}/#{config[:opts][:vcenter][:datacenter]}/host/#{config[:opts][:vcenter][:cluster]}" cmd = "echo yes | ovftool --acceptAllEulas --noSSLVerify --powerOn --X:waitForIp --net:\"Network 1=#{config[:opts][:portgroup]}\" --name=#{vm_name} -ds=#{config[:opts][:datastore]} --prop:ip0=#{config[:ip]} --prop:netmask0=#{config[:opts][:netmask]} --prop:gateway=#{config[:opts][:gateway]} --prop:DNS=#{config[:opts][:dns]} --prop:ntp_servers=#{config[:opts][:ntp_servers].join(',')} --prop:admin_password=#{config[:password]} #{config[:opts][:ova_path]} #{vcenter_target}" logger.info "Running: #{cmd}" logger.info `#{cmd}` puts 'done'.green end |
#stop_current_vm(name) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/ops_manager/appliance/vsphere.rb', line 22 def stop_current_vm(name) print "====> Stopping vm #{name} ...".green dc = vim.serviceInstance.find_datacenter(config[:opts][:vcenter][:datacenter]) logger.info "finding vm: #{name}" vm = dc.find_vm(name) or fail "VM not found" vm.PowerOffVM_Task.wait_for_completion puts 'done'.green end |