Class: Hyperkit::Client

Inherits:
Object
  • Object
show all
Includes:
Certificates, Containers, Images, Networks, Operations, Profiles, Configurable, Connection, Utility
Defined in:
lib/hyperkit/client.rb,
lib/hyperkit/client/images.rb,
lib/hyperkit/client/profiles.rb,
lib/hyperkit/client/networks.rb,
lib/hyperkit/client/operations.rb,
lib/hyperkit/client/containers.rb,
lib/hyperkit/client/certificates.rb

Overview

LXD client

Defined Under Namespace

Modules: Certificates, Containers, Images, Networks, Operations, Profiles

Constant Summary

Constants included from Connection

Hyperkit::Connection::CONVENIENCE_HEADERS

Instance Attribute Summary

Attributes included from Configurable

#api_endpoint, #auto_sync, #client_cert, #client_key, #default_media_type, #middleware, #proxy, #user_agent, #verify_ssl

Instance Method Summary collapse

Methods included from Profiles

#create_profile, #delete_profile, #profile, #profiles, #rename_profile, #update_profile

Methods included from Operations

#cancel_operation, #operation, #operations, #wait_for_operation

Methods included from Networks

#network, #networks

Methods included from Images

#create_image_alias, #create_image_from_container, #create_image_from_file, #create_image_from_remote, #create_image_from_snapshot, #create_image_from_url, #create_image_secret, #delete_image, #delete_image_alias, #export_image, #image, #image_alias, #image_aliases, #image_by_alias, #images, #rename_image_alias, #update_image, #update_image_alias

Methods included from Containers

#container, #container_state, #containers, #copy_container, #create_container, #create_snapshot, #delete_container, #delete_log, #delete_snapshot, #execute_command, #freeze_container, #init_migration, #log, #logs, #migrate, #pull_file, #push_file, #read_file, #rename_container, #rename_snapshot, #restart_container, #restore_snapshot, #snapshot, #snapshots, #start_container, #stop_container, #unfreeze_container, #update_container, #write_file

Methods included from Certificates

#certificate, #certificates, #create_certificate, #delete_certificate

Methods included from Connection

#agent, #delete, #get, #head, #last_response, #patch, #post, #put, #root

Methods included from Configurable

#configure, keys, #reset!, #same_options?

Constructor Details

#initialize(options = {}) ⇒ Client

Initialize a new Hyperkit client

Examples:

Use a client with default options

client = Hyperkit.client

Create a new client and override the api_endpoint

client = Hyperkit::Client.new(api_endpoint: "https://images.linuxcontainers.org:8443")

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/hyperkit/client.rb', line 63

def initialize(options = {})

  # Use options passed in, but fall back to module defaults
  Hyperkit::Configurable.keys.each do |key|

    # Allow user to explicitly override default values by passing 'key: nil'
    next if options.has_key?(key) && options[key].nil?

    if options.has_key?(key)
      value = options[key]
    else
      value = Hyperkit.instance_variable_get(:"@#{key}")
    end

    instance_variable_set(:"@#{key}", value)
  end

end