class Fog::NFV::OpenStack::Real

Public Class Methods

new(options = {}) click to toggle source
# File lib/fog/nfv/openstack.rb, line 105
def initialize(options = {})
  initialize_identity options

  @openstack_service_type  = options[:openstack_service_type] || ['servicevm']
  @openstack_service_name  = options[:openstack_service_name]

  @connection_options = options[:connection_options] || {}

  authenticate
  set_api_path

  @persistent = options[:persistent] || false
  @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
not_found_class() click to toggle source
# File lib/fog/nfv/openstack.rb, line 101
def self.not_found_class
  Fog::NFV::OpenStack::NotFound
end

Public Instance Methods

create_vnf(options) click to toggle source
# File lib/fog/nfv/openstack/requests/create_vnf.rb, line 5
def create_vnf(options)
  options_valid = [
    :auth,
    :vnf,
  ]

  # Filter only allowed creation attributes
  data = options.select do |key, _|
    options_valid.include?(key.to_sym) || options_valid.include?(key.to_s)
  end

  request(
    :body    => Fog::JSON.encode(data),
    :expects => 201,
    :method  => "POST",
    :path    => "vnfs"
  )
end
create_vnfd(options) click to toggle source
# File lib/fog/nfv/openstack/requests/create_vnfd.rb, line 5
def create_vnfd(options)
  options_valid = [
    :auth,
    :vnfd,
  ]

  # Filter only allowed creation attributes
  data = options.select do |key, _|
    options_valid.include?(key.to_sym) || options_valid.include?(key.to_s)
  end

  request(
    :body    => Fog::JSON.encode(data),
    :expects => 201,
    :method  => "POST",
    :path    => "vnfds"
  )
end
delete_vnf(vnf_id) click to toggle source
# File lib/fog/nfv/openstack/requests/delete_vnf.rb, line 5
def delete_vnf(vnf_id)
  request(
    :expects => 204,
    :method  => "DELETE",
    :path    => "vnfs/#{vnf_id}"
  )
end
delete_vnfd(vnfd_id) click to toggle source
# File lib/fog/nfv/openstack/requests/delete_vnfd.rb, line 5
def delete_vnfd(vnfd_id)
  request(
    :expects => 204,
    :method  => "DELETE",
    :path    => "vnfds/#{vnfd_id}"
  )
end
get_vnf(vnf_id) click to toggle source
# File lib/fog/nfv/openstack/requests/get_vnf.rb, line 5
def get_vnf(vnf_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "vnfs/#{vnf_id}"
  )
end
get_vnfd(vnfd_id) click to toggle source
# File lib/fog/nfv/openstack/requests/get_vnfd.rb, line 5
def get_vnfd(vnfd_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "vnfds/#{vnfd_id}"
  )
end
list_vnfds(options = {}) click to toggle source
# File lib/fog/nfv/openstack/requests/list_vnfds.rb, line 5
def list_vnfds(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "vnfds",
    :query   => options
  )
end
list_vnfs(options = {}) click to toggle source
# File lib/fog/nfv/openstack/requests/list_vnfs.rb, line 5
def list_vnfs(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "vnfs",
    :query   => options
  )
end
set_api_path() click to toggle source
# File lib/fog/nfv/openstack.rb, line 120
def set_api_path
  unless @path.match(SUPPORTED_VERSIONS)
    @path = "/" + Fog::OpenStack.get_supported_version(
      SUPPORTED_VERSIONS,
      @openstack_management_uri,
      @auth_token,
      @connection_options
    )
  end
end
update_vnf(id, options) click to toggle source
# File lib/fog/nfv/openstack/requests/update_vnf.rb, line 5
def update_vnf(id, options)
  options_valid = [
    :auth,
    :vnf,
  ]

  # Filter only allowed creation attributes
  data = options.select do |key, _|
    options_valid.include?(key.to_sym) || options_valid.include?(key.to_s)
  end

  request(
    :body    => Fog::JSON.encode(data),
    :expects => 200,
    :method  => "PUT",
    :path    => "vnfs/#{id}"
  )
end