1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | 'use strict';
|
18 |
|
19 | const INSTANCE_STATUS_BECOMING_PRIMARY = 'BECOMING_PRIMARY';
|
20 | const INSTANCE_STATUS_OK = 'OK';
|
21 |
|
22 | class AutoscaleInstance {
|
23 | constructor() {
|
24 | this.privateIp = undefined;
|
25 | this.publicIp = undefined;
|
26 | this.mgmtIp = undefined;
|
27 | this.hostname = undefined;
|
28 | this.macAddress = undefined;
|
29 | this.machineId = undefined;
|
30 | this.isPrimary = false;
|
31 | this.providerVisible = true;
|
32 | this.status = INSTANCE_STATUS_OK;
|
33 | this.versionOk = true;
|
34 | this.external = false;
|
35 | this.version = undefined;
|
36 | this.lastBackup = new Date(1970, 1, 1).getTime();
|
37 | }
|
38 |
|
39 | static get INSTANCE_STATUS_BECOMING_PRIMARY() {
|
40 | return INSTANCE_STATUS_BECOMING_PRIMARY;
|
41 | }
|
42 |
|
43 | static get INSTANCE_STATUS_OK() {
|
44 | return INSTANCE_STATUS_OK;
|
45 | }
|
46 |
|
47 | setExternal(external) {
|
48 | this.external = typeof external === 'undefined' ? true : external;
|
49 | return this;
|
50 | }
|
51 |
|
52 | setHostname(hostname) {
|
53 | this.hostname = hostname;
|
54 | return this;
|
55 | }
|
56 |
|
57 | setMacAddress(macAddress) {
|
58 | this.macAddress = macAddress;
|
59 | return this;
|
60 | }
|
61 |
|
62 | setMachineId(machineId) {
|
63 | this.machineId = machineId;
|
64 | return this;
|
65 | }
|
66 |
|
67 | setIsPrimary(isPrimary) {
|
68 | this.isPrimary = typeof isPrimary === 'undefined' ? true : isPrimary;
|
69 | return this;
|
70 | }
|
71 |
|
72 | setLastBackup(date) {
|
73 | this.lastBackup = date || Date.now();
|
74 | return this;
|
75 | }
|
76 |
|
77 | setMgmtIp(mgmtIp) {
|
78 | this.mgmtIp = mgmtIp;
|
79 | return this;
|
80 | }
|
81 |
|
82 | setPrivateIp(privateIp) {
|
83 | this.privateIp = privateIp;
|
84 | return this;
|
85 | }
|
86 |
|
87 | setProviderVisible(providerVisible) {
|
88 | this.providerVisible = typeof providerVisible === 'undefined' ? true : providerVisible;
|
89 | return this;
|
90 | }
|
91 |
|
92 | setPublicIp(publicIp) {
|
93 | this.publicIp = publicIp;
|
94 | return this;
|
95 | }
|
96 |
|
97 | setStatus(status) {
|
98 | this.status = status;
|
99 | return this;
|
100 | }
|
101 |
|
102 | setVersion(version) {
|
103 | this.version = version;
|
104 | return this;
|
105 | }
|
106 |
|
107 | setVersionOk(versionOk) {
|
108 | this.versionOk = typeof versionOk === 'undefined' ? true : versionOk;
|
109 | return this;
|
110 | }
|
111 | }
|
112 |
|
113 | module.exports = AutoscaleInstance;
|