Class: Kubernetes::V1Device

Inherits:
Object
  • Object
show all
Defined in:
lib/kubernetes/models/v1_device.rb

Overview

Device represents one individual hardware instance that can be selected based on its attributes. Besides the name, exactly one field must be set.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ V1Device

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/kubernetes/models/v1_device.rb', line 108

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Kubernetes::V1Device` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Kubernetes::V1Device`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'all_nodes')
    self.all_nodes = attributes[:'all_nodes']
  end

  if attributes.key?(:'allow_multiple_allocations')
    self.allow_multiple_allocations = attributes[:'allow_multiple_allocations']
  end

  if attributes.key?(:'attributes')
    if (value = attributes[:'attributes']).is_a?(Hash)
      self.attributes = value
    end
  end

  if attributes.key?(:'binding_conditions')
    if (value = attributes[:'binding_conditions']).is_a?(Array)
      self.binding_conditions = value
    end
  end

  if attributes.key?(:'binding_failure_conditions')
    if (value = attributes[:'binding_failure_conditions']).is_a?(Array)
      self.binding_failure_conditions = value
    end
  end

  if attributes.key?(:'binds_to_node')
    self.binds_to_node = attributes[:'binds_to_node']
  end

  if attributes.key?(:'capacity')
    if (value = attributes[:'capacity']).is_a?(Hash)
      self.capacity = value
    end
  end

  if attributes.key?(:'consumes_counters')
    if (value = attributes[:'consumes_counters']).is_a?(Array)
      self.consumes_counters = value
    end
  end

  if attributes.key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.key?(:'node_allocatable_resource_mappings')
    if (value = attributes[:'node_allocatable_resource_mappings']).is_a?(Hash)
      self.node_allocatable_resource_mappings = value
    end
  end

  if attributes.key?(:'node_name')
    self.node_name = attributes[:'node_name']
  end

  if attributes.key?(:'node_selector')
    self.node_selector = attributes[:'node_selector']
  end

  if attributes.key?(:'taints')
    if (value = attributes[:'taints']).is_a?(Array)
      self.taints = value
    end
  end
end

Instance Attribute Details

#all_nodesObject

AllNodes indicates that all nodes have access to the device. Must only be set if Spec.PerDeviceNodeSelection is set to true. At most one of NodeName, NodeSelector and AllNodes can be set.



20
21
22
# File 'lib/kubernetes/models/v1_device.rb', line 20

def all_nodes
  @all_nodes
end

#allow_multiple_allocationsObject

AllowMultipleAllocations marks whether the device is allowed to be allocated to multiple DeviceRequests. If AllowMultipleAllocations is set to true, the device can be allocated more than once, and all of its capacity is consumable, regardless of whether the requestPolicy is defined or not.



23
24
25
# File 'lib/kubernetes/models/v1_device.rb', line 23

def allow_multiple_allocations
  @allow_multiple_allocations
end

#attributesObject

Attributes defines the set of attributes for this device. The name of each attribute must be unique in that set. The maximum number of attributes and capacities combined is 32.



26
27
28
# File 'lib/kubernetes/models/v1_device.rb', line 26

def attributes
  @attributes
end

#binding_conditionsObject

BindingConditions defines the conditions for proceeding with binding. All of these conditions must be set in the per-device status conditions with a value of True to proceed with binding the pod to the node while scheduling the pod. The maximum number of binding conditions is 4. The conditions must be a valid condition type string. This is a beta field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus feature gates.



29
30
31
# File 'lib/kubernetes/models/v1_device.rb', line 29

def binding_conditions
  @binding_conditions
end

#binding_failure_conditionsObject

BindingFailureConditions defines the conditions for binding failure. They may be set in the per-device status conditions. If any is set to "True", a binding failure occurred. The maximum number of binding failure conditions is 4. The conditions must be a valid condition type string. This is a beta field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus feature gates.



32
33
34
# File 'lib/kubernetes/models/v1_device.rb', line 32

def binding_failure_conditions
  @binding_failure_conditions
end

#binds_to_nodeObject

BindsToNode indicates if the usage of an allocation involving this device has to be limited to exactly the node that was chosen when allocating the claim. If set to true, the scheduler will set the ResourceClaim.Status.Allocation.NodeSelector to match the node where the allocation was made. This is a beta field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus feature gates.



35
36
37
# File 'lib/kubernetes/models/v1_device.rb', line 35

def binds_to_node
  @binds_to_node
end

#capacityObject

Capacity defines the set of capacities for this device. The name of each capacity must be unique in that set. The maximum number of attributes and capacities combined is 32.



38
39
40
# File 'lib/kubernetes/models/v1_device.rb', line 38

def capacity
  @capacity
end

#consumes_countersObject

ConsumesCounters defines a list of references to sharedCounters and the set of counters that the device will consume from those counter sets. There can only be a single entry per counterSet. The maximum number of device counter consumptions per device is 2.



41
42
43
# File 'lib/kubernetes/models/v1_device.rb', line 41

def consumes_counters
  @consumes_counters
end

#nameObject

Name is unique identifier among all devices managed by the driver in the pool. It must be a DNS label.



44
45
46
# File 'lib/kubernetes/models/v1_device.rb', line 44

def name
  @name
end

#node_allocatable_resource_mappingsObject

NodeAllocatableResourceMappings defines the mapping of node resources that are managed by the DRA driver exposing this device. This includes resources currently reported in v1.Node ‘status.allocatable` that are not extended resources (see kubernetes.io/docs/concepts/configuration/manage-resources-containers/#extended-resources). Examples include "cpu", "memory", "ephemeral-storage", and hugepages. In addition to standard requests made through the Pod `spec`, these resources can also be requested through claims and allocated by the DRA driver. For example, a CPU DRA driver might allocate exclusive CPUs or auxiliary node memory dependencies of an accelerator device. The keys of this map are the node-allocatable resource names (e.g., "cpu", "memory"). Extended resource names are not permitted as keys.



47
48
49
# File 'lib/kubernetes/models/v1_device.rb', line 47

def node_allocatable_resource_mappings
  @node_allocatable_resource_mappings
end

#node_nameObject

NodeName identifies the node where the device is available. Must only be set if Spec.PerDeviceNodeSelection is set to true. At most one of NodeName, NodeSelector and AllNodes can be set.



50
51
52
# File 'lib/kubernetes/models/v1_device.rb', line 50

def node_name
  @node_name
end

#node_selectorObject

Returns the value of attribute node_selector.



52
53
54
# File 'lib/kubernetes/models/v1_device.rb', line 52

def node_selector
  @node_selector
end

#taintsObject

If specified, these are the driver-defined taints. The maximum number of taints is 16. If taints are set for any device in a ResourceSlice, then the maximum number of allowed devices per ResourceSlice is 64 instead of 128. This is a beta field and requires enabling the DRADeviceTaints feature gate.



55
56
57
# File 'lib/kubernetes/models/v1_device.rb', line 55

def taints
  @taints
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



77
78
79
# File 'lib/kubernetes/models/v1_device.rb', line 77

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/kubernetes/models/v1_device.rb', line 58

def self.attribute_map
  {
    :'all_nodes' => :'allNodes',
    :'allow_multiple_allocations' => :'allowMultipleAllocations',
    :'attributes' => :'attributes',
    :'binding_conditions' => :'bindingConditions',
    :'binding_failure_conditions' => :'bindingFailureConditions',
    :'binds_to_node' => :'bindsToNode',
    :'capacity' => :'capacity',
    :'consumes_counters' => :'consumesCounters',
    :'name' => :'name',
    :'node_allocatable_resource_mappings' => :'nodeAllocatableResourceMappings',
    :'node_name' => :'nodeName',
    :'node_selector' => :'nodeSelector',
    :'taints' => :'taints'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



241
242
243
# File 'lib/kubernetes/models/v1_device.rb', line 241

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



101
102
103
104
# File 'lib/kubernetes/models/v1_device.rb', line 101

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/kubernetes/models/v1_device.rb', line 82

def self.openapi_types
  {
    :'all_nodes' => :'Boolean',
    :'allow_multiple_allocations' => :'Boolean',
    :'attributes' => :'Hash<String, V1DeviceAttribute>',
    :'binding_conditions' => :'Array<String>',
    :'binding_failure_conditions' => :'Array<String>',
    :'binds_to_node' => :'Boolean',
    :'capacity' => :'Hash<String, V1DeviceCapacity>',
    :'consumes_counters' => :'Array<V1DeviceCounterConsumption>',
    :'name' => :'String',
    :'node_allocatable_resource_mappings' => :'Hash<String, V1NodeAllocatableResourceMapping>',
    :'node_name' => :'String',
    :'node_selector' => :'V1NodeSelector',
    :'taints' => :'Array<V1DeviceTaint>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/kubernetes/models/v1_device.rb', line 208

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      all_nodes == o.all_nodes &&
      allow_multiple_allocations == o.allow_multiple_allocations &&
      attributes == o.attributes &&
      binding_conditions == o.binding_conditions &&
      binding_failure_conditions == o.binding_failure_conditions &&
      binds_to_node == o.binds_to_node &&
      capacity == o.capacity &&
      consumes_counters == o.consumes_counters &&
      name == o.name &&
      node_allocatable_resource_mappings == o.node_allocatable_resource_mappings &&
      node_name == o.node_name &&
      node_selector == o.node_selector &&
      taints == o.taints
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/kubernetes/models/v1_device.rb', line 271

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = Kubernetes.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/kubernetes/models/v1_device.rb', line 342

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/kubernetes/models/v1_device.rb', line 248

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      self.send("#{key}=", nil)
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


228
229
230
# File 'lib/kubernetes/models/v1_device.rb', line 228

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



234
235
236
# File 'lib/kubernetes/models/v1_device.rb', line 234

def hash
  [all_nodes, allow_multiple_allocations, attributes, binding_conditions, binding_failure_conditions, binds_to_node, capacity, consumes_counters, name, node_allocatable_resource_mappings, node_name, node_selector, taints].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



190
191
192
193
194
195
196
197
# File 'lib/kubernetes/models/v1_device.rb', line 190

def list_invalid_properties
  invalid_properties = Array.new
  if @name.nil?
    invalid_properties.push('invalid value for "name", name cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



318
319
320
# File 'lib/kubernetes/models/v1_device.rb', line 318

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/kubernetes/models/v1_device.rb', line 324

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



312
313
314
# File 'lib/kubernetes/models/v1_device.rb', line 312

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



201
202
203
204
# File 'lib/kubernetes/models/v1_device.rb', line 201

def valid?
  return false if @name.nil?
  true
end