Class: Brightbox::DetailedServer

Inherits:
Server
  • Object
show all
Defined in:
lib/brightbox-cli/detailed_server.rb

Instance Attribute Summary

Attributes inherited from Api

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Server

#activate_console, all, #attributes, create, create_servers, #deleted?, #destroy, get, #ipv6_fqdn, require_account?, #update

Methods inherited from Api

#attributes, cache_all!, cached_get, conn, #created_on, #exists?, find, find_all_or_warn, find_by_handle, find_or_call, #fog_attributes, #fog_model, #initialize, klass_name, #method_missing, require_account?, #respond_to_missing?, #to_s

Constructor Details

This class inherits a constructor from Brightbox::Api

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Brightbox::Api

Class Method Details

.default_field_orderObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/brightbox-cli/detailed_server.rb', line 48

def self.default_field_order
  %i[
    id
    status
    locked
    name
    created_at
    deleted_at
    zone
    type
    type_name
    type_handle
    ram
    cores
    disk
    disk_encrypted
    compatibility_mode
    image
    image_name
    image_username
    arch
    private_ips
    ipv6_address
    hostname
    fqdn
    public_hostname
    ipv6_hostname
    cloud_ip_ids
    cloud_ipv4s
    cloud_ipv6s
    snapshots
    server_groups
    volumes
  ]
end

Instance Method Details

#to_rowObject



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
# File 'lib/brightbox-cli/detailed_server.rb', line 3

def to_row
  attributes.tap do |attrs|
    attrs[:compatibility_mode] = attrs["compatibility_mode"]

    if server_type
      attrs[:type] = server_type["id"]
      attrs[:type_handle] = server_type["handle"]
      attrs[:type_name] = server_type["name"]
      attrs[:ram] = server_type["ram"]
      attrs[:cores] = server_type["cores"]
      attrs[:disk] = server_type["disk_size"].to_i
    end

    if image
      attrs[:image_name] = image.name
      attrs[:arch] = image.arch
      attrs[:image_username] = image.username
    end

    attrs[:private_ips] = interfaces.map { |i| i["ipv4_address"] }.join(", ")
    attrs[:ipv6_address] = interfaces.map { |i| i["ipv6_address"] }.join(", ")

    attrs[:cloud_ip_ids] = cloud_ips.map { |i| i["id"] }.join(", ")
    attrs[:cloud_ipv4s] = cloud_ips.map { |i| i["public_ipv4"] }.join(", ")
    attrs[:cloud_ipv6s] = cloud_ips.map { |i| i["public_ipv6"] }.join(", ")
    attrs[:snapshots] = snapshots.map { |i| i["id"] }.join(", ")

    if server_groups
      attrs[:server_groups] = server_groups.map { |sg| sg["id"] }.join(", ")
    end

    attrs[:volumes] = volume_ids if volumes
  end.to_h
end

#volume_idsObject



38
39
40
41
42
43
44
45
46
# File 'lib/brightbox-cli/detailed_server.rb', line 38

def volume_ids
  volumes.map do |vol|
    if vol["boot"] == true
      "*#{vol['id']}*"
    else
      vol["id"]
    end
  end.join(", ")
end