UNPKG

2.85 kBJavaScriptView Raw
1/**
2 * Copyright 2018 F5 Networks, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17'use strict';
18
19const INSTANCE_STATUS_BECOMING_PRIMARY = 'BECOMING_PRIMARY';
20const INSTANCE_STATUS_OK = 'OK';
21
22class 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
113module.exports = AutoscaleInstance;