Sha256: 86e62820a7ec551574c1c6c9514234cafa674d732294c711609642afdd220be1

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

require 'fog/huaweicloud/models/model'

module Fog
  module NFV
    class HuaweiCloud
      class Vnf < Fog::HuaweiCloud::Model
        identity :id

        attribute :status
        attribute :name
        attribute :tenant_id
        attribute :instance_id
        attribute :mgmt_url
        attribute :description
        attribute :vnf_attributes

        # Attributes for create and update
        attribute :vnf
        attribute :auth

        def create(options = {})
          merge_attributes(service.create_vnf(default_options.merge(options)).body['vnf'])
          self
        end

        def update(options = {})
          merge_attributes(service.update_vnf(identity, default_options.merge(options)).body['vnf'])
          self
        end

        def save(options = {})
          identity ? update(options) : create(options)
        end

        def destroy
          requires :id
          service.delete_vnf(id)
          true
        end

        def default_options
          {
            :vnf  => vnf,
            :auth => auth
          }
        end

        def vnf_attributes
          attributes['attributes']
        end

        def ready?
          status == 'ACTIVE'
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-huaweicloud-0.0.3 lib/fog/nfv/huaweicloud/models/vnf.rb
fog-huaweicloud-0.0.2 lib/fog/nfv/huaweicloud/models/vnf.rb
fog-huaweicloud-0.1.3 lib/fog/nfv/huaweicloud/models/vnf.rb
fog-huaweicloud-0.1.2 lib/fog/nfv/huaweicloud/models/vnf.rb