Class: ForemanProxmox::Virtualmachine

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/foreman_proxmox/virtualmachine.rb

Instance Method Summary collapse

Instance Method Details

#create_harddiskObject



5
6
7
8
# File 'app/models/foreman_proxmox/virtualmachine.rb', line 5

def create_harddisk
  proxmoxserver = Proxmoxserver.where("current = 'true'").first
  proxmoxserver.create_ide(self.vmid,self.size)
end

#create_virtualmachineObject



10
11
12
13
# File 'app/models/foreman_proxmox/virtualmachine.rb', line 10

def create_virtualmachine
  proxmoxserver = Proxmoxserver.where("current = 'true'").first
  proxmoxserver.create_kvm(self.vmid,self.sockets,self.cores,self.memory,self.mac)
end

#delete_virtualmachineObject



30
31
32
33
34
35
# File 'app/models/foreman_proxmox/virtualmachine.rb', line 30

def delete_virtualmachine
  proxmoxserver = Proxmoxserver.where("current = 'true'").first
  self.stop
  proxmoxserver.delete_kvm(self.vmid)
  self.destroy
end

#get_free_vmidObject



37
38
39
40
# File 'app/models/foreman_proxmox/virtualmachine.rb', line 37

def get_free_vmid
  proxmoxserver = Proxmoxserver.where("current = 'true'").first
  self.vmid = proxmoxserver.get_next_free_vmid
end

#rebootObject



25
26
27
28
# File 'app/models/foreman_proxmox/virtualmachine.rb', line 25

def reboot
  proxmoxserver = Proxmoxserver.where("current = 'true'").first
  proxmoxserver.reboot_kvm(self.vmid)
end

#startObject



15
16
17
18
# File 'app/models/foreman_proxmox/virtualmachine.rb', line 15

def start
  proxmoxserver = Proxmoxserver.where("current = 'true'").first
  proxmoxserver.start_kvm(self.vmid)
end

#stopObject



20
21
22
23
# File 'app/models/foreman_proxmox/virtualmachine.rb', line 20

def stop
  proxmoxserver = Proxmoxserver.where("current = 'true'").first
  proxmoxserver.stop_kvm(self.vmid)
end