def action(self): self.ncs.screen.setColor("BUTTON", "black", "red") self.ncs.screen.setColor("ACTBUTTON", "blue", "white") if self.root_password_1.value() != "" and self.root_password_2.value( ) != "" and self.root_password_1.value() == self.root_password_2.value( ): set_password(self.root_password_1.value(), "root") augtool("set", "/files/etc/ssh/sshd_config/PasswordAuthentication", "yes") dn = file('/dev/null', 'w+') subprocess.Popen(['/sbin/service', 'sshd', 'restart'], stdout=dn, stderr=dn) if len(self.rhevm_server.value()) > 0: deployUtil.nodeCleanup() if self.verify_rhevm_cert.selected(): if deployUtil.getRhevmCert(self.rhevm_server.value(), self.rhevm_server_port.value()): path, dontCare = deployUtil.certPaths('') fp = deployUtil.generateFingerPrint(path) approval = ButtonChoiceWindow( self.ncs.screen, "Certificate Fingerprint:", fp, buttons=['Approve', 'Reject']) if 'reject' == approval: ButtonChoiceWindow(self.ncs.screen, "Fingerprint rejected", "RHEV-M Configuration Failed", buttons=['Ok']) return False else: ovirt_store_config(path) self.ncs.reset_screen_colors() else: ButtonChoiceWindow(self.ncs.screen, "RHEV-M Configuration", "Failed downloading RHEV-M certificate", buttons=['Ok']) self.ncs.reset_screen_colors() # Stopping vdsm-reg may fail but its ok - its in the case when the menus are run after installation deployUtil._logExec([constants.EXT_SERVICE, 'vdsm-reg', 'stop']) if write_vdsm_config(self.rhevm_server.value(), self.rhevm_server_port.value()): deployUtil._logExec( [constants.EXT_SERVICE, 'vdsm-reg', 'start']) ButtonChoiceWindow(self.ncs.screen, "RHEV-M Configuration", "RHEV-M Configuration Successfully Updated", buttons=['Ok']) self.ncs.reset_screen_colors() return True else: ButtonChoiceWindow(self.ncs.screen, "RHEV-M Configuration", "RHEV-M Configuration Failed", buttons=['Ok']) self.ncs.reset_screen_colors() return False
def imvp_apply(self, obj): from ocsetup.ocsetup import ocs log("enter imvp apply %s") imvp_server_address = ocs.imvp_server_addr_val_Entry.get_text() imvp_server_port = ocs.imvp_serve_port_val_Entry.get_text() compatPort, sslPort = compatiblePort(imvp_server_port) if len(imvp_server_address) > 0: deployUtil.nodeCleanup() if not isHostReachable(host=imvp_server_address, port=imvp_server_port, ssl=sslPort, timeout=TIMEOUT_FIND_HOST_SEC): if compatPort is None: # Try one more time with SSL=False if not isHostReachable(host=imvp_server_address, port=imvp_server_port, ssl=False, timeout=TIMEOUT_FIND_HOST_SEC): msgConn = "Can't connect to oVirt Engine in the specific" \ " port %s" % enginePort resp_id = ConfirmDialog(message=msgConn).run_and_close() return False else: msgConn = "Can't connect to oVirt Engine port %s," \ " trying compatible port %s" % \ (enginePort, compatPort) resp_id = ConfirmDialog(message=msgConn).run_and_close() if not isHostReachable(host=imvp_server_address, port=compatPort, ssl=sslPort, timeout=TIMEOUT_FIND_HOST_SEC): msgConn = "Can't connect to oVirt Engine using" \ " compatible port %s" % compatPort resp_id = ConfirmDialog(message=msgConn).run_and_close() return False else: # compatible port found enginePort = compatPort if True: if deployUtil.getRhevmCert(imvp_server_address, enginePort): path, dontCare = deployUtil.certPaths('') fp = deployUtil.generateFingerPrint(path) ovirt_store_config(path) else: msgConn = "Failed downloading IMVP certificate" resp_id = ConfirmDialog(message=msgConn).run_and_close() # Stopping vdsm-reg may fail but its ok - its in the case when the menus are run after installation deployUtil._logExec([constants.EXT_SERVICE, 'vdsm-reg', 'stop']) if write_vdsm_config(imvp_server_address, enginePort): deployUtil._logExec([constants.EXT_SERVICE, 'vdsm-reg', 'start']) msgConn = "@ENGINENAME@ Configuration Successfully Updated" resp_id = ConfirmDialog(message=msgConn).run_and_close() retWriteConf = True else: msgConn = "@ENGINENAME@ Configuration Failed" resp_id = ConfirmDialog(message=msgConn).run_and_close() retWriteConf = False return retWriteConf
def findPort(engineServer, enginePort): """Function to find the correct port for a given server """ # pylint: disable-msg=E0611,F0401 sys.path.append('/usr/share/vdsm-reg') import deployUtil # @UnresolvedImport from ovirt_config_setup.engine import \ TIMEOUT_FIND_HOST_SEC # @UnresolvedImport from ovirt_config_setup.engine import \ compatiblePort # @UnresolvedImport # pylint: enable-msg=E0611,F0401 compatPort, sslPort = compatiblePort(enginePort) LOGGER.debug("Finding port %s:%s with compat %s ssl %s" % (engineServer, enginePort, compatPort, sslPort)) deployUtil.nodeCleanup() # Build port list to try port_cfgs = [(enginePort, sslPort)] if compatPort: port_cfgs += [(compatPort, sslPort)] else: port_cfgs += [(enginePort, False)] LOGGER.debug("Port configuratoins for engine: %s" % port_cfgs) for try_port, use_ssl in port_cfgs: LOGGER.debug("Trying to reach engine %s via %s %s" % (engineServer, try_port, "SSL" if use_ssl else "")) is_reachable = False try: is_reachable = isHostReachable(host=engineServer, port=try_port, ssl=use_ssl, timeout=TIMEOUT_FIND_HOST_SEC) except Exception: LOGGER.debug("Failed to reach engine: %s" % traceback.format_exc()) if is_reachable: LOGGER.debug("Reached engine") enginePort = try_port break if not is_reachable: raise RuntimeError("Can't connect to @ENGINENAME@") return enginePort
def findPort(engineServer, enginePort): """Function to find the correct port for a given server """ # pylint: disable-msg=E0611,F0401 sys.path.append('/usr/share/vdsm-reg') import deployUtil # @UnresolvedImport from ovirt_config_setup.engine import \ TIMEOUT_FIND_HOST_SEC # @UnresolvedImport from ovirt_config_setup.engine import \ compatiblePort # @UnresolvedImport # pylint: enable-msg=E0611,F0401 compatPort, sslPort = compatiblePort(enginePort) LOGGER.debug("Finding port %s:%s with compat %s ssl %s" % (engineServer, enginePort, compatPort, sslPort)) deployUtil.nodeCleanup() # Build port list to try port_cfgs = [(enginePort, sslPort)] if compatPort: port_cfgs += [(compatPort, sslPort)] else: port_cfgs += [(enginePort, False)] LOGGER.debug("Port configuratoins for engine: %s" % port_cfgs) for try_port, use_ssl in port_cfgs: LOGGER.debug("Trying to reach engine %s via %s %s" % (engineServer, try_port, "SSL" if use_ssl else "")) is_reachable = False try: is_reachable = isHostReachable(host=engineServer, port=try_port, ssl=use_ssl, timeout=TIMEOUT_FIND_HOST_SEC) except Exception: LOGGER.debug("Failed to reach engine: %s" % traceback.format_exc()) if is_reachable: LOGGER.debug("Reached engine") enginePort = try_port break if not is_reachable: raise RuntimeError("Can't connect to {engine_name}".format( engine_name=config.engine_name)) return enginePort
def action(self): self.ncs.screen.setColor("BUTTON", "black", "red") self.ncs.screen.setColor("ACTBUTTON", "blue", "white") if self.root_password_1.value() != "" and self.root_password_2.value() != "" and self.root_password_1.value() == self.root_password_2.value(): set_password(self.root_password_1.value(), "root") augtool("set", "/files/etc/ssh/sshd_config/PasswordAuthentication", "yes") dn = file('/dev/null', 'w+') subprocess.Popen(['/sbin/service', 'sshd', 'restart'], stdout=dn, stderr=dn) if len(self.rhevm_server.value()) > 0: deployUtil.nodeCleanup() if self.verify_rhevm_cert.selected(): if deployUtil.getRhevmCert(self.rhevm_server.value(), self.rhevm_server_port.value()): path, dontCare = deployUtil.certPaths('') fp = deployUtil.generateFingerPrint(path) approval = ButtonChoiceWindow(self.ncs.screen, "Certificate Fingerprint:", fp, buttons = ['Approve', 'Reject']) if 'reject' == approval: ButtonChoiceWindow(self.ncs.screen, "Fingerprint rejected", "oVirt Engine Configuration Failed", buttons = ['Ok']) return False else: ovirt_store_config(path) self.ncs.reset_screen_colors() else: ButtonChoiceWindow(self.ncs.screen, "oVirt Engine Configuration", "Failed downloading oVirt Engine certificate", buttons = ['Ok']) self.ncs.reset_screen_colors() # Stopping vdsm-reg may fail but its ok - its in the case when the menus are run after installation deployUtil._logExec([constants.EXT_SERVICE, 'vdsm-reg', 'stop']) if write_vdsm_config(self.rhevm_server.value(), self.rhevm_server_port.value()): deployUtil._logExec([constants.EXT_SERVICE, 'vdsm-reg', 'start']) ButtonChoiceWindow(self.ncs.screen, "oVirt Engine Configuration", "oVirt Engine Configuration Successfully Updated", buttons = ['Ok']) self.ncs.reset_screen_colors() return True else: ButtonChoiceWindow(self.ncs.screen, "oVirt Engine Configuration", "oVirt Engine Configuration Failed", buttons = ['Ok']) self.ncs.reset_screen_colors() return False
def imvp_apply(self, obj): from ocsetup.ocsetup import ocs log("enter imvp apply %s") imvp_server_address = ocs.imvp_server_addr_val_Entry.get_text() imvp_server_port = ocs.imvp_serve_port_val_Entry.get_text() compatPort, sslPort = compatiblePort(imvp_server_port) if len(imvp_server_address) > 0: deployUtil.nodeCleanup() if not isHostReachable(host=imvp_server_address, port=imvp_server_port, ssl=sslPort, timeout=TIMEOUT_FIND_HOST_SEC): if compatPort is None: # Try one more time with SSL=False if not isHostReachable(host=imvp_server_address, port=imvp_server_port, ssl=False, timeout=TIMEOUT_FIND_HOST_SEC): msgConn = "Can't connect to oVirt Engine in the specific" \ " port %s" % enginePort resp_id = ConfirmDialog( message=msgConn).run_and_close() return False else: msgConn = "Can't connect to oVirt Engine port %s," \ " trying compatible port %s" % \ (enginePort, compatPort) resp_id = ConfirmDialog(message=msgConn).run_and_close() if not isHostReachable(host=imvp_server_address, port=compatPort, ssl=sslPort, timeout=TIMEOUT_FIND_HOST_SEC): msgConn = "Can't connect to oVirt Engine using" \ " compatible port %s" % compatPort resp_id = ConfirmDialog( message=msgConn).run_and_close() return False else: # compatible port found enginePort = compatPort if True: if deployUtil.getRhevmCert(imvp_server_address, enginePort): path, dontCare = deployUtil.certPaths('') fp = deployUtil.generateFingerPrint(path) ovirt_store_config(path) else: msgConn = "Failed downloading IMVP certificate" resp_id = ConfirmDialog(message=msgConn).run_and_close() # Stopping vdsm-reg may fail but its ok - its in the case when the menus are run after installation deployUtil._logExec([constants.EXT_SERVICE, 'vdsm-reg', 'stop']) if write_vdsm_config(imvp_server_address, enginePort): deployUtil._logExec( [constants.EXT_SERVICE, 'vdsm-reg', 'start']) msgConn = "@ENGINENAME@ Configuration Successfully Updated" resp_id = ConfirmDialog(message=msgConn).run_and_close() retWriteConf = True else: msgConn = "@ENGINENAME@ Configuration Failed" resp_id = ConfirmDialog(message=msgConn).run_and_close() retWriteConf = False return retWriteConf