|
52 | 52 | import org.apache.log4j.Logger; |
53 | 53 |
|
54 | 54 | import com.cloud.agent.AgentManager; |
| 55 | +import com.cloud.agent.api.Answer; |
55 | 56 | import com.cloud.agent.api.GetVncPortAnswer; |
56 | 57 | import com.cloud.agent.api.GetVncPortCommand; |
| 58 | +import com.cloud.agent.api.proxy.UpdateCertificateCommand; |
57 | 59 | import com.cloud.agent.api.storage.CopyVolumeAnswer; |
58 | 60 | import com.cloud.agent.api.storage.CopyVolumeCommand; |
59 | 61 | import com.cloud.alert.AlertManager; |
|
180 | 182 | import com.cloud.exception.InternalErrorException; |
181 | 183 | import com.cloud.exception.InvalidParameterValueException; |
182 | 184 | import com.cloud.exception.NetworkRuleConflictException; |
| 185 | +import com.cloud.exception.OperationTimedoutException; |
183 | 186 | import com.cloud.exception.PermissionDeniedException; |
184 | 187 | import com.cloud.exception.ResourceAllocationException; |
185 | 188 | import com.cloud.exception.StorageUnavailableException; |
@@ -6866,30 +6869,35 @@ public String getVersion(){ |
6866 | 6869 | @Override |
6867 | 6870 | public boolean uploadCertificate(UploadCustomCertificateCmd cmd) { |
6868 | 6871 | String certificatePath = cmd.getPath(); |
6869 | | - boolean uploadStatus = _certDao.persistCustomCertToDb(certificatePath); |
| 6872 | + Long certVOId = _certDao.persistCustomCertToDb(certificatePath);//0 implies failure |
6870 | 6873 |
|
6871 | | - if (uploadStatus) { |
| 6874 | + if (certVOId!=null && certVOId!=0) { |
6872 | 6875 | //certficate uploaded to db successfully |
6873 | 6876 |
|
6874 | 6877 | //get a list of all hosts from host table |
6875 | 6878 | List<HostVO> hosts = _hostDao.listAll(); |
6876 | 6879 |
|
6877 | | - List<VMInstanceVO> consoleProxyList = new ArrayList<VMInstanceVO>(); |
| 6880 | + List<HostVO> consoleProxyList = new ArrayList<HostVO>(); |
6878 | 6881 |
|
6879 | 6882 | //find the console proxies, and send the command to them |
6880 | 6883 | for(HostVO host : hosts) { |
6881 | | - //find corresponding vms for this host |
6882 | | - List<VMInstanceVO> vmList = _vmInstanceDao.listByHostId(host.getId()); |
6883 | | - |
6884 | | - for(VMInstanceVO vm : vmList){ |
6885 | | - if(VirtualMachineName.isValidConsoleProxyName(vm.getInstanceName())){ |
6886 | | - consoleProxyList.add(vm); |
6887 | | - } |
| 6884 | + if(host.getType().equals(com.cloud.host.Host.Type.ConsoleProxy)){ |
| 6885 | + consoleProxyList.add(host); |
6888 | 6886 | } |
6889 | 6887 | } |
6890 | 6888 |
|
6891 | | - //now restart each of these proxies |
6892 | | - //restart will |
| 6889 | + for(HostVO consoleProxy : consoleProxyList){ |
| 6890 | + //now send a command to each console proxy |
| 6891 | + UpdateCertificateCommand certCmd = new UpdateCertificateCommand(_certDao.findById(certVOId).getCertificate()); |
| 6892 | + try { |
| 6893 | + Answer updateCertAns = _agentMgr.send(consoleProxy.getId(), certCmd); |
| 6894 | + int a = 30; |
| 6895 | + } catch (AgentUnavailableException e) { |
| 6896 | + s_logger.warn("Unable to send command to the console proxy resource", e); |
| 6897 | + } catch (OperationTimedoutException e) { |
| 6898 | + s_logger.warn("Unable to send command to the console proxy resource", e); |
| 6899 | + } |
| 6900 | + } |
6893 | 6901 | } |
6894 | 6902 |
|
6895 | 6903 | return false; |
|
0 commit comments