|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// --------------------------------------------------------------------- |
|
4
|
|
|
// |
|
5
|
|
|
// Copyright (C) 2018-2024 Artem Rodygin |
|
6
|
|
|
// |
|
7
|
|
|
// You should have received a copy of the MIT License along with |
|
8
|
|
|
// this file. If not, see <https://opensource.org/licenses/MIT>. |
|
9
|
|
|
// |
|
10
|
|
|
// --------------------------------------------------------------------- |
|
11
|
|
|
|
|
12
|
|
|
namespace Linode\LinodeInstances; |
|
13
|
|
|
|
|
14
|
|
|
use Linode\Entity; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Configuration profile associated with a Linode. |
|
18
|
|
|
* |
|
19
|
|
|
* @property int $id The ID of this Config. |
|
20
|
|
|
* @property string $label The Config's label is for display purposes only. |
|
21
|
|
|
* @property string $kernel A Kernel ID to boot a Linode with. Here are examples of commonly-used kernels: |
|
22
|
|
|
* * `linode/latest-64bit` (default): Our latest kernel at the time of instance |
|
23
|
|
|
* boot/reboot. |
|
24
|
|
|
* * `linode/grub2`: The upstream distribution-supplied kernel that is installed on |
|
25
|
|
|
* the primary disk, or a custom kernel if installed. |
|
26
|
|
|
* * `linode/direct-disk`: The MBR (Master Boot Record) of the primary disk/root |
|
27
|
|
|
* device, used instead of a Linux kernel. |
|
28
|
|
|
* For a complete list of options, use the Kernels List command. |
|
29
|
|
|
* @property null|string $comments Optional field for arbitrary User comments on this Config. |
|
30
|
|
|
* @property int $memory_limit Defaults to the total RAM of the Linode. |
|
31
|
|
|
* @property string $run_level Defines the state of your Linode after booting. Defaults to `default`. |
|
32
|
|
|
* @property string $virt_mode Controls the virtualization mode. Defaults to `paravirt`. |
|
33
|
|
|
* * `paravirt` is suitable for most cases. Linodes running in paravirt mode |
|
34
|
|
|
* share some qualities with the host, ultimately making it run faster since |
|
35
|
|
|
* there is less transition between it and the host. |
|
36
|
|
|
* * `fullvirt` affords more customization, but is slower because 100% of the VM |
|
37
|
|
|
* is virtualized. |
|
38
|
|
|
* @property LinodeConfigInterface[] $interfaces An array of Network Interfaces to add to this Linode's Configuration Profile. At |
|
39
|
|
|
* least one and up to three Interface objects can exist in this array. The position |
|
40
|
|
|
* in the array determines which of the Linode's network Interfaces is configured: |
|
41
|
|
|
* - First 0]: eth0 |
|
42
|
|
|
* - Second [1]: eth1 |
|
43
|
|
|
* - Third [2]: eth2 |
|
44
|
|
|
* When updating a Linode's Interfaces, *each Interface must be redefined*. An empty |
|
45
|
|
|
* `interfaces` array results in a default `public` type Interface configuration |
|
46
|
|
|
* only. |
|
47
|
|
|
* If no public Interface is configured, public IP addresses are still assigned to |
|
48
|
|
|
* the Linode but will not be usable without manual configuration. |
|
49
|
|
|
* **Note:** Changes to Linode Interface configurations can be enabled by rebooting |
|
50
|
|
|
* the Linode. |
|
51
|
|
|
* `vpc` details |
|
52
|
|
|
* See the [VPC documentation guide for its specifications and limitations. |
|
53
|
|
|
* `vlan` details |
|
54
|
|
|
* - Only Next Generation Network (NGN) data centers support VLANs. Use the Regions |
|
55
|
|
|
* (/regions) endpoint to view the capabilities of data center regions. If a VLAN is |
|
56
|
|
|
* attached to your Linode and you attempt to migrate or clone it to a non-NGN data |
|
57
|
|
|
* center, the migration or cloning will not initiate. If a Linode cannot be migrated |
|
58
|
|
|
* or cloned because of an incompatibility, you will be prompted to select a |
|
59
|
|
|
* different data center or contact support. |
|
60
|
|
|
* - See the VLANs Overview guide to view additional specifications and limitations. |
|
61
|
|
|
* @property Helpers $helpers Helpers enabled when booting to this Linode Config. |
|
62
|
|
|
* @property Devices $devices A dictionary of device disks to use as a device map in a Linode's configuration |
|
63
|
|
|
* profile. |
|
64
|
|
|
* * An empty device disk dictionary or a dictionary with empty values for device |
|
65
|
|
|
* slots is allowed. |
|
66
|
|
|
* * If no devices are specified, booting from this configuration will hold until a |
|
67
|
|
|
* device exists that allows the boot process to start. |
|
68
|
|
|
* @property string $root_device The root device to boot. |
|
69
|
|
|
* * If no value or an invalid value is provided, root device will default to |
|
70
|
|
|
* `/dev/sda`. |
|
71
|
|
|
* * If the device specified at the root device location is not mounted, the Linode |
|
72
|
|
|
* will not boot until a device is mounted. |
|
73
|
|
|
*/ |
|
74
|
|
|
class LinodeConfig extends Entity |
|
75
|
|
|
{ |
|
76
|
|
|
// Available fields. |
|
77
|
|
|
public const FIELD_ID = 'id'; |
|
78
|
|
|
public const FIELD_LABEL = 'label'; |
|
79
|
|
|
public const FIELD_KERNEL = 'kernel'; |
|
80
|
|
|
public const FIELD_COMMENTS = 'comments'; |
|
81
|
|
|
public const FIELD_MEMORY_LIMIT = 'memory_limit'; |
|
82
|
|
|
public const FIELD_RUN_LEVEL = 'run_level'; |
|
83
|
|
|
public const FIELD_VIRT_MODE = 'virt_mode'; |
|
84
|
|
|
public const FIELD_INTERFACES = 'interfaces'; |
|
85
|
|
|
public const FIELD_HELPERS = 'helpers'; |
|
86
|
|
|
public const FIELD_DEVICES = 'devices'; |
|
87
|
|
|
public const FIELD_ROOT_DEVICE = 'root_device'; |
|
88
|
|
|
|
|
89
|
|
|
// `FIELD_RUN_LEVEL` values. |
|
90
|
|
|
public const RUN_LEVEL_DEFAULT = 'default'; |
|
91
|
|
|
public const RUN_LEVEL_SINGLE = 'single'; |
|
92
|
|
|
public const RUN_LEVEL_BINBASH = 'binbash'; |
|
93
|
|
|
|
|
94
|
|
|
// `FIELD_VIRT_MODE` values. |
|
95
|
|
|
public const VIRT_MODE_PARAVIRT = 'paravirt'; |
|
96
|
|
|
public const VIRT_MODE_FULLVIRT = 'fullvirt'; |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @codeCoverageIgnore This method was autogenerated. |
|
100
|
|
|
*/ |
|
101
|
|
|
public function __get(string $name): mixed |
|
102
|
|
|
{ |
|
103
|
|
|
return match ($name) { |
|
104
|
|
|
self::FIELD_INTERFACES => array_map(fn ($data) => new LinodeConfigInterface($this->client, $data), $this->data[$name]), |
|
105
|
|
|
self::FIELD_HELPERS => new Helpers($this->client, $this->data[$name]), |
|
106
|
|
|
self::FIELD_DEVICES => new Devices($this->client, $this->data[$name]), |
|
107
|
|
|
default => parent::__get($name), |
|
108
|
|
|
}; |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|