Module: GridscaleImagesHelper

Defined in:
app/helpers/gridscale_images_helper.rb

Instance Method Summary collapse

Instance Method Details

#gridscale_image_field(f) ⇒ Object



138
139
140
141
142
143
# File 'app/helpers/gridscale_images_helper.rb', line 138

def gridscale_image_field(f)
  images = @compute_resource.available_templates
  images.each { |image| image.name = image.object_uuid if image.name.nil? }
  select_f f, :object_uuid, images.to_a,
           :object_uuid, :name, {}, :label => _('Image')
end

#gridscale_server_field(f) ⇒ Object



2
3
4
5
6
7
# File 'app/helpers/gridscale_images_helper.rb', line 2

def gridscale_server_field(f)
  images = @compute_resource.available_servers
  images.each { |image| image.name = image.id if image.name.nil? }
  select_f f, :uuid, images.to_a.sort_by(&:full_name),
           :id, :full_name, {}, :label => _('Image')
end

#select_ipv4(f, compute_resource) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/gridscale_images_helper.rb', line 9

def select_ipv4(f, compute_resource)
  addresses = Array.new
  compute_resource.ips.each do |ip|
     if ip.relations['servers'].empty? and ip.relations['loadbalancers'].empty? and ip.family ==4 and ip.failover == false
       addresses << ip
     end
   end
  if addresses.empty?
    "No IPs available"
  else
    select_f(f,
             :ipv4_uuid,
             addresses,
             :object_uuid,
             :ip,
             { :include_blank => true },
             { :label => 'IP Address 4'})
  end
end

#select_ipv6(f, compute_resource) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/helpers/gridscale_images_helper.rb', line 29

def select_ipv6(f, compute_resource)
  addresses = Array.new
  compute_resource.ips.each do |ip|
    if ip.relations['servers'].empty? and ip.relations['loadbalancers'].empty? and ip.family ==6 and ip.failover == false
      addresses << ip
    end
  end
  if addresses.empty?
    "No IPs available"
  else
    select_f(f,
             :ipv6_uuid,
             addresses,
             :object_uuid,
             :ip,
             { :include_blank => true },
             { :label => 'IP Address 6'})
  end
end

#select_isoimage(f, compute_resource) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'app/helpers/gridscale_images_helper.rb', line 122

def select_isoimage(f, compute_resource)
  template_list = Array.new
  compute_resource.isoimages.each do |isoimage|
    template_list << isoimage
  end

  select_f(f,
           :isoimage_uuid,
           template_list,
           :object_uuid,
           :name,
           { :include_blank => true },
           { :label => 'Iso-image'})

end

#select_network(f, compute_resource) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/helpers/gridscale_images_helper.rb', line 49

def select_network(f, compute_resource)
  networks_list = Array.new
  compute_resource.networks.each do |network|
    networks_list << network
  end

  select_f(f,
           :network_uuid,
           networks_list,
           :object_uuid,
           :name,
           { :include_blank => true },
           { :label => 'Network'})

end

#select_sshkey(f, compute_resource) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'app/helpers/gridscale_images_helper.rb', line 106

def select_sshkey(f, compute_resource)
  template_list = Array.new
  compute_resource.sshkeys.each do |template|
    template_list << template
  end

  select_f(f,
           :sshkey_uuid,
           template_list,
           :object_uuid,
           :name,
           { :include_blank => true },
           { :label => 'SSH Key'})

end

#select_storage(f, compute_resource) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'app/helpers/gridscale_images_helper.rb', line 67

def select_storage(f, compute_resource)

  storages_list = Array.new

  compute_resource.storages.each do |storage|
    if storage.relations['servers'].empty?
      storages_list << storage
    end
  end

  if storages_list.empty?
    "No storage available"
  else
    select_f(f,
             :storage_uuid,
             storages_list,
             :object_uuid,
             :name,
             { :include_blank => true },
             { :label => 'available storage'})
  end
end

#select_template(f, compute_resource) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'app/helpers/gridscale_images_helper.rb', line 90

def select_template(f, compute_resource)
  template_list = Array.new
  compute_resource.templates.each do |template|
    template_list << template
  end

  select_f(f,
           :template_uuid,
           template_list,
           :object_uuid,
           :name,
           { :include_blank => true },
           { :label => 'Template'})

end