Sha256: d864bba1c58ba3fcba87a123d7024c0b6567e6daeaf42e80e3bb49c6e7ca9cd8

Contents?: true

Size: 916 Bytes

Versions: 4

Compression:

Stored size: 916 Bytes

Contents

require 'fog/core/collection'
require 'fog/openstack/models/baremetal/port'

module Fog
  module Baremetal
    class OpenStack
      class Ports < Fog::Collection
        model Fog::Baremetal::OpenStack::Port

        def all
          load(service.list_ports.body['ports'])
        end

        def details(parameters=nil)
          load(service.list_ports_detailed(parameters).body['ports'])
        end

        def find_by_uuid(uuid)
          new(service.get_port(uuid).body)
        end
        alias_method :get, :find_by_uuid

        def destroy(uuid)
          port = self.find_by_id(uuid)
          port.destroy
        end

        def method_missing(method_sym, *arguments, &block)
          if method_sym.to_s =~ /^find_by_(.*)$/
            load(service.list_ports_detailed({$1 => arguments.first}).body['ports'])
          else
            super
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-1.31.0 lib/fog/openstack/models/baremetal/ports.rb
fog-1.30.0 lib/fog/openstack/models/baremetal/ports.rb
fog-1.29.0 lib/fog/openstack/models/baremetal/ports.rb
fog-1.28.0 lib/fog/openstack/models/baremetal/ports.rb