staypuft 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/app/assets/javascripts/staypuft/nics_assignment.js +35 -0
- data/app/assets/javascripts/staypuft/staypuft.js +4 -0
- data/app/assets/javascripts/staypuft/subnets_assignment.js +33 -3
- data/app/assets/stylesheets/staypuft/staypuft.css.scss +31 -0
- data/app/controllers/staypuft/bonds_controller.rb +131 -0
- data/app/controllers/staypuft/interface_assignments_controller.rb +7 -2
- data/app/controllers/staypuft/steps_controller.rb +1 -1
- data/app/controllers/staypuft/subnet_typings_controller.rb +45 -3
- data/app/lib/staypuft/seeder.rb +57 -27
- data/app/models/staypuft/deployment/glance_service.rb +1 -1
- data/app/models/staypuft/deployment/neutron_service.rb +1 -1
- data/app/models/staypuft/deployment.rb +4 -0
- data/app/models/staypuft/interface_assigner.rb +42 -22
- data/app/models/staypuft/subnet_type.rb +1 -0
- data/app/views/staypuft/bonds/add_slave.js.erb +10 -0
- data/app/views/staypuft/bonds/create.js.erb +10 -0
- data/app/views/staypuft/bonds/destroy.js.erb +10 -0
- data/app/views/staypuft/deployments/_assigned_hosts.html.erb +17 -17
- data/app/views/staypuft/interface_assignments/_interfaces.html.erb +31 -0
- data/app/views/staypuft/interface_assignments/_nics_assignment.html.erb +29 -0
- data/app/views/staypuft/interface_assignments/index.html.erb +42 -69
- data/app/views/staypuft/interfaces/_drop_zone.html.erb +72 -3
- data/app/views/staypuft/steps/_glance.html.erb +3 -3
- data/app/views/staypuft/steps/_neutron.html.erb +1 -1
- data/app/views/staypuft/steps/deployment_settings.html.erb +2 -2
- data/app/views/staypuft/steps/services_configuration.html.erb +1 -1
- data/app/views/staypuft/subnet_typings/create.js.erb +3 -0
- data/app/views/staypuft/subnet_typings/destroy.js.erb +3 -0
- data/app/views/staypuft/subnet_typings/update.js.erb +3 -0
- data/config/routes.rb +8 -0
- data/db/migrate/20141003223000_add_validation_to_subnet_types.rb +7 -0
- data/lib/staypuft/version.rb +1 -1
- metadata +143 -136
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YzAyMWVlODdjMzI2ZDE0YzM0ZmM3ODcwNjI5YjZhYmE0NTg5ZGU1ZA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a03caebb78c982156156e14071fb90cef35627dd
|
4
|
+
data.tar.gz: 96d1b6b7f38b74f6b081d1e061b7a9d7e5dbab89
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MDlhZDM0MzM0NTlkOTg3NTFhYzBjNTlmMzhmNGJjNzE5NjZiNjY1OTkyODg0
|
11
|
-
YzljZjM1ZjQ3NDVkYjU3OWEzMzMwN2FkYzcxZmM1NjI1OGEzNTg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjljNjI4NWMxM2ZjMGIxNGM4ZDI1YmU1N2U1M2QwZWY4NmUyZjNjZGFhYWZj
|
14
|
-
ZDdmZjFkMmIxNTIwNWFlMmFjNWRhY2U0NTlmYzJjZmNiYzFkODlkYWRiYmI4
|
15
|
-
ZDgzMDk0ODFkOTdhNDNjOGM5YzMwZmZhYzFiMGM1NWNjYWM1MjE=
|
6
|
+
metadata.gz: 213f86077425ac3969d84c220fce82fe6bc941234ea136e8332d594c9bc93c58e440ba919c7be841ae2e4848c598eb4c9c00cd64076471440331ad6d0fed392f
|
7
|
+
data.tar.gz: 114c5a5a5ad09fc049bb8c6504265a8da3a05717acfb6b7fe232b83a4c023b491bc10f3c78e16349fc50372dd1732535a6f6bc267fc507e072fca1890979825e
|
@@ -44,4 +44,39 @@ var nics_assignment = (function() {
|
|
44
44
|
});
|
45
45
|
}
|
46
46
|
});
|
47
|
+
|
48
|
+
$('#hosts_to_configure').on('show.bs.collapse', function() {
|
49
|
+
$(this).prev('h3[data-toggle="collapse"]').addClass('active');
|
50
|
+
});
|
51
|
+
$('#hosts_to_configure').on('hide.bs.collapse', function() {
|
52
|
+
$(this).prev('h3[data-toggle="collapse"]').removeClass('active');
|
53
|
+
});
|
54
|
+
|
55
|
+
$('.panel-heading > #bonding_mode > ul > li').on('click', function(event) {
|
56
|
+
var dropdown = $($(event.target).parents('ul')[0]).prev();
|
57
|
+
dropdown.prop('disabled', true);
|
58
|
+
|
59
|
+
var to_assign = $('input:checkbox[name=host_ids[]]:checked').map(
|
60
|
+
function() {
|
61
|
+
return $(this).attr('value');
|
62
|
+
}).get().join();
|
63
|
+
/* remove the first if it's the select all */
|
64
|
+
if(to_assign.substr(0, 2) == 'on') {
|
65
|
+
to_assign = to_assign.substr(3);
|
66
|
+
}
|
67
|
+
|
68
|
+
var to_path = $('#bonding_mode').data('path');
|
69
|
+
$.ajax({
|
70
|
+
url: to_path,
|
71
|
+
type: 'PUT',
|
72
|
+
data: {
|
73
|
+
mode: $(event.target).text(),
|
74
|
+
host_ids: to_assign
|
75
|
+
},
|
76
|
+
success: function(data) {
|
77
|
+
dropdown.text($(event.target).text());
|
78
|
+
dropdown.prop('disabled', false);
|
79
|
+
}
|
80
|
+
});
|
81
|
+
});
|
47
82
|
});
|
@@ -93,7 +93,9 @@ $(function () {
|
|
93
93
|
showNeutronVlanRange();
|
94
94
|
$("input[name='staypuft_deployment[neutron][network_segmentation]']").change(showNeutronVlanRange);
|
95
95
|
function showNeutronVlanRange() {
|
96
|
+
$('#staypuft_deployment_neutron_network_segmentation_vlan').parent().parent().parent().removeClass('col-md-4').addClass('col-md-6')
|
96
97
|
if ($('#staypuft_deployment_neutron_network_segmentation_vlan').is(":checked")) {
|
98
|
+
$('#staypuft_deployment_neutron_network_segmentation_vlan').parent().after($('.neutron_tenant_vlan_ranges'));
|
97
99
|
$('.neutron_tenant_vlan_ranges').fadeIn(duration);
|
98
100
|
}
|
99
101
|
else {
|
@@ -115,7 +117,9 @@ $(function () {
|
|
115
117
|
showGlanceNfsNetworkPath();
|
116
118
|
$("input[name='staypuft_deployment[glance][driver_backend]']").change(showGlanceNfsNetworkPath);
|
117
119
|
function showGlanceNfsNetworkPath() {
|
120
|
+
$('#staypuft_deployment_glance_driver_backend_nfs').parent().parent().parent().removeClass('col-md-4').addClass('col-md-6')
|
118
121
|
if ($('#staypuft_deployment_glance_driver_backend_nfs').is(":checked")) {
|
122
|
+
$('#staypuft_deployment_glance_driver_backend_nfs').parent().after($('.glance_nfs_network_path'));
|
119
123
|
$('.glance_nfs_network_path').show();
|
120
124
|
}
|
121
125
|
else {
|
@@ -2,6 +2,12 @@ $(function() {
|
|
2
2
|
$("div.subnet-type-pull").draggable({
|
3
3
|
revert: 'invalid'
|
4
4
|
});
|
5
|
+
|
6
|
+
$("div.subnet-type-pull").live('dragstart', function( event, ui ) {
|
7
|
+
dropped = $(this);
|
8
|
+
dropped.data.left = ui.originalPosition.left;
|
9
|
+
dropped.data.top = ui.originalPosition.top;
|
10
|
+
});
|
5
11
|
|
6
12
|
$("div.subnet-drop-zone").droppable({
|
7
13
|
activeClass: "panel-droppable",
|
@@ -13,14 +19,30 @@ $(function() {
|
|
13
19
|
type: 'POST',
|
14
20
|
url: ui.draggable.data('create-url'),
|
15
21
|
data: 'subnet_type_id=' + ui.draggable.data('subnet-type-id') + '&subnet_id=' + $(this).data('subnet-id'),
|
16
|
-
dataType: 'script'
|
22
|
+
dataType: 'script',
|
23
|
+
success: function(data, event){
|
24
|
+
if(data.indexOf("error =") > -1){
|
25
|
+
dropped.animate({
|
26
|
+
left: dropped.data.left,
|
27
|
+
top: dropped.data.top
|
28
|
+
}, 1000, 'swing');
|
29
|
+
}
|
30
|
+
}
|
17
31
|
})
|
18
32
|
} else {
|
19
33
|
$.ajax({
|
20
34
|
type: 'PUT',
|
21
35
|
url: ui.draggable.data('update-url'),
|
22
36
|
data: 'subnet_id=' + $(this).data('subnet-id'),
|
23
|
-
dataType: 'script'
|
37
|
+
dataType: 'script',
|
38
|
+
success: function(data, event){
|
39
|
+
if(data.indexOf("error =") > -1){
|
40
|
+
dropped.animate({
|
41
|
+
left: dropped.data.left,
|
42
|
+
top: dropped.data.top
|
43
|
+
}, 1000, 'swing');
|
44
|
+
}
|
45
|
+
}
|
24
46
|
})
|
25
47
|
}
|
26
48
|
}
|
@@ -34,7 +56,15 @@ $(function() {
|
|
34
56
|
$.ajax({
|
35
57
|
type: 'DELETE',
|
36
58
|
url: ui.draggable.data('delete-url'),
|
37
|
-
dataType: 'script'
|
59
|
+
dataType: 'script',
|
60
|
+
success: function(data, event){
|
61
|
+
if(data.indexOf("error =") > -1){
|
62
|
+
dropped.animate({
|
63
|
+
left: dropped.data.left,
|
64
|
+
top: dropped.data.top
|
65
|
+
}, 1000, 'swing');
|
66
|
+
}
|
67
|
+
}
|
38
68
|
});
|
39
69
|
}
|
40
70
|
});
|
@@ -172,3 +172,34 @@ span.editable, span.editable:hover {
|
|
172
172
|
overflow-y: auto;
|
173
173
|
}
|
174
174
|
}
|
175
|
+
|
176
|
+
h3[data-toggle="collapse"] {
|
177
|
+
cursor: pointer;
|
178
|
+
span.glyphicon:before {
|
179
|
+
transition: all .3s ease 0s;
|
180
|
+
display: inline-block;
|
181
|
+
}
|
182
|
+
&.active span.glyphicon:before {
|
183
|
+
color: $brand-primary;
|
184
|
+
-ms-transform: rotate(180deg); /* IE 9 */
|
185
|
+
-webkit-transform: rotate(180deg); /* Chrome, Safari, Opera */
|
186
|
+
transform: rotate(180deg);
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
.inset_form {
|
191
|
+
font-size: 85%;
|
192
|
+
.form-group {
|
193
|
+
margin-bottom: 0;
|
194
|
+
.control-label {
|
195
|
+
text-align: left;
|
196
|
+
}
|
197
|
+
.help-block {
|
198
|
+
margin-bottom: 0;
|
199
|
+
}
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
.single_password.inset_form {
|
204
|
+
margin-left: 192px;
|
205
|
+
}
|
@@ -0,0 +1,131 @@
|
|
1
|
+
module Staypuft
|
2
|
+
class BondsController < Staypuft::ApplicationController
|
3
|
+
before_filter :find_hosts
|
4
|
+
before_filter :find_bonds, :only => %w(destroy add_slave remove_slave change_mode)
|
5
|
+
|
6
|
+
def create
|
7
|
+
@bonds = []
|
8
|
+
@hosts.each do |host|
|
9
|
+
|
10
|
+
existing = host.interfaces.select { |i| i.is_a?(Nic::Bond) }.map(&:identifier)
|
11
|
+
i = 0
|
12
|
+
while existing.include?("bond#{i}") do
|
13
|
+
i +=1
|
14
|
+
end
|
15
|
+
|
16
|
+
bond = Nic::Bond.new
|
17
|
+
bond.identifier = "bond#{i}"
|
18
|
+
params[:interfaces].each do |interface|
|
19
|
+
bond.add_slave(interface)
|
20
|
+
end
|
21
|
+
bond.mode = 'balance-tlb'
|
22
|
+
bond.bond_options = 'miimon=100'
|
23
|
+
bond.host = host
|
24
|
+
@bonds.push bond
|
25
|
+
end
|
26
|
+
|
27
|
+
ActiveRecord::Base.transaction do
|
28
|
+
results = @bonds.map(&:save)
|
29
|
+
@result = results.all?
|
30
|
+
clear_nic_assignments(params[:interfaces])
|
31
|
+
raise ActiveRecord::Rollback unless @result
|
32
|
+
end
|
33
|
+
|
34
|
+
find_unassigned_subnets
|
35
|
+
end
|
36
|
+
|
37
|
+
def destroy
|
38
|
+
ActiveRecord::Base.transaction do
|
39
|
+
clear_nic_assignments([params[:id]])
|
40
|
+
results = @bonds.map(&:destroy)
|
41
|
+
@result = results.all?
|
42
|
+
raise ActiveRecord::Rollback unless @result
|
43
|
+
end
|
44
|
+
|
45
|
+
find_unassigned_subnets
|
46
|
+
end
|
47
|
+
|
48
|
+
def add_slave
|
49
|
+
@bonds.each { |bond| bond.add_slave(params[:interface]) }
|
50
|
+
|
51
|
+
ActiveRecord::Base.transaction do
|
52
|
+
results = @bonds.map(&:save)
|
53
|
+
@result = results.all?
|
54
|
+
clear_nic_assignments([params[:interface]])
|
55
|
+
raise ActiveRecord::Rollback unless @result
|
56
|
+
end
|
57
|
+
|
58
|
+
find_unassigned_subnets
|
59
|
+
end
|
60
|
+
|
61
|
+
def change_mode
|
62
|
+
@bonds.each { |bond| bond.mode = params[:mode] }
|
63
|
+
|
64
|
+
ActiveRecord::Base.transaction do
|
65
|
+
results = @bonds.map(&:save)
|
66
|
+
@result = results.all?
|
67
|
+
raise ActiveRecord::Rollback unless @result
|
68
|
+
end
|
69
|
+
|
70
|
+
render :nothing => true
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def remove_slave
|
75
|
+
@bonds.each { |bond| bond.remove_slave(params[:interface]) }
|
76
|
+
|
77
|
+
ActiveRecord::Base.transaction do
|
78
|
+
results = @bonds.map(&:save)
|
79
|
+
@result = results.all?
|
80
|
+
clear_nic_assignments(params[:interfaces])
|
81
|
+
raise ActiveRecord::Rollback unless @result
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def find_bonds
|
88
|
+
@bonds = @hosts.map do |host|
|
89
|
+
host.interfaces.detect { |i| i.identifier == params[:id] }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def find_hosts
|
94
|
+
@hosts = Host::Managed.where(:id => params[:host_ids]).includes(:interfaces)
|
95
|
+
@host = @hosts.first
|
96
|
+
@interfaces = @host.interfaces.where("type <> 'Nic::BMC'").non_vip.order(:identifier).where(['(virtual = ? OR type = ?)', false, 'Nic::Bond'])
|
97
|
+
@deployment = Deployment.find(params[:deployment_id])
|
98
|
+
end
|
99
|
+
|
100
|
+
def find_unassigned_subnets
|
101
|
+
assigned_subnet_ids = ([@host.subnet_id] + @host.interfaces.non_vip.map(&:subnet_id)).compact.uniq
|
102
|
+
@subnets = @deployment.subnets.where(["#{Subnet.table_name}.id NOT IN (?)", assigned_subnet_ids]).uniq
|
103
|
+
end
|
104
|
+
|
105
|
+
def clear_nic_assignments(interface_identifiers)
|
106
|
+
@hosts.each do |host|
|
107
|
+
interface_identifiers.each do |interface_identifier|
|
108
|
+
|
109
|
+
if host.primary_interface == interface_identifier
|
110
|
+
interface = host
|
111
|
+
else
|
112
|
+
interface = host.interfaces.find_by_identifier(interface_identifier)
|
113
|
+
end
|
114
|
+
|
115
|
+
host.interfaces.where(:attached_to => interface_identifier).map(&:subnet).compact.uniq.each do |virtual_subnet|
|
116
|
+
assigner = InterfaceAssigner.new(@deployment, interface, virtual_subnet)
|
117
|
+
assigner.unassign
|
118
|
+
end
|
119
|
+
|
120
|
+
subnet_typing = Staypuft::SubnetTyping.includes('subnet_type').where(:deployment_id => @deployment, :subnet_id => interface.subnet).first
|
121
|
+
if subnet_typing
|
122
|
+
next if subnet_typing.subnet_type.name == Staypuft::SubnetType::PXE
|
123
|
+
|
124
|
+
assigner = InterfaceAssigner.new(@deployment, interface, interface.subnet)
|
125
|
+
assigner.unassign
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -6,9 +6,14 @@ module Staypuft
|
|
6
6
|
host_ids = params[:host_ids]
|
7
7
|
host_ids = host_ids.split(',') unless host_ids.is_a? Array
|
8
8
|
@hosts = Host::Managed.where(:id => host_ids).includes(:interfaces)
|
9
|
-
@subnets = @deployment.subnets.uniq
|
10
9
|
@host = @hosts.first
|
11
|
-
|
10
|
+
assigned_subnet_ids = ([@host.subnet_id] + @host.interfaces.non_vip.map(&:subnet_id)).compact.uniq
|
11
|
+
@subnets = @deployment.subnets.where(["#{Subnet.table_name}.id NOT IN (?)", assigned_subnet_ids]).uniq
|
12
|
+
if @host
|
13
|
+
@interfaces = @host.interfaces.where("type <> 'Nic::BMC'").non_vip.order(:identifier).where(['(virtual = ? OR type = ?)', false, 'Nic::Bond'])
|
14
|
+
else
|
15
|
+
@interfaces = []
|
16
|
+
end
|
12
17
|
|
13
18
|
errors = {}
|
14
19
|
@hosts.each do |host|
|
@@ -36,7 +36,7 @@ module Staypuft
|
|
36
36
|
# just a helper for user to have all types preassigned to pxe network
|
37
37
|
pxe_network = Subnet.where('dhcp_id IS NOT NULL').first
|
38
38
|
if pxe_network
|
39
|
-
@deployment.
|
39
|
+
@deployment.unassigned_pxe_default_subnet_types.each do |type|
|
40
40
|
@deployment.subnet_typings.new(:subnet_id => pxe_network.id, :subnet_type_id => type.id).save
|
41
41
|
end
|
42
42
|
end
|
@@ -1,31 +1,41 @@
|
|
1
1
|
module Staypuft
|
2
2
|
class SubnetTypingsController < ActionController::Base
|
3
3
|
def create
|
4
|
+
@errors = {}
|
4
5
|
@deployment = Deployment.find(params[:deployment_id])
|
5
6
|
@subnet_type = SubnetType.find(params[:subnet_type_id])
|
6
7
|
@subnet = Subnet.find(params[:subnet_id])
|
7
8
|
check_for_existing_assignments
|
9
|
+
check_for_ip_management
|
10
|
+
check_for_unsharable_subnet_types
|
8
11
|
@subnet_typing = @deployment.subnet_typings.new(:subnet_id => @subnet.id, :subnet_type_id => @subnet_type.id)
|
9
|
-
@saved = @subnet_typing.save
|
12
|
+
@saved = @errors.blank? ? @subnet_typing.save : false
|
10
13
|
end
|
11
14
|
|
12
15
|
def update
|
16
|
+
@errors = {}
|
13
17
|
@subnet_typing = SubnetTyping.find(params[:id])
|
14
18
|
@deployment = @subnet_typing.deployment
|
15
19
|
@subnet_type = @subnet_typing.subnet_type
|
16
20
|
@subnet = Subnet.find(params[:subnet_id])
|
17
21
|
check_for_existing_assignments
|
22
|
+
check_for_ip_management
|
23
|
+
check_for_unsharable_subnet_types
|
18
24
|
@subnet_typing.subnet = @subnet
|
19
|
-
@saved = @subnet_typing.save
|
25
|
+
@saved = @errors.blank? ? @subnet_typing.save : false
|
20
26
|
end
|
21
27
|
|
22
28
|
def destroy
|
29
|
+
@errors = {}
|
23
30
|
@subnet_typing = SubnetTyping.find(params[:id])
|
24
31
|
@deployment = @subnet_typing.deployment
|
25
32
|
@subnet = @subnet_typing.subnet
|
26
33
|
check_for_existing_assignments
|
27
34
|
@subnet_type = @subnet_typing.subnet_type
|
28
|
-
|
35
|
+
if @subnet_type.is_required
|
36
|
+
@errors[@subnet_type.name] = ["Network traffic type is required."]
|
37
|
+
end
|
38
|
+
@destroyed = @errors.blank? ? @subnet_typing.destroy : false
|
29
39
|
end
|
30
40
|
|
31
41
|
private
|
@@ -38,5 +48,37 @@ module Staypuft
|
|
38
48
|
@warn = _('Some hosts interfaces were already assigned to this subnet, check interface assignment before deploying!')
|
39
49
|
end
|
40
50
|
end
|
51
|
+
|
52
|
+
def check_for_ip_management
|
53
|
+
if @subnet_type.foreman_managed_ips &&
|
54
|
+
!((@subnet.ipam == Subnet::IPAM_MODES[:dhcp] && @subnet.dhcp_boot_mode?) ||
|
55
|
+
(@subnet.ipam == Subnet::IPAM_MODES[:db] && !@subnet.dhcp_boot_mode?))
|
56
|
+
@errors[@subnet_type.name] = ["Foreman-managed IP addresses are required to associate with subnet."]
|
57
|
+
false
|
58
|
+
else
|
59
|
+
true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def check_for_unsharable_subnet_types
|
64
|
+
# if subnet type is unsharable, make sure nothing else is already assigned here
|
65
|
+
if @subnet_type.dedicated_subnet
|
66
|
+
if @deployment.subnet_typings.where(:subnet_id => @subnet.id).size > 0
|
67
|
+
@errors[@subnet_type.name] = ["Subnet cannot be shared with other traffic types in this deployment."]
|
68
|
+
false
|
69
|
+
else
|
70
|
+
true
|
71
|
+
end
|
72
|
+
#otherwise make sure there's no existing unsharable type already here
|
73
|
+
else
|
74
|
+
existing_dedicated_types = @deployment.subnet_typings.includes(:subnet_type).where(:subnet_id => @subnet.id, "staypuft_subnet_types.dedicated_subnet" => true)
|
75
|
+
if existing_dedicated_types.size > 0
|
76
|
+
@errors[existing_dedicated_types.first.subnet_type.name] = ["Subnet cannot be shared with other traffic types in this deployment."]
|
77
|
+
false
|
78
|
+
else
|
79
|
+
true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
41
83
|
end
|
42
84
|
end
|
data/app/lib/staypuft/seeder.rb
CHANGED
@@ -175,33 +175,60 @@ module Staypuft
|
|
175
175
|
CEPH_ROLES = ROLES.select {|h| h.fetch(:name) =~ /Ceph/ }
|
176
176
|
|
177
177
|
ALL_LAYOUTS = LAYOUTS.keys
|
178
|
-
SUBNET_TYPES = { :pxe => { :name
|
179
|
-
:required
|
180
|
-
:
|
181
|
-
|
182
|
-
:
|
183
|
-
:layouts
|
184
|
-
:
|
185
|
-
:required
|
186
|
-
:
|
187
|
-
|
188
|
-
:
|
189
|
-
:layouts
|
190
|
-
:
|
191
|
-
:required
|
192
|
-
:
|
193
|
-
|
194
|
-
:
|
195
|
-
:layouts
|
196
|
-
:
|
197
|
-
:required
|
198
|
-
:
|
199
|
-
|
200
|
-
:
|
201
|
-
:layouts
|
202
|
-
:
|
203
|
-
:required
|
204
|
-
:
|
178
|
+
SUBNET_TYPES = { :pxe => { :name => Staypuft::SubnetType::PXE,
|
179
|
+
:required => true,
|
180
|
+
:foreman_managed_ips => true,
|
181
|
+
:default_to_provisioning => true,
|
182
|
+
:dedicated_subnet => false,
|
183
|
+
:layouts => ALL_LAYOUTS},
|
184
|
+
:management => { :name => Staypuft::SubnetType::MANAGEMENT,
|
185
|
+
:required => true,
|
186
|
+
:foreman_managed_ips => true,
|
187
|
+
:default_to_provisioning => true,
|
188
|
+
:dedicated_subnet => false,
|
189
|
+
:layouts => ALL_LAYOUTS},
|
190
|
+
:external => { :name => Staypuft::SubnetType::EXTERNAL,
|
191
|
+
:required => true,
|
192
|
+
:foreman_managed_ips => false,
|
193
|
+
:default_to_provisioning => false,
|
194
|
+
:dedicated_subnet => true,
|
195
|
+
:layouts => ALL_LAYOUTS},
|
196
|
+
:cluster_mgmt => { :name => Staypuft::SubnetType::CLUSTER_MGMT,
|
197
|
+
:required => true,
|
198
|
+
:foreman_managed_ips => true,
|
199
|
+
:default_to_provisioning => true,
|
200
|
+
:dedicated_subnet => false,
|
201
|
+
:layouts => ALL_LAYOUTS},
|
202
|
+
:admin_api => { :name => Staypuft::SubnetType::ADMIN_API,
|
203
|
+
:required => true,
|
204
|
+
:foreman_managed_ips => true,
|
205
|
+
:default_to_provisioning => true,
|
206
|
+
:dedicated_subnet => false,
|
207
|
+
:layouts => ALL_LAYOUTS},
|
208
|
+
:public_api => { :name => Staypuft::SubnetType::PUBLIC_API,
|
209
|
+
:required => true,
|
210
|
+
:foreman_managed_ips => true,
|
211
|
+
:default_to_provisioning => true,
|
212
|
+
:dedicated_subnet => false,
|
213
|
+
:layouts => ALL_LAYOUTS},
|
214
|
+
:tenant => { :name => Staypuft::SubnetType::TENANT,
|
215
|
+
:required => true,
|
216
|
+
:foreman_managed_ips => false,
|
217
|
+
:default_to_provisioning => false,
|
218
|
+
:dedicated_subnet => true,
|
219
|
+
:layouts => ALL_LAYOUTS},
|
220
|
+
:storage => { :name => Staypuft::SubnetType::STORAGE,
|
221
|
+
:required => true,
|
222
|
+
:foreman_managed_ips => true,
|
223
|
+
:default_to_provisioning => true,
|
224
|
+
:dedicated_subnet => false,
|
225
|
+
:layouts => ALL_LAYOUTS},
|
226
|
+
:storage_cluster => { :name => Staypuft::SubnetType::STORAGE_CLUSTERING,
|
227
|
+
:required => true,
|
228
|
+
:foreman_managed_ips => true,
|
229
|
+
:default_to_provisioning => true,
|
230
|
+
:dedicated_subnet => false,
|
231
|
+
:layouts => ALL_LAYOUTS}
|
205
232
|
}
|
206
233
|
|
207
234
|
def get_host_format(param_name, subnet_type_name)
|
@@ -878,6 +905,9 @@ module Staypuft
|
|
878
905
|
SUBNET_TYPES.each do |key, subnet_type_hash|
|
879
906
|
subnet_type = Staypuft::SubnetType.where(:name => subnet_type_hash[:name]).first_or_initialize
|
880
907
|
subnet_type.is_required = subnet_type_hash[:required]
|
908
|
+
subnet_type.foreman_managed_ips = subnet_type_hash[:foreman_managed_ips]
|
909
|
+
subnet_type.default_to_provisioning = subnet_type_hash[:default_to_provisioning]
|
910
|
+
subnet_type.dedicated_subnet = subnet_type_hash[:dedicated_subnet]
|
881
911
|
subnet_type.save!
|
882
912
|
old_layout_subnet_types_arr = subnet_type.layout_subnet_types.to_a
|
883
913
|
subnet_type_hash[:layouts].each do |layout|
|
@@ -62,7 +62,7 @@ module Staypuft
|
|
62
62
|
:tenant_iface, :networker_ovs_bridge_mappings, :networker_ovs_bridge_uplinks,
|
63
63
|
:compute_ovs_bridge_mappings, :compute_ovs_bridge_uplinks, :ovs_tunnel_types,
|
64
64
|
:openvswitch_mechanism?, :l2population_mechanism?, :cisco_nexus_mechanism?,
|
65
|
-
:ml2_mechanisms, :nexuses
|
65
|
+
:ml2_mechanisms, :nexuses, :active?, :compute_cisco_nexus_config
|
66
66
|
end
|
67
67
|
|
68
68
|
def set_defaults
|
@@ -273,6 +273,10 @@ module Staypuft
|
|
273
273
|
self.layout.subnet_types - self.subnet_types
|
274
274
|
end
|
275
275
|
|
276
|
+
def unassigned_pxe_default_subnet_types
|
277
|
+
self.layout.subnet_types.pxe_defaults - self.subnet_types
|
278
|
+
end
|
279
|
+
|
276
280
|
def ceph_hostgroup
|
277
281
|
Hostgroup.includes(:deployment_role_hostgroup).
|
278
282
|
where(DeploymentRoleHostgroup.table_name => { deployment_id: self,
|
@@ -9,11 +9,11 @@ module Staypuft
|
|
9
9
|
else
|
10
10
|
# interface may be Host::Managed which means primary interface, so we create pseudo-interface object
|
11
11
|
@interface = Nic::Managed.new(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
:mac => interface.mac,
|
13
|
+
:virtual => false,
|
14
|
+
:identifier => interface.primary_interface,
|
15
|
+
:host => interface,
|
16
|
+
:subnet => interface.subnet)
|
17
17
|
end
|
18
18
|
|
19
19
|
@host = @interface.host
|
@@ -51,7 +51,15 @@ module Staypuft
|
|
51
51
|
|
52
52
|
def unassign
|
53
53
|
base = @host.interfaces
|
54
|
-
|
54
|
+
|
55
|
+
# we should make sure that we delete from right base, subnet vlan may have changed meanwhile which affects
|
56
|
+
# virtual_assignment? result
|
57
|
+
if @interface.is_a?(Nic::Bond)
|
58
|
+
base = base.virtual # we want to find bond and vlans (both virtual)
|
59
|
+
else
|
60
|
+
base = virtual_assignment? ? base.virtual : base.physical
|
61
|
+
end
|
62
|
+
|
55
63
|
ActiveRecord::Base.transaction do
|
56
64
|
base.where(:subnet_id => @subnet.id).each do |interface|
|
57
65
|
virtual_assignment? ? unassign_virtual(interface) : unassign_physical(interface)
|
@@ -66,25 +74,30 @@ module Staypuft
|
|
66
74
|
|
67
75
|
private
|
68
76
|
|
77
|
+
def build_new_interface(klass = Nic::Managed)
|
78
|
+
klass.new(
|
79
|
+
:attached_to => @interface.identifier,
|
80
|
+
:mac => @interface.mac,
|
81
|
+
:host => @host,
|
82
|
+
:virtual => true,
|
83
|
+
:identifier => @interface.identifier + ".#{@subnet.vlanid}"
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
69
87
|
def assign_virtual
|
70
|
-
interface =
|
71
|
-
|
72
|
-
:physical_device => @interface.identifier,
|
73
|
-
:mac => @interface.mac,
|
74
|
-
:host => @host,
|
75
|
-
:virtual => true,
|
76
|
-
:identifier => @interface.identifier + ".#{@subnet.vlanid}")
|
77
|
-
suggest_ip(interface) if @subnet.ipam?
|
78
|
-
unless interface.save
|
79
|
-
@errors.push(*interface.errors.full_messages)
|
80
|
-
end
|
88
|
+
interface = build_new_interface
|
89
|
+
assign_interface(interface)
|
81
90
|
end
|
82
91
|
|
83
92
|
def assign_physical
|
84
|
-
@interface
|
85
|
-
|
86
|
-
|
87
|
-
|
93
|
+
assign_interface(@interface)
|
94
|
+
end
|
95
|
+
|
96
|
+
def assign_interface(interface)
|
97
|
+
interface.subnet = @subnet
|
98
|
+
suggest_ip(interface) if @subnet.ipam?
|
99
|
+
unless interface.save
|
100
|
+
@errors.push(*interface.errors.full_messages)
|
88
101
|
end
|
89
102
|
end
|
90
103
|
|
@@ -92,6 +105,7 @@ module Staypuft
|
|
92
105
|
# subnet could become virtual/physical meanwhile
|
93
106
|
def unassign_from_other_nics
|
94
107
|
unassign_physicals
|
108
|
+
unassign_bonds
|
95
109
|
unassign_virtuals
|
96
110
|
end
|
97
111
|
|
@@ -111,8 +125,14 @@ module Staypuft
|
|
111
125
|
end
|
112
126
|
end
|
113
127
|
|
128
|
+
def unassign_bonds
|
129
|
+
@host.interfaces.bonds.where(:subnet_id => @subnet.id).each do |interface|
|
130
|
+
unassign_physical(interface)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
114
134
|
def unassign_virtuals
|
115
|
-
@host.interfaces.virtual.where(:subnet_id => @subnet.id).each do |interface|
|
135
|
+
@host.interfaces.virtual.where('type <> ?', Nic::Bond.to_s).where(:subnet_id => @subnet.id).each do |interface|
|
116
136
|
unassign_virtual(interface)
|
117
137
|
end
|
118
138
|
end
|
@@ -23,6 +23,7 @@ module Staypuft
|
|
23
23
|
has_many :subnets, :through => :subnet_typings
|
24
24
|
|
25
25
|
scope :required, lambda { where(:is_required => true) }
|
26
|
+
scope :pxe_defaults, lambda { where(:default_to_provisioning => true) }
|
26
27
|
|
27
28
|
class Jail < Safemode::Jail
|
28
29
|
allow :layouts, :layout_subnet_types, :name, :subnets, :subnet_typings, :required
|