Class: PVE::CTTemplate::Base
- Inherits:
-
Object
- Object
- PVE::CTTemplate::Base
- Defined in:
- lib/pve/templates.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #_ipv4(ip, gw) ⇒ Object
- #_ipv6(ip, gw) ⇒ Object
- #arch ⇒ Object
- #cmode ⇒ Object
- #cores ⇒ Object
- #description ⇒ Object
- #hostname ⇒ Object
-
#initialize(**opts) ⇒ Base
constructor
A new instance of Base.
- #memory ⇒ Object
- #name ⇒ Object
- #net0 ⇒ Object
- #net1 ⇒ Object
- #net2 ⇒ Object
- #net3 ⇒ Object
- #node ⇒ Object
- #ostype ⇒ Object
- #ssh_public_keys ⇒ Object
- #swap ⇒ Object
- #unprivileged ⇒ Object
- #vmid ⇒ Object
Constructor Details
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/pve/templates.rb', line 5 def @options end |
Instance Method Details
#_ipv4(ip, gw) ⇒ Object
30 31 32 33 34 |
# File 'lib/pve/templates.rb', line 30 def _ipv4 ip, gw return [ip, nil] if %w[dhcp].include? ip ip = IPAddress::IPv4.new ip [ip.to_string, gw || ip.hosts.last.to_s] end |
#_ipv6(ip, gw) ⇒ Object
36 37 38 39 40 |
# File 'lib/pve/templates.rb', line 36 def _ipv6 ip, gw return [ip, nil] if %w[dhcp auto].include? ip ip = IPAddress::IPv6.new ip [ip.to_string, gw || ip.hosts.last.to_s] end |
#arch ⇒ Object
14 |
# File 'lib/pve/templates.rb', line 14 def arch() .arch || 'amd64' end |
#cmode ⇒ Object
17 |
# File 'lib/pve/templates.rb', line 17 def cmode() .cmode || 'shell' end |
#cores ⇒ Object
18 |
# File 'lib/pve/templates.rb', line 18 def cores() .cores || 1 end |
#description ⇒ Object
19 |
# File 'lib/pve/templates.rb', line 19 def description() .description || '' end |
#hostname ⇒ Object
20 |
# File 'lib/pve/templates.rb', line 20 def hostname() .hostname || name end |
#memory ⇒ Object
21 |
# File 'lib/pve/templates.rb', line 21 def memory() .memory || 1024 end |
#name ⇒ Object
12 |
# File 'lib/pve/templates.rb', line 12 def name() .name end |
#net0 ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pve/templates.rb', line 42 def net0() if .ipv4 || .ipv6 ipv4, gw4 = _ipv4( .ipv4, .gateway4) ipv6, gw6 = _ipv6( .ipv6, .gateway6) { name: 'eth0', bridge: 'vmbr1', ip: ipv4, ip6: ipv6, gw: gw4, gw6: gw6, } end end |
#net1 ⇒ Object
54 |
# File 'lib/pve/templates.rb', line 54 def net1() nil end |
#net2 ⇒ Object
55 |
# File 'lib/pve/templates.rb', line 55 def net2() nil end |
#net3 ⇒ Object
56 |
# File 'lib/pve/templates.rb', line 56 def net3() nil end |
#node ⇒ Object
13 |
# File 'lib/pve/templates.rb', line 13 def node() .node end |
#ostype ⇒ Object
16 |
# File 'lib/pve/templates.rb', line 16 def ostype() .ostype end |
#ssh_public_keys ⇒ Object
25 26 27 28 |
# File 'lib/pve/templates.rb', line 25 def ssh_public_keys [:'ssh-public-keys'] || File.read( [:'ssh-public-keys-file'] || '/root/.ssh/authorized_keys') end |
#swap ⇒ Object
22 |
# File 'lib/pve/templates.rb', line 22 def swap() .swap || 0 end |
#unprivileged ⇒ Object
23 |
# File 'lib/pve/templates.rb', line 23 def unprivileged() .unprivileged() || 1 end |
#vmid ⇒ Object
15 |
# File 'lib/pve/templates.rb', line 15 def vmid() .vmid end |