Sha256: 4b5d85ef1631ec2ff54bf5a93cbfe6a1e11520408e067f12195374efede9c10d

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

require 'fog/huaweicloud/models/model'

module Fog
  module Baremetal
    class HuaweiCloud
      class Port < Fog::HuaweiCloud::Model
        identity :uuid

        attribute :address
        attribute :uuid

        # detailed
        attribute :created_at
        attribute :updated_at
        attribute :extra
        attribute :node_uuid

        def create
          requires :address, :node_uuid
          merge_attributes(service.create_port(attributes).body)
          self
        end

        def update(patch = nil)
          requires :uuid, :address, :node_uuid
          if patch
            merge_attributes(service.patch_port(uuid, patch).body)
          else
            # TODO: implement update_node method using PUT method and self.attributes
            # once it is supported by Ironic
            raise ArgumentError,
                  'You need to provide patch attribute. Ironic does not support update by hash yet, only by jsonpatch.'
          end
          self
        end

        def destroy
          requires :uuid
          service.delete_port(uuid)
          true
        end

        def metadata
          requires :uuid
          service.get_port(uuid).headers
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-huaweicloud-0.0.3 lib/fog/baremetal/huaweicloud/models/port.rb
fog-huaweicloud-0.0.2 lib/fog/baremetal/huaweicloud/models/port.rb
fog-huaweicloud-0.1.3 lib/fog/baremetal/huaweicloud/models/port.rb
fog-huaweicloud-0.1.2 lib/fog/baremetal/huaweicloud/models/port.rb