-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save ram and storage of a request in gb internally (#342)
* Save ram and storage of a request in gb internally * Fix CodeFactor * Fix Tests * Fix same Tests, hopefully * Forgot Gemfile * Add some tests for request templates and convert gb to mibi and kibi for vsphere * Rename comments * Modify migration * CodeFactor ... * Modify migration again * Refactor os on vm edit config page
- Loading branch information
1 parent
df1d8d9
commit b979c13
Showing
25 changed files
with
160 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -473,4 +473,4 @@ RUBY VERSION | |
ruby 2.5.0p0 | ||
|
||
BUNDLED WITH | ||
1.16.2 | ||
1.17.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class RequestTemplate < ApplicationRecord | ||
MAX_CPU_CORES = 64 | ||
MAX_RAM_GB = 256 | ||
MAX_STORAGE_GB = 1_000 | ||
|
||
validates :name, :cpu_cores, :ram_gb, :storage_gb, :operating_system, presence: true | ||
validates :cpu_cores, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: MAX_CPU_CORES } | ||
validates :ram_gb, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: MAX_RAM_GB } | ||
validates :storage_gb, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: MAX_STORAGE_GB } | ||
validates :cpu_cores, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: Request::MAX_CPU_CORES } | ||
validates :ram_gb, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: Request::MAX_RAM_GB } | ||
validates :storage_gb, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: Request::MAX_STORAGE_GB } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
json.extract! request, :id, :name, :cpu_cores, :ram_mb, :storage_mb, :operating_system, :comment, :rejection_information, :status, :created_at, :updated_at | ||
json.extract! request, :id, :name, :cpu_cores, :ram_gb, :storage_gb, :operating_system, :comment, :rejection_information, :status, :created_at, :updated_at | ||
json.url request_url(request, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
class RenameRequestMbToGb < ActiveRecord::Migration[5.2] | ||
def up | ||
rename_column :requests, :ram_mb, :ram_gb | ||
rename_column :requests, :storage_mb, :storage_gb | ||
update_requests | ||
end | ||
|
||
def update_requests | ||
Request.all.each do |request| | ||
unless request.nil? | ||
request.ram_gb = (request.ram_gb / 1000.0).ceil | ||
request.storage_gb = (request.storage_gb / 1000.0).ceil | ||
end | ||
request.save | ||
end | ||
end | ||
|
||
def down | ||
raise ActiveRecord::IrreversibleMigration | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.