module Hyperkit::Client::Networks

Methods for the networks API

@see Hyperkit::Client @see github.com/lxc/lxd/blob/master/doc/rest-api.md

Public Instance Methods

network(name) click to toggle source

Get information on a network

@return [Sawyer::Resource] Network information

@example Get information about lxcbr0

Hyperkit.network("lxcbr0") #=> {:name=>"lxcbr0", :type=>"bridge", :used_by=>[]}
# File lib/hyperkit/client/networks.rb, line 28
def network(name)
  get(network_path(name)).metadata
end
networks() click to toggle source

List of networks defined on the host

@return [Array<String>] An array of networks defined on the host

@example Get list of networks

Hyperkit.networks #=> ["lo", "eth0", "lxcbr0"]
# File lib/hyperkit/client/networks.rb, line 17
def networks
  response = get(networks_path)
  response.metadata.map { |path| path.split('/').last }
end

Private Instance Methods

network_path(name) click to toggle source
# File lib/hyperkit/client/networks.rb, line 34
def network_path(name)
  File.join(networks_path, name)
end
networks_path() click to toggle source
# File lib/hyperkit/client/networks.rb, line 38
def networks_path
  "/1.0/networks"
end