Skip to content

Commit

Permalink
feat(compute): remove old bare metal filter for flavor (#1399)
Browse files Browse the repository at this point in the history
  • Loading branch information
hgw77 authored Sep 5, 2024
1 parent 0651b9b commit 5ae1b48
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
33 changes: 20 additions & 13 deletions plugins/compute/app/helpers/compute/instances_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ def js_images_data(images)
js_data = []
unless images.empty?
js_data =
images.map do |flavor|
images.map do |image|
{
flavor.id => {
"name" => flavor.name,
"ram" => flavor.ram,
"vcpus" => flavor.vcpus,
"disk" => flavor.disk,
image.id => {
"name" => image.name,
"ram" => image.ram,
"vcpus" => image.vcpus,
"disk" => image.disk,
},
}
end
Expand Down Expand Up @@ -193,7 +193,7 @@ def grouped_flavors(flavors)
private_flavors = []
flavors.each do |flavor|
if flavor.public?
if flavor.name =~ /^(baremetal|zg|zh|bg_|bm_)/
if flavor.extra_specs["capabilities:hypervisor_type"] == "ironic"
public_flavors_baremetal << flavor
else
public_flavors_vmware << flavor
Expand Down Expand Up @@ -269,21 +269,28 @@ def js_flavor_data(flavors)
flavors.map do |flavor|
{
flavor.id => {
"name" => flavor.name,
"ram" => flavor.ram,
"vcpus" => flavor.vcpus,
"disk" => flavor.disk,
"name" => flavor.name,
"ram" => flavor.ram,
"vcpus" => flavor.vcpus,
"disk" => flavor.disk,
"hypervisor_type" => flavor.extra_specs["capabilities:hypervisor_type"],
},
}
end
end

js_data.to_json
end

# flavor label in dropdown
def flavor_label_for_select(flavor)
"#{flavor.name} (RAM: #{Core::DataType.new(:bytes, :mega).format(flavor.ram)}, VCPUs: #{flavor.vcpus}, Disk: #{Core::DataType.new(:bytes, :giga).format(flavor.disk)} )"

label = "#{flavor.name} (RAM: #{Core::DataType.new(:bytes, :mega).format(flavor.ram)}, VCPUs: #{flavor.vcpus}, Disk: #{Core::DataType.new(:bytes, :giga).format(flavor.disk)} )"

if flavor.extra_specs["capabilities:hypervisor_type"] == "ironic"
label = "#{flavor.name} ironic (RAM: #{Core::DataType.new(:bytes, :mega).format(flavor.ram)}, VCPUs: #{flavor.vcpus}, Disk: #{Core::DataType.new(:bytes, :giga).format(flavor.disk)} )"
end

return label
end

########################################################################
Expand Down
14 changes: 2 additions & 12 deletions plugins/compute/app/views/compute/instances/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,7 @@
:javascript
$(document).ready(function(){
if ($('#server_flavor_id option:selected').text() != "Choose flavor") {
if ($('#server_flavor_id option:selected').text().match(/^baremetal/) ||
$('#server_flavor_id option:selected').text().match(/^hv/) ||
$('#server_flavor_id option:selected').text().match(/^zh/) ||
$('#server_flavor_id option:selected').text().match(/^bm_/) ||
$('#server_flavor_id option:selected').text().match(/^bg_/) ||
$('#server_flavor_id option:selected').text().match(/^zg/)) {
if ($('#server_flavor_id option:selected').text().match(/ironic/)) {
// baremetal
$('#baremetal_image_id_wrapper').removeClass('hidden');

Expand Down Expand Up @@ -146,12 +141,7 @@
//flavors = JSON.parse(flavors.replace(/&quot;/g,'"'));
$('#server_flavor_id').change(function(){
//console.log($( this ).val())
if ($('#server_flavor_id option:selected').text().match(/^baremetal/) ||
$('#server_flavor_id option:selected').text().match(/^hv/) ||
$('#server_flavor_id option:selected').text().match(/^zh/) ||
$('#server_flavor_id option:selected').text().match(/^bm_/) ||
$('#server_flavor_id option:selected').text().match(/^bg_/) ||
$('#server_flavor_id option:selected').text().match(/^zg/)) {
if ($('#server_flavor_id option:selected').text().match(/ironic/)) {
// baremetal
$('#baremetal_image_id_wrapper').removeClass('hidden');
$('#vmware_image_id_wrapper').addClass('hidden');
Expand Down

0 comments on commit 5ae1b48

Please sign in to comment.