1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
require 'fog/openstack/models/model'
module Fog
module OpenStack
class NFV
class Vnf < Fog::OpenStack::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
|