def setSSHAccess(self, url): """ Sets ssh access for this host from the managment server. """ self.message = "SUCCESS" self.status = "OK" self.rc = True strKey = None vdcAddress = None vdcPort = None vdcAddress, vdcPort = deployUtil.getAddress(url) if vdcAddress is not None: strKey = deployUtil.getAuthKeysFile(vdcAddress, vdcPort) if strKey is None: self.rc = False self.message = "Failed to retrieve server SSH key." else: self.message = "Failed to extract server address." self.rc = False if self.rc: if not deployUtil.handleSSHKey(strKey): self.rc = False self.message = "Failed to write server's SSH key." if not self.rc: self.status = "FAIL" self._xmlOutput('SetSSHAccess', self.status, None, None, self.message) return self.rc
def handle_ssh_key(host, port): import deployUtil ssh_result = False strKey = deployUtil.getAuthKeysFile(host, port) if strKey is not None: ssh_result = deployUtil.handleSSHKey(strKey) if ssh_result: printNlog("<BSTRAP component='RHEV_INSTALL' status='OK' message='RHEV-H ACCESSIBLE'/>") else: printNlog("<BSTRAP component='RHEV_INSTALL' status='FAIL' message='Host failed to download management server public-key.'/>") return ssh_result
def setSSHAccess(self, url, engine_ssh_key): """ Sets ssh access for this host from the managment server. """ self.message = "SUCCESS" self.status = "OK" self.rc = True strKey = None # TODO remove legacy if deployUtil.getBootstrapInterfaceVersion() == 1 and \ engine_ssh_key is None: vdcAddress = None vdcPort = None vdcAddress, vdcPort = deployUtil.getAddress(url) if vdcAddress is not None: strKey = deployUtil.getAuthKeysFile(vdcAddress, vdcPort) if strKey is None: self.rc = False self.message = "Failed to retrieve server SSH key." else: self.message = "Failed to extract server address." self.rc = False else: try: with open(engine_ssh_key) as key: strKey = key.read() except Exception as e: self.message = "Failed to read SSH key file " + str(e) self.rc = False if self.rc: if not deployUtil.handleSSHKey(strKey): self.rc = False self.message = "Failed to write server's SSH key." if not self.rc: self.status = "FAIL" self._xmlOutput('SetSSHAccess', self.status, None, None, self.message) return self.rc
def setSSHAccess(self, url, engine_ssh_key): """ Sets ssh access for this host from the managment server. """ self.message = "SUCCESS" self.status = "OK" self.rc = True strKey = None # TODO remove legacy if deployUtil.getBootstrapInterfaceVersion() == 1 and \ engine_ssh_key is None: vdcAddress = None vdcPort = None vdcAddress, vdcPort = deployUtil.getAddress(url) if vdcAddress is not None: strKey = deployUtil.getAuthKeysFile(vdcAddress, vdcPort) if strKey is None: self.rc = False self.message = "Failed to retrieve server SSH key." else: self.message = "Failed to extract server address." self.rc = False else: try: strKey = file(engine_ssh_key).read() except Exception as e: self.message = "Failed to read SSH key file " + str(e) self.rc = False if self.rc: if not deployUtil.handleSSHKey(strKey): self.rc = False self.message = "Failed to write server's SSH key." if not self.rc: self.status = "FAIL" self._xmlOutput('SetSSHAccess', self.status, None, None, self.message) return self.rc