staypuft 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7622052ac4880d6725eb045121b15069d508329
4
- data.tar.gz: 10373f5df0ea8ba8c582766c921699e455229cfc
3
+ metadata.gz: ecedbdd2ea81a9ce7287d7cdbe5382f8ce86e5a3
4
+ data.tar.gz: cb2332dab9ceda616c083f1a2196f13c3a7cf10f
5
5
  SHA512:
6
- metadata.gz: 083822b65880648551e760e55393ba38d70b8de42be1cc751293a8113ab71d3ef1a929590fb9ae0dd3d3131dc933e617d501ae048344d28f4ba8f7d0805885ca
7
- data.tar.gz: b2a914e38b530af822b17604462bc16293ee6107aecbfabb5260cf6a4e97d1f0fa41d2db1e2ecf0bf2ecbac55360e181d2a1fa2d6849178bfc680d8680931961
6
+ metadata.gz: 9418075d837ba35a8be9a79a02e9aa5e5e64a4ed0b8f8c89c7ded7e47f4a61dca4a5c0ced030e14c75fa1cb63758de6ea114f97c86e661647cdc881ca42e933e
7
+ data.tar.gz: f5d1961cfb88f300bd0c932112125a755a7b769f3a0e7911ad0e648b0c5c692bc1cff71a7b80b6bc937df3a0de732481b86dcc51f37b26dfb17463cb754c2c32
@@ -37,33 +37,46 @@ module Staypuft
37
37
  }
38
38
  COUNT = VIP_NAMES.size
39
39
 
40
- def initialize(deployment)
40
+ def initialize(deployment, host=nil)
41
41
  @deployment = deployment
42
+ @host = host
42
43
  end
43
44
 
44
- def ip_for_host(host, subnet_type_name)
45
- interface_hash_for_host(host, subnet_type_name)[:ip]
45
+ def ip_for_host(subnet_type_name, host=@host)
46
+ interface_hash_for_host(subnet_type_name, host)[:ip]
46
47
  end
47
48
 
48
- def interface_for_host(host, subnet_type_name)
49
- interface_hash_for_host(host, subnet_type_name)[:interface]
49
+ def interface_for_host(subnet_type_name, host=@host)
50
+ interface_hash_for_host(subnet_type_name, host)[:interface]
50
51
  end
51
52
 
52
- def network_address_for_host(host, subnet_type_name)
53
- subnet = interface_hash_for_host(host, subnet_type_name)[:subnet]
53
+ def network_address_for_host(subnet_type_name, host=@host)
54
+ subnet = subnet_for_host(subnet_type_name, host)
54
55
  subnet.network_address if subnet
55
56
  end
56
57
 
58
+ def subnet_for_host(subnet_type_name, host=@host)
59
+ interface_hash_for_host(subnet_type_name, host)[:subnet]
60
+ end
61
+
62
+ def gateway_subnet(host=@host)
63
+ gateway_hash_for_host(host)[:subnet]
64
+ end
65
+
66
+ def gateway_interface(host=@host)
67
+ gateway_hash_for_host(host)[:interface]
68
+ end
69
+
57
70
  def controllers
58
71
  @controllers ||= @deployment.controller_hostgroup.hosts.order(:id)
59
72
  end
60
73
 
61
74
  def controller_ips(subnet_type_name)
62
- controllers.map { |controller| ip_for_host(controller, subnet_type_name) }
75
+ controllers.map { |controller| ip_for_host(subnet_type_name, controller) }
63
76
  end
64
77
 
65
78
  def controller_ip(subnet_type_name)
66
- ip_for_host(controllers.tap { |v| v.size == 1 or raise('only one controller is allowed') }.first, subnet_type_name)
79
+ ip_for_host(subnet_type_name, controllers.tap { |v| v.size == 1 or raise('only one controller is allowed') }.first)
67
80
  end
68
81
 
69
82
  def controller_fqdns
@@ -87,11 +100,12 @@ module Staypuft
87
100
 
88
101
  class Jail < Safemode::Jail
89
102
  allow :ip_for_host, :interface_for_host, :network_address_for_host,
90
- :controller_ip, :controller_ips, :controller_fqdns, :get_vip
103
+ :controller_ip, :controller_ips, :controller_fqdns, :get_vip,
104
+ :subnet_for_host, :gateway_subnet, :gateway_interface
91
105
  end
92
106
 
93
107
  private
94
- def interface_hash_for_host(host, subnet_type_name)
108
+ def interface_hash_for_host(subnet_type_name, host)
95
109
  if host.nil?
96
110
  raise ArgumentError, "no host specified"
97
111
  end
@@ -120,5 +134,11 @@ module Staypuft
120
134
  {}
121
135
  end
122
136
  end
137
+
138
+ def gateway_hash_for_host(host)
139
+ gateway_hash = interface_hash_for_host(Staypuft::SubnetType::PUBLIC_API, host)
140
+ gateway_hash = interface_hash_for_host(Staypuft::SubnetType::PXE, host) unless gateway_hash[:subnet]
141
+ gateway_hash
142
+ end
123
143
  end
124
144
  end
@@ -209,7 +209,7 @@ module Staypuft
209
209
 
210
210
  # virtual ip addresses
211
211
  def vip_format(param_name)
212
- { :string => '<%%= @host.deployment.network_query.get_vip(:%s) %%>' % param_name }
212
+ { :string => '<%%= @host.network_query.get_vip(:%s) %%>' % param_name }
213
213
  end
214
214
 
215
215
  def functional_dependencies
@@ -224,8 +224,8 @@ module Staypuft
224
224
  network_num_networks = { :string => '<%= @host.deployment.nova.num_networks %>' }
225
225
  network_fixed_range = { :string => '<%= @host.deployment.nova.private_fixed_range %>' }
226
226
  network_floating_range = { :string => '<%= @host.deployment.nova.public_floating_range %>' }
227
- network_private_iface = { :string => "<%= @host.deployment.network_query.interface_for_host(@host, '#{Staypuft::SubnetType::TENANT}') %>" }
228
- network_public_iface = { :string => "<%= @host.deployment.network_query.interface_for_host(@host, '#{Staypuft::SubnetType::EXTERNAL}') %>" }
227
+ network_private_iface = { :string => "<%= @host.network_query.interface_for_host('#{Staypuft::SubnetType::TENANT}') %>" }
228
+ network_public_iface = { :string => "<%= @host.network_query.interface_for_host('#{Staypuft::SubnetType::EXTERNAL}') %>" }
229
229
  network_create_networks = true
230
230
 
231
231
  # Neutron
@@ -295,15 +295,15 @@ module Staypuft
295
295
  keystonerc = 'true'
296
296
 
297
297
  # Ceph
298
- ceph_cluster_network = { :string => "<%= @host.deployment.network_query.network_address_for_host(@host, '#{Staypuft::SubnetType::STORAGE_CLUSTERING}') %>" }
298
+ ceph_cluster_network = { :string => "<%= @host.network_query.network_address_for_host('#{Staypuft::SubnetType::STORAGE_CLUSTERING}') %>" }
299
299
  # FIXME: this should actually be STORAGE instead of PXE, but only after we have a reliable way of identifying DNS names
300
300
  # on the storage network
301
- ceph_public_network = { :string => "<%= @host.deployment.network_query.network_address_for_host(@host, '#{Staypuft::SubnetType::PXE}') %>" }
301
+ ceph_public_network = { :string => "<%= @host.network_query.network_address_for_host('#{Staypuft::SubnetType::PXE}') %>" }
302
302
  ceph_fsid = { :string => '<%= @host.deployment.ceph.fsid %>' }
303
303
  ceph_images_key = { :string => '<%= @host.deployment.ceph.images_key %>' }
304
304
  ceph_volumes_key = { :string => '<%= @host.deployment.ceph.volumes_key %>' }
305
305
  # FIXME: this should move to STORAGE from PXE like above
306
- ceph_mon_host = { :array => "<%= @host.deployment.network_query.controller_ips('#{Staypuft::SubnetType::PXE}') %>" }
306
+ ceph_mon_host = { :array => "<%= @host.network_query.controller_ips('#{Staypuft::SubnetType::PXE}') %>" }
307
307
  # FIXME: This is currently the hostnames (which maps to fqdns on the PXE network) -- eventually we want DNS names
308
308
  # on the Storage network
309
309
  ceph_mon_initial_members = { :array => "<%= @host.deployment.ceph.mon_initial_members %>" }
@@ -340,7 +340,7 @@ module Staypuft
340
340
  neutron_metadata_proxy_secret = { :string => '<%= @host.deployment.passwords.neutron_metadata_proxy_secret %>' }
341
341
 
342
342
 
343
- private_ip = { :string => "<%= @host.deployment.network_query.ip_for_host(@host, '#{Staypuft::SubnetType::MANAGEMENT}') %>" }
343
+ private_ip = { :string => "<%= @host.deployment.network_query.ip_for_host('#{Staypuft::SubnetType::MANAGEMENT}', @host) %>" }
344
344
  # private API/management
345
345
  amqp_host = get_host_format :amqp_vip, Staypuft::SubnetType::MANAGEMENT
346
346
  mysql_host = get_host_format :db_vip, Staypuft::SubnetType::MANAGEMENT
@@ -355,7 +355,7 @@ module Staypuft
355
355
  controller_priv_host = { :string => "<%= d = @host.deployment; d.ha? ? nil : d.network_query.controller_ip('#{Staypuft::SubnetType::MANAGEMENT}') %>"}
356
356
  controller_pub_host = { :string => "<%= d = @host.deployment; d.ha? ? nil : d.network_query.controller_ip('#{Staypuft::SubnetType::PUBLIC_API}') %>"}
357
357
 
358
- fencing_type = { :string => '<%= @host.bmc_nic.attrs["fencing_type"] if @host.bmc_nic && @host.bmc_nic.fencing_enabled? %>' }
358
+ fencing_type = { :string => '<%= (@host.bmc_nic && @host.bmc_nic.fencing_enabled?) ? @host.bmc_nic.attrs["fencing_type"] : "disabled" %>' }
359
359
  fence_ipmilan_address = { :string => '<%= @host.bmc_nic.ip if @host.bmc_nic && @host.bmc_nic.fencing_enabled? %>' }
360
360
  fence_ipmilan_username = { :string => '<%= @host.bmc_nic.username if @host.bmc_nic && @host.bmc_nic.fencing_enabled? %>' }
361
361
  fence_ipmilan_password = { :string => '<%= @host.bmc_nic.password if @host.bmc_nic && @host.bmc_nic.fencing_enabled? %>' }
@@ -46,6 +46,15 @@ module Staypuft
46
46
  n += 1
47
47
  end
48
48
  end
49
+
50
+ def network_query
51
+ @network_query || NetworkQuery.new(self.hostgroup.deployment, self)
52
+ end
53
+
49
54
  end
50
55
  end
51
56
  end
57
+
58
+ class ::Host::Managed::Jail < Safemode::Jail
59
+ allow :network_query
60
+ end
@@ -91,11 +91,11 @@ module Staypuft
91
91
  end
92
92
 
93
93
  def tenant_iface(host)
94
- deployment.network_query.interface_for_host(host, Staypuft::SubnetType::TENANT)
94
+ deployment.network_query.interface_for_host(Staypuft::SubnetType::TENANT, host)
95
95
  end
96
96
 
97
97
  def external_interface_name(host)
98
- deployment.network_query.interface_for_host(host, Staypuft::SubnetType::EXTERNAL)
98
+ deployment.network_query.interface_for_host(Staypuft::SubnetType::EXTERNAL, host)
99
99
  end
100
100
 
101
101
  def ovs_tunnel_types
@@ -1,3 +1,3 @@
1
1
  module Staypuft
2
- VERSION = '0.3.6'
2
+ VERSION = '0.3.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staypuft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Staypuft team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2014-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman-tasks