Module: Staypuft::DeploymentsHelper

Defined in:
app/helpers/staypuft/deployments_helper.rb

Instance Method Summary collapse

Instance Method Details

#alert_if_deployedObject



17
18
19
20
21
22
23
24
# File 'app/helpers/staypuft/deployments_helper.rb', line 17

def alert_if_deployed
  if @deployment.deployed?
    (alert :class => 'alert-warning',
           :text  => _('Machines are already deployed with this configuration. Changing the configuration parameters ' +
                           'is unsupported and may result in an unusable configuration. <br/>Please proceed with caution.'),
           :close => false).html_safe
  end
end

#deployment_wizard(step) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'app/helpers/staypuft/deployments_helper.rb', line 3

def deployment_wizard(step)
  wizard_header(
      step,
      _("Deployment Settings"),
      _("Network Configuration"),
      _("Services Overview"),
      _("Services Configuration")
  )
end

#host_disks(host) ⇒ Object



55
56
57
58
59
60
61
62
# File 'app/helpers/staypuft/deployments_helper.rb', line 55

def host_disks(host)
  hosts_facts = FactValue.joins(:fact_name).where(host_id: host.id)
  host.blockdevices.collect do |blockdevice|
    disk_size = hosts_facts.
        where(fact_names: { name: 'blockdevice_#{blockdevice}_size'}).first.try(:value)
    "#{blockdevice}: #{disk_size or 'Unknown'}"
  end.join(tag(:br)).html_safe
end

#host_label(host) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/helpers/staypuft/deployments_helper.rb', line 26

def host_label(host)
  case host
  when Host::Managed
    style ="label-info"
    short = s_("Managed|M")
    label = _('Known Host')
    path  = hash_for_host_path(host)
  when Host::Discovered
    style           ="label-default"
    short           = s_("Discovered|D")
    label           = _('Discovered Host')
    path            = hash_for_discovered_host_path(host)
  else
    style = 'label-warning'
    short = s_("Error|E")
    path  = '#'
    label = _('Unknown Host')
  end

  (:span, short,
              { :rel                   => "twipsy",
                :class                 => "label label-light " + style,
                :"data-original-title" => _(label) }) + link_to(trunc("  #{host}", 32), path)
end

#host_nics(host) ⇒ Object



51
52
53
# File 'app/helpers/staypuft/deployments_helper.rb', line 51

def host_nics(host)
  host.interfaces_identifiers.compact.sort.join(tag(:br)).html_safe
end

#is_newObject



13
14
15
# File 'app/helpers/staypuft/deployments_helper.rb', line 13

def is_new
  @deployment.name.empty?
end

#is_pxe?(deployment, subnet) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'app/helpers/staypuft/deployments_helper.rb', line 64

def is_pxe?(deployment, subnet)
  subnet_typings(deployment, subnet).any? { |t| t.subnet_type.name == Staypuft::SubnetType::PXE }
end

#subnet_types(deployment, subnet) ⇒ Object



68
69
70
# File 'app/helpers/staypuft/deployments_helper.rb', line 68

def subnet_types(deployment, subnet)
  subnet_typings(deployment, subnet).map { |t| h(t.subnet_type.name) }.join(' + ')
end

#subnet_typings(deployment, subnet) ⇒ Object



72
73
74
# File 'app/helpers/staypuft/deployments_helper.rb', line 72

def subnet_typings(deployment, subnet)
  deployment.subnet_typings.where(:subnet_id => subnet.id).includes(:subnet_type)
end