Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ public void setName(String name) {

@Override
public String getValue() {
if(isEncrypted()) {
if (isEncrypted()) {
return DBEncryptionUtil.decrypt(value);
} else {
return value;
}
}

public void setValue(String value) {
if(isEncrypted()) {
if (isEncrypted()) {
this.value = DBEncryptionUtil.encrypt(value);
} else {
this.value = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public interface ConsoleProxyManager extends Manager, ConsoleProxyService {
int DEFAULT_PROXY_VM_RAMSIZE = 1024; // 1G
int DEFAULT_PROXY_VM_CPUMHZ = 500; // 500 MHz

int DEFAULT_PROXY_CMD_PORT = 8001;
int DEFAULT_PROXY_VNC_PORT = 0;
int DEFAULT_PROXY_URL_PORT = 80;
int DEFAULT_PROXY_SESSION_TIMEOUT = 300000; // 5 minutes
Expand All @@ -54,7 +53,8 @@ public interface ConsoleProxyManager extends Manager, ConsoleProxyService {
"If true, noVNC console will be default console for virtual machines", false, ConfigKey.Scope.Zone, null);

ConfigKey<Boolean> NoVncConsoleSourceIpCheckEnabled = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, Boolean.class, "novnc.console.sourceip.check.enabled", "false",
"If true, The source IP to access novnc console must be same as the IP in request to management server for console URL. Needs to reconnect CPVM to management server when this changes (via restart CPVM, or management server, or cloud service in CPVM)", false);
"If true, The source IP to access novnc console must be same as the IP in request to management server for console URL. Needs to reconnect CPVM to management server" +
" when this changes (via restart CPVM, or management server, or cloud service in CPVM)", false);

ConfigKey<Boolean> NoVncConsoleShowDot = new ConfigKey<>(Boolean.class, "novnc.console.show.dot", ConfigKey.CATEGORY_ADVANCED, "true",
"If true, in noVNC console a dot cursor will be shown when the remote server provides no local cursor, or provides a fully-transparent (invisible) cursor.",
Expand Down Expand Up @@ -87,12 +87,13 @@ public interface ConsoleProxyManager extends Manager, ConsoleProxyService {
ConfigKey<Integer> ConsoleProxyLaunchMax = new ConfigKey<>(Integer.class, "consoleproxy.launch.max", "Console Proxy", "10",
"maximum number of console proxy instances per zone can be launched", false, ConfigKey.Scope.Zone, null);

String consoleProxyManagementStates = Arrays.stream(com.cloud.consoleproxy.ConsoleProxyManagementState.values()).map(Enum::name).collect(Collectors.joining(","));
ConfigKey<String> ConsoleProxyServiceManagementState = new ConfigKey<String>(ConfigKey.CATEGORY_ADVANCED, String.class, "consoleproxy.management.state", com.cloud.consoleproxy.ConsoleProxyManagementState.Auto.toString(),
"console proxy service management state", false, ConfigKey.Kind.Select, consoleProxyManagementStates);
String consoleProxyServiceManagementStates = Arrays.stream(com.cloud.consoleproxy.ConsoleProxyManagementState.values()).map(Enum::name).collect(Collectors.joining(","));

ConfigKey<String> ConsoleProxyManagementLastState = new ConfigKey<String>(ConfigKey.CATEGORY_ADVANCED, String.class, "consoleproxy.management.state.last", com.cloud.consoleproxy.ConsoleProxyManagementState.Auto.toString(),
"last console proxy service management state", false, ConfigKey.Kind.Select, consoleProxyManagementStates);
ConfigKey<String> ConsoleProxyServiceManagementState = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, String.class, "consoleproxy.management.state", com.cloud.consoleproxy.ConsoleProxyManagementState.Auto.toString(),
"console proxy service management state", true, ConfigKey.Kind.Select, consoleProxyServiceManagementStates);

ConfigKey<String> ConsoleProxyServiceManagementLastState = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, String.class, "consoleproxy.management.state.last", com.cloud.consoleproxy.ConsoleProxyManagementState.Auto.toString(),
"last console proxy service management state", true, ConfigKey.Kind.Select, consoleProxyServiceManagementStates);

ConfigKey<String> ConsoleProxyVmUserData = new ConfigKey<>(String.class, "console.proxy.vm.userdata",
ConfigKey.CATEGORY_ADVANCED, "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -988,41 +988,43 @@ public boolean stopProxy(long proxyVmId) {

@Override
@DB
public void setManagementState(final ConsoleProxyManagementState state) {
public void setManagementState(final ConsoleProxyManagementState newState) {
try {
final ConsoleProxyManagementState lastState = getManagementState();
if (lastState == null) {
final ConsoleProxyManagementState currentState = getManagementState();
if (currentState == null) {
return;
}

if (lastState != state) {
if (currentState != newState) {
logger.debug("Updating console proxy management state config to new state: {}, it's current state is {} and last management state config to {}.", newState, currentState, currentState);
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
configurationDao.update(ConsoleProxyManagementLastState.key(), ConsoleProxyManagementLastState.category(), lastState.toString());
configurationDao.update(ConsoleProxyServiceManagementState.key(), ConsoleProxyServiceManagementState.category(), state.toString());
configurationDao.update(ConsoleProxyServiceManagementLastState.key(), ConsoleProxyServiceManagementLastState.category(), currentState.toString());
configurationDao.update(ConsoleProxyServiceManagementState.key(), ConsoleProxyServiceManagementState.category(), newState.toString());
}
});
} else {
logger.debug("Console proxy management state is already set to {}, no need to update.", newState);
}
} catch (Exception e) {
logger.error(String.format("Unable to set console proxy management state to [%s] due to [%s].", state, e.getMessage()), e);
logger.error("Unable to update console proxy management state to [{}] due to [{}].", newState, e.getMessage(), e);
}
}

@Override
public ConsoleProxyManagementState getManagementState() {
String configKey = ConsoleProxyServiceManagementState.key();
String value = ConsoleProxyServiceManagementState.value();

if (value != null) {
ConsoleProxyManagementState state = ConsoleProxyManagementState.valueOf(value);
String stateConfigKey = ConsoleProxyServiceManagementState.key();
String stateConfigValue = ConsoleProxyServiceManagementState.value();

if (stateConfigValue != null) {
ConsoleProxyManagementState state = ConsoleProxyManagementState.valueOf(stateConfigValue);
if (state != null) {
return state;
}
}

logger.error(String.format("Value [%s] set in global configuration [%s] is not a valid console proxy management state.", value, configKey));
logger.error("Console proxy management state value is null in the global configuration [{}].", stateConfigKey);
return null;
}

Expand All @@ -1037,26 +1039,26 @@ public void resumeLastManagementState() {
}

if (lastState != state) {
logger.debug("Resuming console proxy management state to last state {}, current state is {}.", lastState, state);
configurationDao.update(ConsoleProxyServiceManagementState.key(), ConsoleProxyServiceManagementState.category(), lastState.toString());
}
} catch (Exception e) {
logger.error(String.format("Unable to resume last management state due to [%s].", e.getMessage()), e);
logger.error("Unable to resume last management state due to [{}].", e.getMessage(), e);
}
}

private ConsoleProxyManagementState getLastManagementState() {
String configKey = ConsoleProxyManagementLastState.key();
String value = ConsoleProxyManagementLastState.value();
String lastStateConfigKey = ConsoleProxyServiceManagementLastState.key();
String lastStateConfigValue = ConsoleProxyServiceManagementLastState.value();

if (value != null) {
ConsoleProxyManagementState state = ConsoleProxyManagementState.valueOf(value);

if (state != null) {
return state;
if (lastStateConfigValue != null) {
ConsoleProxyManagementState lastState = ConsoleProxyManagementState.valueOf(lastStateConfigValue);
if (lastState != null) {
return lastState;
}
}

logger.error(String.format("Value [%s] set in global configuration [%s] is not a valid console proxy management state.", value, configKey));
logger.error("Console proxy last management state value is null in the global configuration [{}].", lastStateConfigKey);
return null;
}

Expand All @@ -1074,7 +1076,7 @@ public boolean rebootProxy(long proxyVmId) {

if (answer != null && answer.getResult()) {
if (logger.isDebugEnabled()) {
logger.debug("Successfully reboot console proxy " + proxy.getHostName());
logger.debug("Successfully reboot console proxy {}", proxy.getHostName());
}

SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this,
Expand All @@ -1083,7 +1085,7 @@ public boolean rebootProxy(long proxyVmId) {
return true;
} else {
if (logger.isDebugEnabled()) {
logger.debug("failed to reboot console proxy : " + proxy.getHostName());
logger.debug("Failed to reboot console proxy : {}", proxy.getHostName());
}

return false;
Expand Down Expand Up @@ -1113,7 +1115,7 @@ public boolean destroyProxy(long vmId) {

return true;
} catch (ResourceUnavailableException e) {
logger.warn(String.format("Unable to destroy console proxy [%s] due to [%s].", proxy, e.getMessage()), e);
logger.warn("Unable to destroy console proxy [{}] due to [{}].", proxy, e.getMessage(), e);
return false;
}
}
Expand Down Expand Up @@ -1590,7 +1592,7 @@ public String getConfigComponentName() {
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {ConsoleProxySslEnabled, NoVncConsoleDefault, NoVncConsoleSourceIpCheckEnabled, ConsoleProxyServiceOffering,
ConsoleProxyCapacityStandby, ConsoleProxyCapacityScanInterval, ConsoleProxyRestart, ConsoleProxyUrlDomain, ConsoleProxySessionMax, ConsoleProxySessionTimeout, ConsoleProxyDisableRpFilter, ConsoleProxyLaunchMax,
ConsoleProxyManagementLastState, ConsoleProxyServiceManagementState, NoVncConsoleShowDot,
ConsoleProxyServiceManagementLastState, ConsoleProxyServiceManagementState, NoVncConsoleShowDot,
ConsoleProxyVmUserData};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4975,8 +4975,8 @@ public String uploadCertificate(final UploadCustomCertificateCmd cmd) {
if (cmd.getPrivateKey() != null) {
_ksMgr.saveCertificate(ConsoleProxyManager.CERTIFICATE_NAME, certificate, key, domainSuffix);

// Reboot ssvm here since private key is present - meaning server cert being passed
final List<SecondaryStorageVmVO> alreadyRunning = _secStorageVmDao.getSecStorageVmListInStates(null, State.Running, State.Migrating, State.Starting);
logger.debug("Reboot SSVMs in Running, Migrating, Starting states since private key is present - meaning server cert being passed");
for (final SecondaryStorageVmVO ssVmVm : alreadyRunning) {
_secStorageVmMgr.rebootSecStorageVm(ssVmVm.getId());
}
Expand Down
Loading