Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions lib/fog/libvirt/models/compute/tpm.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
require 'fog/core/model'

module Fog
module Libvirt
class Compute
class TPM < Fog::Model
# Currently Qemu only allows for one TPM device

identity :id
attribute :model
attribute :type
attribute :version
attribute :device_path
attribute :spapr_address_type
attribute :spapr_address_reg

# Models
# crb - TCG PC Client Platform TPM Profile (PTP) Specification (2017)
# tis - TCG PC Client Specific TPM Interface Specification (TIS) (2013)
# spapr - Used with pSeries (ppc64)
# spapr-tpm-proxy - Used with pSeries (ppc64), this is only used with 'passthrough' type
#
MODELS = ['crb', 'tis', 'spapr', 'spapr-tpm-proxy']

Check warning on line 23 in lib/fog/libvirt/models/compute/tpm.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Freeze mutable objects assigned to constants. Raw Output: lib/fog/libvirt/models/compute/tpm.rb:23:18: C: Style/MutableConstant: Freeze mutable objects assigned to constants.

# Versions
#
VERSIONS = ['1.2', '2.0']

Check warning on line 27 in lib/fog/libvirt/models/compute/tpm.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Freeze mutable objects assigned to constants. Raw Output: lib/fog/libvirt/models/compute/tpm.rb:27:20: C: Style/MutableConstant: Freeze mutable objects assigned to constants.

# Types
#
TYPES = ['emulator', 'passthrough']

Check warning on line 31 in lib/fog/libvirt/models/compute/tpm.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Freeze mutable objects assigned to constants. Raw Output: lib/fog/libvirt/models/compute/tpm.rb:31:17: C: Style/MutableConstant: Freeze mutable objects assigned to constants.

def initialize(attributes={})

Check warning on line 33 in lib/fog/libvirt/models/compute/tpm.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Surrounding space missing in default value assignment. Raw Output: lib/fog/libvirt/models/compute/tpm.rb:33:34: C: Layout/SpaceAroundEqualsInParameterDefault: Surrounding space missing in default value assignment.
super defaults.merge(attributes)
raise Fog::Errors::Error.new("#{model} is not a supported tpm model") if new? && !MODELS.include?(model)

Check warning on line 35 in lib/fog/libvirt/models/compute/tpm.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/fog/libvirt/models/compute/tpm.rb:35:115: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Check warning on line 35 in lib/fog/libvirt/models/compute/tpm.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Provide an exception class and message as arguments to `raise`. Raw Output: lib/fog/libvirt/models/compute/tpm.rb:35:11: C: Style/RaiseArgs: Provide an exception class and message as arguments to `raise`.
raise Fog::Errors::Error.new("#{type} is not a supported tpm type") if new? && !TYPES.include?(type)

Check warning on line 36 in lib/fog/libvirt/models/compute/tpm.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Provide an exception class and message as arguments to `raise`. Raw Output: lib/fog/libvirt/models/compute/tpm.rb:36:11: C: Style/RaiseArgs: Provide an exception class and message as arguments to `raise`.
end

def new?
id.nil?
end

def save
raise Fog::Errors::Error.new('Creating a new tpm device is not yet implemented. Contributions welcome!')

Check warning on line 44 in lib/fog/libvirt/models/compute/tpm.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Provide an exception class and message as arguments to `raise`. Raw Output: lib/fog/libvirt/models/compute/tpm.rb:44:11: C: Style/RaiseArgs: Provide an exception class and message as arguments to `raise`.
end

def destroy
raise Fog::Errors::Error.new('Destroying a tpm device is not yet implemented. Contributions welcome!')

Check warning on line 48 in lib/fog/libvirt/models/compute/tpm.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Provide an exception class and message as arguments to `raise`. Raw Output: lib/fog/libvirt/models/compute/tpm.rb:48:11: C: Style/RaiseArgs: Provide an exception class and message as arguments to `raise`.
end

def defaults
{
:model => "crb",
:type => "emulator",
:version => "2.0",
:device_path => "/dev/tpm0",
:spapr_address_type => "spapr-vio",
:spapr_address_reg => "0x00004000",

Check warning on line 58 in lib/fog/libvirt/models/compute/tpm.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Avoid comma after the last item of a hash. Raw Output: lib/fog/libvirt/models/compute/tpm.rb:58:47: C: Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.
}
end
end
end
end
end
Loading