|
1 | 1 | module Brightbox |
2 | 2 | class DetailedServer < Server |
3 | 3 | def to_row |
4 | | - row_attributes = attributes |
| 4 | + attributes.tap do |attrs| |
| 5 | + attrs[:compatibility_mode] = attrs["compatibility_mode"] |
5 | 6 |
|
6 | | - row_attributes[:compatibility_mode] = row_attributes["compatibility_mode"] |
7 | | - |
8 | | - if server_type |
9 | | - row_attributes[:type] = server_type["id"] |
10 | | - row_attributes[:type_handle] = server_type["handle"] |
11 | | - row_attributes[:type_name] = server_type["name"] |
12 | | - row_attributes[:ram] = server_type["ram"] |
13 | | - row_attributes[:cores] = server_type["cores"] |
14 | | - row_attributes[:disk] = server_type["disk_size"].to_i |
15 | | - end |
16 | | - |
17 | | - if image |
18 | | - row_attributes[:image_name] = image.name |
19 | | - row_attributes[:arch] = image.arch |
20 | | - row_attributes[:image_username] = image.username |
21 | | - end |
| 7 | + if server_type |
| 8 | + attrs[:type] = server_type["id"] |
| 9 | + attrs[:type_handle] = server_type["handle"] |
| 10 | + attrs[:type_name] = server_type["name"] |
| 11 | + attrs[:ram] = server_type["ram"] |
| 12 | + attrs[:cores] = server_type["cores"] |
| 13 | + attrs[:disk] = server_type["disk_size"].to_i |
| 14 | + end |
22 | 15 |
|
23 | | - row_attributes[:private_ips] = interfaces.map { |i| i["ipv4_address"] }.join(", ") |
24 | | - row_attributes[:ipv6_address] = interfaces.map { |i| i["ipv6_address"] }.join(", ") |
| 16 | + if image |
| 17 | + attrs[:image_name] = image.name |
| 18 | + attrs[:arch] = image.arch |
| 19 | + attrs[:image_username] = image.username |
| 20 | + end |
25 | 21 |
|
26 | | - row_attributes[:cloud_ip_ids] = cloud_ips.map { |i| i["id"] }.join(", ") |
27 | | - row_attributes[:cloud_ipv4s] = cloud_ips.map { |i| i["public_ipv4"] }.join(", ") |
28 | | - row_attributes[:cloud_ipv6s] = cloud_ips.map { |i| i["public_ipv6"] }.join(", ") |
29 | | - row_attributes[:snapshots] = snapshots.map { |i| i["id"] }.join(", ") |
| 22 | + attrs[:private_ips] = interfaces.map { |i| i["ipv4_address"] }.join(", ") |
| 23 | + attrs[:ipv6_address] = interfaces.map { |i| i["ipv6_address"] }.join(", ") |
30 | 24 |
|
31 | | - if server_groups |
32 | | - row_attributes[:server_groups] = server_groups.map { |sg| sg["id"] }.join(", ") |
33 | | - end |
| 25 | + attrs[:cloud_ip_ids] = cloud_ips.map { |i| i["id"] }.join(", ") |
| 26 | + attrs[:cloud_ipv4s] = cloud_ips.map { |i| i["public_ipv4"] }.join(", ") |
| 27 | + attrs[:cloud_ipv6s] = cloud_ips.map { |i| i["public_ipv6"] }.join(", ") |
| 28 | + attrs[:snapshots] = snapshots.map { |i| i["id"] }.join(", ") |
34 | 29 |
|
35 | | - row_attributes[:volumes] = volume_ids if volumes |
| 30 | + if server_groups |
| 31 | + attrs[:server_groups] = server_groups.map { |sg| sg["id"] }.join(", ") |
| 32 | + end |
36 | 33 |
|
37 | | - row_attributes |
| 34 | + attrs[:volumes] = volume_ids if volumes |
| 35 | + end.to_h |
38 | 36 | end |
39 | 37 |
|
40 | 38 | def volume_ids |
|
0 commit comments