Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then((promptSaysRebootRequired) => {
// Double check the db var. If either the prompt or the db var says
// reboot required, then reboot is required.
if (!promptSaysRebootRequired) {
return bigIp.list('/tm/sys/db/provision.action', null, cloudUtil.NO_RETRY)
.then(response => Promise.resolve(response.value === 'reboot'));
}
return Promise.resolve(true);
})
.then(rebootRequired => Promise.resolve(rebootRequired));
Object.keys(this.declaration.Common[deleteableClass]).forEach((itemToDelete) => {
// Special case for device groups
if (deleteableClass === 'DeviceGroup') {
if (READ_ONLY_DEVICE_GROUPS.indexOf(itemToDelete) === -1) {
classPromises.push(this.bigIp.cluster.deleteDeviceGroup(itemToDelete));
}
} else if (deleteableClass === 'RemoteAuthRole') {
const path = `${PATHS.AuthRemoteRole}/${itemToDelete}`;
classPromises.push(this.bigIp.delete(path, null, null, cloudUtil.NO_RETRY));
} else if (deleteableClass === 'RouteDomain' && itemToDelete === '0') {
// Route Domain 0 can't be deleted
} else {
const commonPrefix = deleteableClass === 'Trunk' ? '' : '~Common~';
const path = `${PATHS[deleteableClass]}/${commonPrefix}${itemToDelete}`;
classPromises.push(this.bigIp.delete(path, null, null, cloudUtil.NO_RETRY));
}
});
if (classPromises.length > 0) {
beforeEach(() => {
sinon.stub(dns, 'lookup').callsArg(1);
sinon.stub(cloudUtilMock, 'MEDIUM_RETRY').value(cloudUtilMock.NO_RETRY);
});
afterEach(() => {
promise = promise.then(() => this.bigIp.delete(
`${PATHS.Route}/~Common~${route.name}`,
null,
null,
cloudUtil.NO_RETRY
));
}
serverNames.forEach((server) => {
authPromises.push(
this.bigIp.delete(
`${PATHS.AuthRadiusServer}/~Common~${server}`,
null, null, cloudUtil.NO_RETRY
)
);
});
}
function isDhcpRunning() {
return this.bigIp.list('/tm/sys/service/dhclient/stats', undefined, cloudUtil.NO_RETRY)
.then((dhcpStats) => {
if (dhcpStats.apiRawValues
&& dhcpStats.apiRawValues.apiAnonymous
&& dhcpStats.apiRawValues.apiAnonymous.indexOf('running') !== -1) {
return Promise.resolve();
}
let message;
if (dhcpStats.apiRawValues && dhcpStats.apiRawValues.apiAnonymous) {
message = `dhclient status is ${dhcpStats.apiRawValues.apiAnonymous}`;
} else {
message = 'Unable to read dhclient status';
}
return Promise.reject(new Error(message));
});
}
.then(() => {
return masterBigIp.ready(cloudUtil.NO_RETRY);
})
.then(() => {
Object.keys(this.declaration.Common[classKey]).forEach((itemKey) => {
const path = `${PATHS[classKey]}/~Common~${itemKey}`;
promises.push(this.bigIp.delete(path, null, null, cloudUtil.NO_RETRY));
});
});