-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from alces-flight/feature/volume-devices
Add representation of volume devices
- Loading branch information
Showing
27 changed files
with
480 additions
and
47 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Device::VolumeDetails < Device::Details | ||
|
||
validate :device_uses_volume_template | ||
|
||
private | ||
|
||
def device_uses_volume_template | ||
reload_device | ||
return unless device.present? | ||
unless device.template.tag == 'volume' | ||
self.errors.add(:device, 'must use the `volume` template if it has a Device::VolumeDetails') | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Device::DetailsPresenter < Presenter | ||
|
||
def is_compute_device? | ||
false | ||
def additional_details | ||
[] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
class Device::NetworkDetailsPresenter < Device::DetailsPresenter | ||
|
||
def additional_details | ||
{ | ||
'Admin state up:': o.admin_state_up, | ||
'DNS domain': o.dns_domain, | ||
'L2 adjacency:': o.l2_adjacency, | ||
'MTU:': o.mtu, | ||
'Port security enabled:': o.port_security_enabled, | ||
'Shared:': o.shared, | ||
'QoS policy:': o.qos_policy | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Device::VolumeDetailsPresenter < Device::DetailsPresenter | ||
|
||
def additional_details | ||
{ | ||
'Availability zone:': o.availability_zone, | ||
'Bootable:': o.bootable, | ||
'Encrypted:': o.encrypted, | ||
'Read-only:': o.read_only, | ||
'Size (GB):': o.size, | ||
'Volume type:': o.volume_type | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
object @details | ||
|
||
attributes :availability_zone, :bootable, :encrypted, :read_only, :size, | ||
:volume_type |
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,14 @@ | ||
class CreateDeviceVolumeDetails < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :device_volume_details, id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| | ||
t.string :availability_zone | ||
t.boolean :bootable | ||
t.boolean :encrypted | ||
t.boolean :read_only | ||
t.integer :size | ||
t.string :volume_type | ||
|
||
t.timestamps | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class SeedVolumeDeviceTemplate < ActiveRecord::Migration[7.1] | ||
|
||
class Template < ApplicationRecord | ||
enum rackable: { rackable: 1, zerouable: 2, nonrackable: 3 } | ||
end | ||
|
||
def change | ||
Template.reset_column_information | ||
reversible do |dir| | ||
|
||
dir.up do | ||
t = Template.new( | ||
name: 'volume', | ||
template_type: 'Device', | ||
tag: 'volume', | ||
version: 1, | ||
height: 2, | ||
depth: 2, | ||
rows: 1, | ||
columns: 1, | ||
rackable: 'rackable', | ||
simple: true, | ||
description: 'Volume', | ||
images: { | ||
'front' => 'disk_front_2u.png', | ||
'rear' => 'generic_rear_2u.png', | ||
} | ||
) | ||
t.save! | ||
end | ||
|
||
dir.down do | ||
Template.find_by_tag('volume')&.destroy! | ||
end | ||
|
||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Oops, something went wrong.