Class: Tiktalik::Computing::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/tiktalik/computing/instance.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#initialize

Constructor Details

This class inherits a constructor from Tiktalik::Object

Instance Attribute Details

#actionsObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def actions
  @actions
end

#default_passwordObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def default_password
  @default_password
end

#gross_cost_per_hourObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def gross_cost_per_hour
  @gross_cost_per_hour
end

#hostnameObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def hostname
  @hostname
end

#interfacesObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def interfaces
  @interfaces
end

#ownerObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def owner
  @owner
end

#runningObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def running
  @running
end

#service_nameObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def service_name
  @service_name
end

#stateObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def state
  @state
end

#uuidObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def uuid
  @uuid
end

#vpsimageObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def vpsimage
  @vpsimage
end

#vpsimage_uuidObject (readonly)

String



9
10
11
# File 'lib/tiktalik/computing/instance.rb', line 9

def vpsimage_uuid
  @vpsimage_uuid
end

Class Method Details

.all(params = {}) ⇒ Object

List of user virtual machines.

Parameters:

  • params (Hash) (defaults to: {})

    Params for results

Options Hash (params):

  • :actions (Boolean)

    Include list of recent operations if true.

  • :vpsimage (Boolean)

    Include details about source image if true.

  • :cost (Boolean)

    Include current cost per hour for each instance if true.



29
30
31
32
# File 'lib/tiktalik/computing/instance.rb', line 29

def self.all(params = {})
  results = request(:get, '/computing/instance', params)
  results.collect { |result| new(result) }
end

.create(params = {}) ⇒ Object

Create a new virtual machine.

Parameters:

  • params (Hash) (defaults to: {})

    Params for instance

Options Hash (params):

  • :image_uuid (String)

    UID of disk image that should be used(required)

  • :size (String)

    Size of instance in Units(required)

  • :hostname (String)

    Hostname set at installation time(required)

  • :networks (Array)

    Networks to attach, each one as “#uuid” from Network model.



42
43
44
45
46
# File 'lib/tiktalik/computing/instance.rb', line 42

def self.create(params = {})
  require_params(params, :image_uuid, :size, :hostname)
  result = request(:post, '/computing/instance', params)
  new(result)
end

.find(uuid) ⇒ Object

Get virtual machine details.

Parameters:

  • uuid (String)

    UUID of instance



51
52
53
54
# File 'lib/tiktalik/computing/instance.rb', line 51

def self.find(uuid)
  result = request(:get, "/computing/instance/#{uuid}")
  new(result)
end

Instance Method Details

#backupObject

Do “Backup” of virtual machine. VPS need to be stopped in order to create its backup.



99
100
101
102
# File 'lib/tiktalik/computing/instance.rb', line 99

def backup
  request(:post, "/computing/instance/#{@uuid}/backup")
  true
end

#build_interface(params = {}) ⇒ Object

Create virtual machine network interface.

Parameters:

  • params (Hash) (defaults to: {})

    Params for interface

Options Hash (params):

  • :network_uuid (String)

    Network UUID. The interface will be assigned an address in this network(required)

  • :seq (String)

    Interface number, eg. ‘3’ maps to eth3(required)



68
69
70
71
72
# File 'lib/tiktalik/computing/instance.rb', line 68

def build_interface(params = {})
  require_params(params, :network_uuid, :seq)
  result = request(:post, "/computing/instance/#{@uuid}/interface", params)
  VPSNetInterface.new(result)
end

#destroyObject

Delete instance.



57
58
59
60
# File 'lib/tiktalik/computing/instance.rb', line 57

def destroy
  request(:delete, "/computing/instance/#{@uuid}")
  true
end

#force_stopObject

Force “Shutdown” operation on virtual machine.



93
94
95
96
# File 'lib/tiktalik/computing/instance.rb', line 93

def force_stop
  request(:post, "/computing/instance/#{@uuid}/force_stop")
  true
end

#installObject

Call “Install” operation on virtual machine.



75
76
77
78
# File 'lib/tiktalik/computing/instance.rb', line 75

def install
  request(:post, "/computing/instance/#{@uuid}/install")
  true
end

#startObject

Call “Boot” or “Start” operation on virtual machine.



81
82
83
84
# File 'lib/tiktalik/computing/instance.rb', line 81

def start
  request(:post, "/computing/instance/#{@uuid}/start")
  true
end

#stopObject

Call “Shutdown” operation on virtual machine.



87
88
89
90
# File 'lib/tiktalik/computing/instance.rb', line 87

def stop
  request(:post, "/computing/instance/#{@uuid}/stop")
  true
end