예제 #1
0
    def form(self):
        log("enter storage form function....")
        try:
            self.iscsi_initiator_label = WidgetBase(
                "iscsi_initiator_label",
                "Label",
                "iSCSI Initiator Name:",
                title=True)

            self.iscsi_initiator_name_value = WidgetBase(
                "iscsi_initiator_name_value", "Entry", "", "",
                get_conf=get_current_iscsi_initiator_name)

            self.iscsi_button = WidgetBase(
                'iscsi_button', ButtonList, '',
                params={'labels': [_('Apply'), _('Reset')],
                'callback': [self.storage_apply, self.storage_reset]})
        except:
            log("Here some error happened.format ext:  %s " %
                traceback.format_exc())

        return [
            "Storage",
            "Storage",
            [
                (self.iscsi_initiator_label, self.iscsi_initiator_name_value),
                (WidgetBase('__', 'Label', vhelp=140),),
                (self.iscsi_button,),
            ]]
예제 #2
0
파일: imvp.py 프로젝트: sunuslee/ocsetup
    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
예제 #3
0
 def kdump_apply(self, obj):
     try:
         from ocsetup import ocs
     except ImportError:
         pass
     else:
         page = ocs.page_kernel_dump
         buttons = page.nfs_ssh_restore_custom.btns
         val = None
         for i in range(3):
             # i == 0 is NFS, i == 1 is SSH, i == 2 is RESTORE
             if buttons[i].get_active() and i == 0:
                 val = page.nfs_location_custom.entry.get_text()
             elif buttons[i].get_active() and i == 1:
                 val = page.ssh_location_custom.entry.get_text()
             elif buttons[i].get_active() and i == 2:
                 restore_kdump_config()
         if val:
             write_kdump_config(val)
             pb = ProgressBar()
             pb.make_progress(0.1)
             if '@' in val:
                 if os.path.exists("/usr/bin/kdumpctl"):
                     kdump_prop_cmd = "kdumpctl propagate"
                 else:
                     kdump_prop_cmd = "service kdump propagate"
                 from sshcmd import runcmd
                 runcmd(kdump_prop_cmd)
                 pb.make_progress(0.2)
                 if runcmd:
                     # SSH LOGIN SUCCESS.
                     ovirt_store_config("/root/.ssh/kdump_id_rsa.pub")
                     ovirt_store_config("/root/.ssh/kdump_id_rsa")
                     ovirt_store_config("/root/.ssh/known_hosts")
                     ovirt_store_config("/root/.ssh/config")
             pb.make_progress(0.5)
             system('servic kdump restart &')
             while True:
                 res = check_output('service kdump status')
                 if 'starting' not in res:
                     break
                 pb.make_progress(0.5)
                 time.sleep(3)
             pb.make_progress(0.8)
             if 'Kdump is not operational' in res:
                 # restart kdump Failed.
                 unmount_config("/etc/kdump.conf")
                 if os.path.exists("/etc/kdump.conf"):
                     os.remove("/etc/kdump.conf")
                 pb.make_progress(0, 'FAILED!')
                 pb.progress_label.set_label('FAILED!')
             elif 'Kdump is operational' in res:
                 ovirt_store_config("/etc/kdump.conf")
                 pb.make_progress(1, 'successful!')
             else:
                 log('kdump start Failed:' + res)
                 pb.make_progress(0, 'FAILED!')
                 pb.progress_label.set_label('FAILED!')
예제 #4
0
 def set_log_server(self, _):
     try:
         from ocsetup import ocs
         page = ocs.page_logging
         cur_server = page.log_server_address_custom.entry.get_text()
         cur_port = page.log_server_port_custom.entry.get_text()
         ovirt_rsyslog(cur_server, cur_port, "udp")
     except Exception, e:
         log(e)
         pass
예제 #5
0
 def change_password(self, _):
     try:
         from ocsetup import ocs
         from ovirtnode.password import set_password
         page = ocs.page_security
         pw1 = page.local_access_password_custom.entry.get_text()
         set_password(pw1, "admin")
         log("change password for admin:" + pw1)
     except Exception, e:
         log(e)
         pass
예제 #6
0
 def get_ssh_conf(self, path):
     try:
         from ocsetup import ocs
         state = augtool_get(path)
         if state == "no":
             ocs.page_security.enable_ssh_CheckButton.set_active(False)
         elif state == "yes":
             ocs.page_security.enable_ssh_CheckButton.set_active(True)
         else:
             log('ssh PasswordAuthentication invail val:' + state)
     except Exception, e:
         log(e)
         pass
예제 #7
0
파일: imvp.py 프로젝트: sunuslee/ocsetup
def getEngineInformation(engine_type):
    try:
        vds_server = getEngineConfig()
        engine_address,engine_port = vds_server.split(":")
        if engine_address.startswith("None"):
            engine_address = ""
    except:
        log("Warning: failed to parse engine config. %s " % traceback.format_exc())
        engine_address = ""
        engine_port = "8080"
    if engine_type == "address":
        return engine_address
    elif engine_type == "port" :
        return engine_port
    return None
예제 #8
0
파일: license.py 프로젝트: sunuslee/ocsetup
    def form(self):
        log("enter license form function....")
        remaindays = 0
        try:
            hasregister = hasRegistered()
            hasstart = hasStarted()

            headermessage = WidgetBase("Basic_Information", "Label", "Basic Information",
                    title=True)

            #show hypervisor version information
            version = getVersionInfo()
            versionlabel =  WidgetBase("Version", "Label",
                    "Version:" + version)

            #show register information
            subtopiclabel = WidgetBase("SUB_TOPIC_LABEL", "Label",
                    "Basic Register Information: ", title=True)

            maclabel = WidgetBase("MAC_LABEL", "Label", "",
                    get_conf=lambda : "MAC :  " +
                    getLicenseConfig("vars", "mac", "F0:DE:F1:00:00:00"))

            sysuuidlabel = WidgetBase("SYSTEMUUID_LABEL", "Label", "",
                    get_conf=lambda : "UUID :  " +
                    getLicenseConfig("vars", "systemuuid", "00000000-0000-0000-0000-000000000000"))

            if hasstart and hasregister:
                taillabel_text = "Your hypervisor has been registered successfully.Any question, please contact : [email protected]!"
            else:
                days, issuccess = computeDeprecatedDays()
                if issuccess:
                    log("the day is %d" % days)
                    remaindays = DEFAULTREMAININGDAYS - days
                    if remaindays < 0:
                        remaindays = 0
                else:
                    log("Failed to invoke computeDeprecatedDays. ")
                warninginfo = "You have " + str(remaindays) + " to use before registering."
                taillabel_text = "Your hypervisor hasn't been registered.Please use the information above to register."+warninginfo
            note = WidgetBase("note", "Label", "Note:", title=True)
            taillabel = WidgetBase("TAIL_LABEL", "Label", taillabel_text, width=80)
        except:
            log("Here some error happened.format ext:  %s " % traceback.format_exc())

        return [ "License", "License",
                    [
                        (headermessage,),
                        (versionlabel,),
                        (subtopiclabel,),
                        (maclabel,),
                        (sysuuidlabel,),
                        (note,),
                        (taillabel,),
                        (EMPTY_LINE,),
                    ]
              ]
예제 #9
0
    def form(self):
        log("enter storage form function....")
        try:
            self.iscsi_initiator_name_label = WidgetBase(
                "iscsi_initiator_name_label",
                "Label",
                "iSCSI Initiator Name:",
                title=True)

            self.iscsi_initiator_name_value = WidgetBase(
                "iscsi_initiator_name_value",
                "Entry",
                "",
                "",
                get_conf=get_current_iscsi_initiator_name)

            self.iscsi_button = WidgetBase(
                'iscsi_button',
                ButtonList,
                '',
                params={
                    'labels': [_('Apply'), _('Reset')],
                    'callback': [self.storage_apply, self.storage_reset]
                })
        except:
            log("Here some error happened.format ext:  %s " %
                traceback.format_exc())

        return [
            "Storage", "Storage",
            [
                (self.iscsi_initiator_name_label,
                 self.iscsi_initiator_name_value),
                (WidgetBase('__', 'Label', vhelp=140), ),
                (self.iscsi_button, ),
            ]
        ]
예제 #10
0
파일: sshcmd.py 프로젝트: jarod-w/ocsetup
def runcmd(cmd):
    child = pexpect.spawn(cmd, logfile=sys.stdout)
    while True:
        i = child.expect([
            pexpect.TIMEOUT,
            'Are you sure you want to continue connecting',
            'Enter passphrase for key',
            'Permission denied, please try again.',
            'password: '******'Permission denied',
            pexpect.EOF])
        if i == 0:
            # TIMEOUT.
            return
        elif i == 1:
            child.sendline('yes')
        elif i == 2:
            child.send("\r")
        elif i == 3:
            # wrong password, but you can still try AGAIN.
            password = PopupEntry(
                label='Password:'******'Password:').run_and_close()
            child.sendline(password)
        elif i == 5:
            # LOGIN FAILED
            return
        elif i == 6:
            # LOGIN SUCCEED.
            return child
        else:
            log(
                "run cmd error i = %d\n before:%s\nafter:%s" %
                (i, child.before, child.after))
예제 #11
0
파일: imvp.py 프로젝트: jarod-w/ocsetup
 def imvp_reset(self, obj):
     log("enter imvp reset")
     refresh_window(obj)
예제 #12
0
 def storage_reset(self, obj):
     log("enter storage reset")
     refresh_window(obj)
예제 #13
0
 def storage_apply(self, obj):
     from ocsetup.ocsetup import ocs
     log("enter storage apply")
     set_iscsi_initiator(
         ocs.page_Storage.iscsi_initiator_name_value_Entry.get_text())
예제 #14
0
 def storage_reset(self, obj):
     log("enter storage reset")
     refresh_window(obj)
예제 #15
0
 def storage_apply(self, obj):
     from ocsetup.ocsetup import ocs
     log("enter storage apply")
     set_iscsi_initiator(
         ocs.page_Storage.iscsi_initiator_name_value_Entry.get_text())
예제 #16
0
파일: imvp.py 프로젝트: sunuslee/ocsetup
    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
예제 #17
0
파일: imvp.py 프로젝트: jarod-w/ocsetup
def write_vdsm_config(engineHost, enginePort):
    if not os.path.exists(VDSM_CONFIG):
        system("touch " + VDSM_CONFIG)
    if os.path.getsize(VDSM_CONFIG) == 0:
        set_defaults()
        ovirt_store_config(VDSM_CONFIG)
        log("@ENGINENAME@ agent configuration files created.")
    else:
        log("@ENGINENAME@ agent configuration files already exist.")

    if system("ping -c 1 " + engineHost):
        sed_cmd = "sed -i --copy \"s/\(^vdc_host_name=\)\(..*$\)/vdc_host_name\
                =" + engineHost + "/\" " + VDSM_REG_CONFIG
        if system(sed_cmd):
            log("The @ENGINENAME@'s address is set: %s\n" % engineHost)
        if enginePort != "":
            sed_cmd = "sed -i --copy \"s/\(^vdc_host_port=\)\(..*$\)/vdc\
                _host_port=" + str(enginePort) + "/\" " + VDSM_REG_CONFIG
            if system(sed_cmd):
                log("The @ENGINENAME@'s port set: %s\n" % enginePort)
            fWriteConfig = 1
    else:
        log("Either " + engineHost + " is an invalid address \
            or the IMVP unresponsive.\n")
        return False

    if fWriteConfig == 1:
        log("Saving vdsm-reg.conf\n")
        if ovirt_store_config(VDSM_REG_CONFIG):
            log("vdsm-reg.conf Saved\n")
            return True
예제 #18
0
    def form(self):
        log("enter license form function....")
        remaindays = 0
        try:
            hasregister = hasRegistered()
            hasstart = hasStarted()

            headermessage = WidgetBase("Basic_Information",
                                       "Label",
                                       "Basic Information",
                                       title=True)

            #show hypervisor version information
            version = getVersionInfo()
            versionlabel = WidgetBase("Version", "Label", "Version:" + version)

            #show register information
            subtopiclabel = WidgetBase("SUB_TOPIC_LABEL",
                                       "Label",
                                       "Basic Register Information: ",
                                       title=True)

            maclabel = WidgetBase(
                "MAC_LABEL",
                "Label",
                "",
                get_conf=lambda: "MAC :  " + getLicenseConfig(
                    "vars", "mac", "F0:DE:F1:00:00:00"))

            sysuuidlabel = WidgetBase(
                "SYSTEMUUID_LABEL",
                "Label",
                "",
                get_conf=lambda: "UUID :  " + getLicenseConfig(
                    "vars", "systemuuid",
                    "00000000-0000-0000-0000-000000000000"))

            if hasstart and hasregister:
                taillabel_text = "Your hypervisor has been registered successfully.Any question, please contact : [email protected]!"
            else:
                days, issuccess = computeDeprecatedDays()
                if issuccess:
                    log("the day is %d" % days)
                    remaindays = DEFAULTREMAININGDAYS - days
                    if remaindays < 0:
                        remaindays = 0
                else:
                    log("Failed to invoke computeDeprecatedDays. ")
                warninginfo = "You have " + str(
                    remaindays) + " to use before registering."
                taillabel_text = "Your hypervisor hasn't been registered.Please use the information above to register." + warninginfo
            note = WidgetBase("note", "Label", "Note:", title=True)
            taillabel = WidgetBase("TAIL_LABEL",
                                   "Label",
                                   taillabel_text,
                                   width=80)
        except:
            log("Here some error happened.format ext:  %s " %
                traceback.format_exc())

        return [
            "License", "License",
            [
                (headermessage, ),
                (versionlabel, ),
                (subtopiclabel, ),
                (maclabel, ),
                (sysuuidlabel, ),
                (note, ),
                (taillabel, ),
                (EMPTY_LINE, ),
            ]
        ]
예제 #19
0
파일: imvp.py 프로젝트: sunuslee/ocsetup
def write_vdsm_config(engineHost, enginePort):
    if not os.path.exists(VDSM_CONFIG):
        system("touch " + VDSM_CONFIG)
    if os.path.getsize(VDSM_CONFIG) == 0:
        set_defaults()
        ovirt_store_config(VDSM_CONFIG)
        log("@ENGINENAME@ agent configuration files created.")
    else:
        log("@ENGINENAME@ agent configuration files already exist.")

    if system("ping -c 1 " + engineHost):
        sed_cmd = "sed -i --copy \"s/\(^vdc_host_name=\)\(..*$\)/vdc_host_name=" + engineHost + "/\" " + VDSM_REG_CONFIG
        if system(sed_cmd):
            log("The @ENGINENAME@'s address is set: %s\n" % engineHost)
        if enginePort != "":
            sed_cmd = "sed -i --copy \"s/\(^vdc_host_port=\)\(..*$\)/vdc_host_port=" + str(
                enginePort) + "/\" " + VDSM_REG_CONFIG
            if system(sed_cmd):
                log("The @ENGINENAME@'s port set: %s\n" % enginePort)
            fWriteConfig = 1
    else:
        log("Either " + engineHost +
            " is an invalid address or the @ENGINENAME@ unresponsive.\n")
        return False

    if fWriteConfig == 1:
        log("Saving vdsm-reg.conf\n")
        if ovirt_store_config(VDSM_REG_CONFIG):
            log("vdsm-reg.conf Saved\n")
            return True
예제 #20
0
파일: engine.py 프로젝트: ekohl/vdsm
def write_vdsm_config(rhevm_host, rhevm_port):
    if not os.path.exists(VDSM_CONFIG):
        os.system("touch " + VDSM_CONFIG)
    if os.path.getsize(VDSM_CONFIG) == 0:
        set_defaults()
        ovirt_store_config(VDSM_CONFIG)
        log("oVirt agent configuration files created.")
    else:
        log("oVirt agent configuration files already exist.")

    ret = os.system("ping -c 1 " + rhevm_host + " &> /dev/null")
    if ret == 0:
        sed_cmd = "sed -i --copy \"s/\(^vdc_host_name=\)\(..*$\)/vdc_host_name="+rhevm_host+"/\" " + VDSM_REG_CONFIG
        ret = os.system(sed_cmd)
        if ret == 0:
            log("The oVirt Engine's address is set: %s\n" % rhevm_host)
        if rhevm_port != "":
            sed_cmd = "sed -i --copy \"s/\(^vdc_host_port=\)\(..*$\)/vdc_host_port="+str(rhevm_port)+"/\" " + VDSM_REG_CONFIG
            os.system(sed_cmd)
            log("The oVirt Engine's port set: %s\n" % rhevm_port)
            fWriteConfig=1
    else:
        log("Either " + rhevm_host + " is an invalid address or the oVirt Engine unresponsive.\n")
        return False

    if fWriteConfig == 1:
        log("Saving vdsm-reg.conf\n")
        if ovirt_store_config(VDSM_REG_CONFIG):
            log("vdsm-reg.conf Saved\n")
            return True
예제 #21
0
파일: imvp.py 프로젝트: sunuslee/ocsetup
 def imvp_reset(self, obj):
     log("enter imvp reset")
     refresh_window(obj)
예제 #22
0
파일: rhevm.py 프로젝트: vikas-lamba/vdsm
def write_vdsm_config(rhevm_host, rhevm_port):
    if not os.path.exists(VDSM_CONFIG):
        os.system("touch " + VDSM_CONFIG)
    if os.path.getsize(VDSM_CONFIG) == 0:
        set_defaults()
        ovirt_store_config(VDSM_CONFIG)
        log("RHEV agent configuration files created.")
    else:
        log("RHEV agent configuration files already exist.")

    ret = os.system("ping -c 1 " + rhevm_host + " &> /dev/null")
    if ret == 0:
        sed_cmd = "sed -i --copy \"s/\(^vdc_host_name=\)\(..*$\)/vdc_host_name=" + rhevm_host + "/\" " + VDSM_REG_CONFIG
        ret = os.system(sed_cmd)
        if ret == 0:
            log("The RHEV Manager's address is set: %s\n" % rhevm_host)
        if rhevm_port != "":
            sed_cmd = "sed -i --copy \"s/\(^vdc_host_port=\)\(..*$\)/vdc_host_port=" + str(
                rhevm_port) + "/\" " + VDSM_REG_CONFIG
            os.system(sed_cmd)
            log("The RHEV Manager's port set: %s\n" % rhevm_port)
            fWriteConfig = 1
    else:
        log("Either " + rhevm_host +
            " is an invalid address or the RHEV Manager unresponsive.\n")
        return False

    if fWriteConfig == 1:
        log("Saving vdsm-reg.conf\n")
        if ovirt_store_config(VDSM_REG_CONFIG):
            log("vdsm-reg.conf Saved\n")
            return True