示例#1
0
文件: toIcm.py 项目: bisos-pip/things
def targetParamsListGet(interactive=False):
    """ Returns a list of path to targetSpecifiers.
        If interactive args have been specified, an ephemera targetPathSpecifier
        is added to list of path to be returned.
        Loaded TARGET_list is appended to returnedList.
    """

    try:
        icm.callableEntryEnhancer(type='cmnd')
    except StopIteration:
        return

    G = icm.IcmGlobalContext()
    icmRunArgs = G.icmRunArgsGet()

    if interactive == True:
        if not len(icmRunArgs.cmndArgs) == 0:
            try:
                icm.EH_runTime('Bad Number Of cmndArgs')
            except RuntimeError:
                return

    tpl = Target_Param_List()
    paramList = tpl.parameterListGet()

    return paramList
示例#2
0
    def cmnd(
            self,
            interactive=False,  # Can also be called non-interactively
    ):
        cmndOutcome = self.getOpOutcome()

        if interactive:
            if not self.cmndLineValidate(outcome=cmndOutcome):
                return cmndOutcome

        callParamsDict = {}
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome


####+END:
        G = icm.IcmGlobalContext()
        argsList = G.icmRunArgsGet().cmndArgs

        G_myFullName = sys.argv[0]

        for eachArg in argsList:
            outcome = icm.subProc_bash(
                """{icmName} -v 20 -i {command}""".format(
                    icmName=G_myFullName,
                    command=eachArg,
                )).log()
            if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

            # eval("""{command}().cmnd(interactive=False,)""".format(
            #     command=eachArg,
            # ))

        return cmndOutcome
示例#3
0
def g_paramsExtraSpecify(parser, ):
    ####+END:
    """Module Specific Command Line Parameters.
    g_argsExtraSpecify is passed to G_main and is executed before argsSetup (can not be decorated)
    """
    G = icm.IcmGlobalContext()
    icmParams = icm.ICM_ParamDict()

    bleep.commonParamsSpecify(icmParams)

    clsMethod.commonParamsSpecify(icmParams)  # --cls, --method

    fp.commonParamsSpecify(icmParams)  # --fpBase

    bpo.commonParamsSpecify(icmParams)

    #palsBpo.commonParamsSpecify(icmParams)
    #palsRepo.commonParamsSpecify(icmParams)

    palsSis.commonParamsSpecify(icmParams)

    PalsRepo_LiveParams_FPs.fps_asIcmParamsAdd(icmParams, )
    PalsRepo_Profile_FPs.fps_asIcmParamsAdd(icmParams, )

    # commonParamsSpecify(icmParams)

    icm.argsparseBasedOnIcmParams(parser, icmParams)

    # So that it can be processed later as well.
    G.icmParamDictSet(icmParams)

    return
示例#4
0
def g_argsExtraSpecify(
    parser,
):
####+END:
    """Module Specific Command Line Parameters.
    g_argsExtraSpecify is passed to G_main and is executed before argsSetup (can not be decorated)
    """
    G = icm.IcmGlobalContext()
    icmParams = icm.ICM_ParamDict()

    icmParams.parDictAdd(
        parName='moduleVersion',
        parDescription="Module Version",
        parDataType=None,
        parDefault=None,
        parChoices=list(),
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--version',
    )

    
    bleep.commonParamsSpecify(icmParams)

    wsInvokerIcm.commonParamsSpecify(icmParams)        
       
    icm.argsparseBasedOnIcmParams(parser, icmParams)

    # So that it can be processed later as well.
    G.icmParamDictSet(icmParams)
    
    return
示例#5
0
    def cmnd(self,
            interactive=False,        # Can also be called non-interactively
            inMailAcct=None,      # or IIF Parameter            
    ):
        """ """
        myName=self.myName()
        G = icm.IcmGlobalContext()        
        thisOutcome = icm.OpOutcome(invokerName=myName)
        if interactive:
            if not self.cmndLineValidate(outcome=thisOutcome):
                return(thisOutcome)

        if not inMailAcct:
            if not interactive:
                return icm.eh_problem_usageError(
                    thisOutcome,
                    "Missing Non-Interactive Arg (inMailAcct)",
                )
            inMailAcct = G.usageParams.inMailAcct

        outcome = icm.subProc_bash("""echo Preparing the package""").log()
        if outcome.isProblematic(): return(icm.EH_badOutcome(outcome))
        
        return thisOutcome.set(
            opError=icm.OpError.Success,
            opResults=None,
        )
示例#6
0
    def cmnd(
            self,
            interactive=False,  # Can also be called non-interactively
            argsList=None,  # or Args-Input
    ):
        G = icm.IcmGlobalContext()
        cmndOutcome = self.getOpOutcome()
        if interactive:
            if not self.cmndLineValidate(outcome=cmndOutcome):
                return cmndOutcome
            effectiveArgsList = G.icmRunArgsGet().cmndArgs
        else:
            effectiveArgsList = argsList

        callParamsDict = {}
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome
####+END:

        moduleDescription = """
*       [[elisp:(org-show-subtree)][|=]]  [[elisp:(org-cycle)][| *Description:* | ]]
**  [[elisp:(org-cycle)][| ]]  [Xref]          :: *[Related/Xrefs:]*  <<Xref-Here->>  -- External Documents  [[elisp:(org-cycle)][| ]]

**  [[elisp:(org-cycle)][| ]]	Model and Terminology 					   :Overview:
*** bxpRootXxFile   -- /etc/bystarRoot, ~/.bystarRoot, /bystar
*** bxpRoot         -- Base For This Module
*** bpb             -- ByStar Platform Base, Location Of Relevant Parts (Bisos, blee, bsip
*** bpd             -- ByStar Platform Directory (Object), An instance of Class BxpBaseDir
**      [End-Of-Description]
"""

        moduleUsage = """
*       [[elisp:(org-show-subtree)][|=]]  [[elisp:(org-cycle)][| *Usage:* | ]]

**      How-Tos:
**      [End-Of-Usage]
"""

        moduleStatus = """
*       [[elisp:(org-show-subtree)][|=]]  [[elisp:(org-cycle)][| *Status:* | ]]
**  [[elisp:(org-cycle)][| ]]  [Info]          :: *[Current-Info:]* Status/Maintenance -- General TODO List [[elisp:(org-cycle)][| ]]
** TODO [[elisp:(org-cycle)][| ]]  Current         :: Just getting started [[elisp:(org-cycle)][| ]]
**      [End-Of-Status]
"""

        ####+BEGIN: bx:dblock:global:file-insert-cond :cond "./blee.el" :file "/libre/ByStar/InitialTemplates/update/sw/icm/py/moduleOverview.py"
        cmndArgsSpec = {
            "0&-1": ['moduleDescription', 'moduleUsage', 'moduleStatus']
        }
        cmndArgsValid = cmndArgsSpec["0&-1"]
        icm.unusedSuppressForEval(moduleDescription, moduleUsage, moduleStatus)
        for each in effectiveArgsList:
            if each in cmndArgsValid:
                if interactive:
                    exec("""print({})""".format(each))

        return (format(str(__doc__) + moduleDescription))
示例#7
0
    def cmnd(
            self,
            interactive=False,  # Can also be called non-interactively
            argsList=None,  # or Args-Input
    ):
        G = icm.IcmGlobalContext()
        cmndOutcome = self.getOpOutcome()
        if interactive:
            if not self.cmndLineValidate(outcome=cmndOutcome):
                return cmndOutcome
            effectiveArgsList = G.icmRunArgsGet().cmndArgs
        else:
            effectiveArgsList = argsList

        callParamsDict = {}
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome
####+END:

        moduleDescription = """
*       [[elisp:(org-show-subtree)][|=]]  [[elisp:(org-cycle)][| *Description:* | ]]
**  [[elisp:(org-cycle)][| ]]  [Xref]          :: *[Related/Xrefs:]*  <<Xref-Here->>  -- External Documents  [[elisp:(org-cycle)][| ]]

**  [[elisp:(org-cycle)][| ]]   Model and Terminology                                      :Overview:
This module is part of BISOS and its primary documentation is in  http://www.by-star.net/PLPC/180047
**      [End-Of-Description]
"""

        moduleUsage = """
*       [[elisp:(org-show-subtree)][|=]]  [[elisp:(org-cycle)][| *Usage:* | ]]

**      How-Tos:
**      [End-Of-Usage]
"""

        moduleStatus = """
*       [[elisp:(org-show-subtree)][|=]]  [[elisp:(org-cycle)][| *Status:* | ]]
**  [[elisp:(org-cycle)][| ]]  [Info]          :: *[Current-Info:]* Status/Maintenance -- General TODO List [[elisp:(org-cycle)][| ]]
** TODO [[elisp:(org-cycle)][| ]]  Current         :: Just getting started [[elisp:(org-cycle)][| ]]
**      [End-Of-Status]
"""

        ####+BEGIN: bx:dblock:global:file-insert-cond :cond "./blee.el" :file "/libre/ByStar/InitialTemplates/update/sw/icm/py/moduleOverview.py"
        cmndArgsSpec = {
            "0&-1": ['moduleDescription', 'moduleUsage', 'moduleStatus']
        }
        cmndArgsValid = cmndArgsSpec["0&-1"]
        icm.unusedSuppressForEval(moduleDescription, moduleUsage, moduleStatus)
        for each in effectiveArgsList:
            if each in cmndArgsValid:
                if interactive:
                    exec("""print({})""".format(each))

        return (format(str(__doc__) + moduleDescription))
示例#8
0
文件: facterIcm.py 项目: bisos/bpip1
def g_paramsExtraSpecify(parser, ):
    ####+END:
    """Module Specific Command Line Parameters.
    g_argsExtraSpecify is passed to G_main and is executed before argsSetup (can not be decorated)
    """
    G = icm.IcmGlobalContext()
    icmParams = icm.ICM_ParamDict()

    # So that it can be processed later as well.
    G.icmParamDictSet(icmParams)

    return
示例#9
0
    def cmnd(
            self,
            interactive=False,  # Can also be called non-interactively
            periodicity=None,  # or Cmnd-Input
    ):
        cmndOutcome = self.getOpOutcome()
        if interactive:
            if not self.cmndLineValidate(outcome=cmndOutcome):
                return cmndOutcome

        callParamsDict = {
            'periodicity': periodicity,
        }
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome
        periodicity = callParamsDict['periodicity']
        ####+END:
        G = icm.IcmGlobalContext()
        argsList = G.icmRunArgsGet().cmndArgs

        G_myFullName = sys.argv[0]

        while True:
            for eachArg in argsList:
                outcome = icm.subProc_bash(
                    """{icmName} -v 20 -i {command}""".format(
                        icmName=G_myFullName,
                        command=eachArg,
                    )).log()
                if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

            icm.ANN_note(
                "sleeping for: {periodicity}".format(periodicity=periodicity))

            try:
                time.sleep(int(periodicity))
            except KeyboardInterrupt:
                print('\n\nKeyboard exception received. Exiting.')
                exit()

            icm.ANN_note("End of sleeping")
示例#10
0
文件: toIcm.py 项目: bisos-pip/things
def ticmoBxpOutputsBaseGetCmnd(interactive=False,
                               targetType="bxp",
                               collective=None,
                               district=None,
                               targetId=None):
    """  """
    try:
        icm.callableEntryEnhancer(type='cmnd')
    except StopIteration:
        return

    if targetType != "bxp":
        return icm.EH_problem_usageError("Unsupported Target Type: " +
                                         targetType)

    G = icm.IcmGlobalContext()
    icmRunArgs = G.icmRunArgsGet()
    #icmParamDict = G.icmParamDictGet()

    if interactive == True:
        if not len(icmRunArgs.cmndArgs) == 0:
            try:
                icm.EH_runTime('Bad Number Of cmndArgs')
            except RuntimeError:
                return

        if icmRunArgs.collective:
            collective = icmRunArgs.collective

        if icmRunArgs.district:
            district = icmRunArgs.district

        if icmRunArgs.targetType:
            targetType = icmRunArgs.targetType

        if icmRunArgs.targetId:
            targetId = icmRunArgs.targetId

    # /de/bx/ticmo/int/libreCenter/targets/bxp/bue/
    return (format("/de/bx/ticmo/%s/%s/targets/%s/%s" %
                   (collective, district, targetType, targetId)))
示例#11
0
def main():
    #
    # ICM Library Setup Begins
    #

    icmRunArgs, icmArgsParser = icm.G_argsProc(
        arguments=sys.argv,
        extraArgs=None,
    )

    logControler = icm.LOG_Control()
    logControler.loggerSet(icmRunArgs)

    G = icm.IcmGlobalContext()
    G.globalContextSet(icmRunArgs=icmRunArgs)

    #
    # ICM Library Setup Begins
    #

    mailSendingExample()
示例#12
0
文件: toIcm.py 项目: bisos-pip/things
def targetBaseGet(
        interactive=False,  # Both Non-Interactive and Interactive
        targetElem=None,
        collective="int",
        district="libreCenter",
        targetType="bxp",
        targetId=None):
    """  """
    try:
        icm.callableEntryEnhancer(type='cmnd')
    except StopIteration:
        return

    G = icm.IcmGlobalContext()
    icmRunArgs = G.icmRunArgsGet()
    #icmParamDict = G.icmParamDictGet()

    if interactive == True:
        if not len(icmRunArgs.cmndArgs) == 0:
            try:
                icm.EH_runTime('Bad Number Of cmndArgs')
            except RuntimeError:
                return

        if icmRunArgs.collective: collective = icmRunArgs.collective
        if icmRunArgs.district: district = icmRunArgs.district
        if icmRunArgs.targetType: targetType = icmRunArgs.targetType
        if icmRunArgs.targetId: targetId = icmRunArgs.targetId

    targetBase = ticmoBxpOutputsBaseGet(targetType=targetType,
                                        targetElem=targetElem,
                                        collective=collective,
                                        district=district,
                                        targetId=targetId)
    print(targetBase)
    return (targetBase)
示例#13
0
def g_argsExtraSpecify(parser, ):
    ####+END:
    """Module Specific Command Line Parameters.
    g_argsExtraSpecify is passed to G_main and is executed before argsSetup (can not be decorated)
    """
    G = icm.IcmGlobalContext()
    icmParams = icm.ICM_ParamDict()

    marmeAcctsLib.commonParamsSpecify(icmParams)

    icmParams.parDictAdd(
        parName='moduleVersion',
        parDescription="Module Version",
        parDataType=None,
        parDefault=None,
        parChoices=list(),
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--version',
    )

    icmParams.parDictAdd(
        parName='inFile',
        parDescription="Input File",
        parDataType=None,
        # ../control/outMail/common/template/bynameUtf8.mail
        parDefault=os.path.join(
            marmeAcctsLib.outMailCommonDirGet(
                marmeAcctsLib.enabledControlProfileObtain(
                    curGet_bxoId(), curGet_sr())), "template/bynameUtf8.mail"),
        parChoices=["someFile", "UserInput"],
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--inFile',
    )

    icmParams.parDictAdd(
        parName='fromLine',
        parDescription="From Line",
        parDataType=None,
        parDefault="*****@*****.**",
        parChoices=["*****@*****.**", "UserInput"],
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--fromLine',
    )

    icmParams.parDictAdd(
        parName='toLine',
        parDescription="To Line",
        parDataType=None,
        parDefault="*****@*****.**",
        parChoices=["*****@*****.**", "UserInput"],
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--toLine',
    )

    bleep.commonParamsSpecify(icmParams)

    icm.argsparseBasedOnIcmParams(parser, icmParams)

    # So that it can be processed later as well.
    G.icmParamDictSet(icmParams)

    return
示例#14
0
文件: toIcm.py 项目: bisos-pip/things
def targetsAccessListGet(interactive=False,
                         targetFqdn=None,
                         accessMethod=None,
                         userName=None,
                         password=None):
    """ Returns a list of path to targetSpecifiers.
        If interactive args have been specified, an ephemera targetPathSpecifier
        is added to list of path to be returned.
        Loaded TARGET_list is appended to returnedList.
    """

    try:
        icm.callableEntryEnhancer(type='cmnd')
    except StopIteration:
        return

    G = icm.IcmGlobalContext()
    icmRunArgs = G.icmRunArgsGet()
    #icmParamDict = G.icmParamDictGet()

    #thisFunc = icm.FUNC_currentGet()
    #cmndThis= thisFunc.__name__
    #cmndMandatoryParams=[]
    #cmndOptionalParams=[]

    cmndPathTargets = []

    if interactive == True:
        if not len(icmRunArgs.cmndArgs) == 0:
            try:
                icm.EH_runTime('Bad Number Of cmndArgs')
            except RuntimeError:
                return

        if icmRunArgs.targetFqdn:
            targetFqdn = icmRunArgs.targetFqdn

        if icmRunArgs.accessMethod:
            accessMethod = icmRunArgs.accessMethod

        if icmRunArgs.userName:
            userName = icmRunArgs.userName

        if icmRunArgs.password:
            password = icmRunArgs.password

    if targetFqdn != None:
        ephemeraTargetBase = format("/tmp/ephemera-target/" + targetFqdn)
        try:
            os.makedirs(ephemeraTargetBase, 0o777)
        except OSError:
            pass
        linuxTarget = TARGET_Proxy_Linux(basePath=ephemeraTargetBase)

        linuxTarget.accessParamsSet(
            accessMethod=accessMethod,
            targetFqdn=targetFqdn,
            userName=userName,
            password=password,
        )

        cmndPathTargets.append(ephemeraTargetBase)

    # Check For cmndArgs and stdin and  Add Them To cmndTargets
    for thisCmndArg in icmRunArgs.cmndArgs:
        icm.TM_here(thisCmndArg)
        cmndPathTargets.append(thisCmndArg)

    # NOTYET: Check For TargetParams and Add Them To cmndTargets

    tl = TARGET_List()
    targetList = tl.targetListGet()

    #icm.icm.TM_here(targetList)

    for thisTarget in targetList:
        targetType = thisTarget.targetType()
        if targetType != 'bxp':
            icm.EH_problem_usageError(targetType)
            continue
        dnType = thisTarget.dnType()
        #dnQualifier = thisTarget.dnQualifier()
        dnBase = thisTarget.base()

        if dnType == 'path':
            cmndPathTargets.append(dnBase)
        else:
            icm.EH_problem_usageError(dnType)

    # for thisPathTarget in cmndPathTargets:
    #     print thisPathTarget

    return cmndPathTargets
示例#15
0
    def cmnd(
            self,
            interactive=False,  # Can also be called non-interactively
            outMailAcct=None,  # or Cmnd-Input
            inFile=None,  # or Cmnd-Input
            sendingMethod=None,  # or Cmnd-Input
            msg=None,  # asFunc when interactive==False
    ):
        cmndOutcome = self.getOpOutcome()
        if interactive:
            if not self.cmndLineValidate(outcome=cmndOutcome):
                return cmndOutcome

        callParamsDict = {
            'outMailAcct': outMailAcct,
            'inFile': inFile,
            'sendingMethod': sendingMethod,
        }
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome
        outMailAcct = callParamsDict['outMailAcct']
        inFile = callParamsDict['inFile']
        sendingMethod = callParamsDict['sendingMethod']
        ####+END:
        G = icm.IcmGlobalContext()

        if not msg:
            if inFile:
                msg = msgIn.getMsgFromFile(inFile)
            else:
                # Stdin then
                msg = msgIn.getMsgFromStdin()

        icm.LOG_here(msgOut.strLogMessage(
            "Msg As Input:",
            msg,
        ))

        if not sendingMethod:
            sendingMethod = msgOut.SendingMethod.submit
        if msgOut.sendingMethodSet(msg, sendingMethod).isProblematic():
            return msgOut.sendingMethodSet(msg, sendingMethod)

        print(G.usageParams.runMode)

        if msgOut.sendingRunControlSet(msg,
                                       G.usageParams.runMode).isProblematic():
            return msgOut.sendingRunControlSet(msg, G.usageParams.runMode)

        envelopeAddr = msg['From']
        recipientsList = msg['To']

        msgOut.envelopeAddrSet(
            msg,
            mailBoxAddr=envelopeAddr,  # Mandatory
        )

        msgOut.crossRefInfo(
            msg,
            crossRefInfo="XrefForStatusNotifications"  # Mandatory
        )
        msgOut.nonDeliveryNotificationRequetsForTo(
            msg,
            recipientsList=recipientsList,
            notifyTo=envelopeAddr,
        )
        msgOut.nonDeliveryNotificationActions(
            msg,
            coRecipientsList=recipientsList,
        )
        msgOut.deliveryNotificationRequetsForTo(
            msg,
            recipientsList=recipientsList,
            notifyTo=envelopeAddr,
        )
        msgOut.dispositionNotificationRequetsForTo(
            msg,
            recipientsList=recipientsList,
            notifyTo=envelopeAddr,
        )

        if msgOut.sendingMethodSet(msg, sendingMethod).isProblematic():
            return icm.EH_badLastOutcome()

        if not marmeSendLib.bx822Set_sendWithEnabledAcct(msg, sendingMethod):
            return icm.EH_badOutcome(cmndOutcome)

        cmndOutcome = marmeSendLib.sendCompleteMessage().cmnd(
            interactive=False,
            msg=msg,
        )

        return cmndOutcome
def enetLibsUpdate(
        interactive=False,
        targetFqdn=None,  # Optional
        accessMethod=None,  # Optional
        userName=None,  # Optional
        password=None,  # Optional
):
    """ Given An ToIcmTag, dateVer in TICMO
    """
    try:
        icm.callableEntryEnhancer(type='cmnd')
    except StopIteration:
        return

    cmndThis = icm.FUNC_currentGet().__name__

    if interactive == True:
        G = icm.IcmGlobalContext()
        icmRunArgs = G.icmRunArgsGet()

        if not len(icmRunArgs.cmndArgs) == 0:
            try:
                icm.EH_runTime(format(cmndThis + 'Bad Number Of cmndArgs'))
            except RuntimeError:
                return

    targetsAccessList = toIcm.targetsAccessListGet(interactive=interactive,
                                                   targetFqdn=targetFqdn,
                                                   accessMethod=accessMethod,
                                                   userName=userName,
                                                   password=password)

    targetParamsList = toIcm.targetParamsListGet(interactive=interactive)

    @icm.subjectToTracking(fnLoc=True, fnEntry=True, fnExit=True)
    def targetsListProc(pathTargetsList):
        """Process List of Ephemera and Persistent Targets"""
        @icm.subjectToTracking(fnLoc=True, fnEntry=True, fnExit=True)
        def targetProc(thisPathTarget):
            """Process One Target"""
            @icm.subjectToTracking(fnLoc=True, fnEntry=True, fnExit=True)
            def paramsListProc(paramsList):
                """Process List of Parameters"""
                @icm.subjectToTracking(fnLoc=True, fnEntry=True, fnExit=True)
                def paramProc(thisParam):
                    """At this point, we have the target and the parameter, ready for processing.
                    - From thisParam's fileParams, get the agent and parName, 
                    - Then remoteExec the agent on target and get the results.
                    - Record the obtained results with local invokation of the agent.
                    """

                    icm.TM_here('targetPath=' +
                                thisPathTarget)  # Target Access Information
                    icm.TM_here(format('ticmoBase=' +
                                       thisTicmoBase))  # TICMO Base

                    paramBase = thisParam.base()
                    icm.TM_here('paramBase=' + paramBase)

                    agent = icm.FILE_ParamValueReadFrom(parRoot=paramBase,
                                                        parName='agent')
                    if not agent: return (icm.EH_problem_unassignedError())

                    parName = icm.FILE_ParamValueReadFrom(parRoot=paramBase,
                                                          parName='parName')
                    if not parName: return (icm.EH_problem_unassignedError())

                    commandLine = format(agent + ' -p mode=agent -i ' +
                                         parName)
                    icm.LOG_here('RemoteExec: ' + commandLine)

                    resultLines = linuxTarget.runCommand(
                        connection, commandLine)

                    pipeableResultLines = ""
                    for thisResultLine in resultLines:
                        pipeableResultLines = pipeableResultLines + thisResultLine + '\n'

                    icm.LOG_here('ResultLines: ' + str(resultLines))

                    # We can now dateVer and empnaPkg write the resultLines for parName in TICMO
                    #fileParWriteBase = os.path.join(thisTicmoBase, empnaPkg, dateVer)

                    # updated =  icm.FILE_ParamWriteTo(parRoot=fileParWriteBase,
                    #                               parName=parName,
                    #                               parValue=resultLines[0])

                    #
                    # We ask the agent to capture the resultLines in ticmo
                    #
                    commandLine = format(
                        agent + ' ' +
                        '-n showRun -p mode=capture -p ticmoBase=' + ' -i ' +
                        parName)
                    commandArgs = shlex.split(commandLine)

                    icm.LOG_here('SubProc: ' + commandLine)
                    p = subprocess.Popen(commandArgs,
                                         stdin=subprocess.PIPE,
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE)

                    out, err = p.communicate(
                        input=format(pipeableResultLines.encode()))

                    if out: icm.ANN_note("Stdout: " + out)
                    if err: icm.ANN_note("Stderr: " + err)

                    return

                for thisParam in paramsList:
                    paramProc(thisParam)
                return

            linuxTarget = toIcm.TARGET_Proxy_Linux(basePath=thisPathTarget)

            accessParams = linuxTarget.accessParamsGet()
            targetId = accessParams.targetFqdnValue

            thisTicmoBase = toIcm.targetBaseGet(targetId=targetId)

            connection = linuxTarget.connect()

            paramsListProc(targetParamsList)

            return

        for thisPathTarget in pathTargetsList:
            targetProc(thisPathTarget)

        return

    targetsListProc(targetsAccessList)

    #empna.dateVerRecordForNext(dateVer=dateVer)

    return
示例#17
0
    def cmnd(
            self,
            interactive=False,  # Can also be called non-interactively
            bxoId=None,  # or Cmnd-Input
            sr=None,  # or Cmnd-Input
            inFile=None,  # or Cmnd-Input
            msg=None,  # asFunc when interactive==False
    ):
        cmndOutcome = self.getOpOutcome()
        if interactive:
            if not self.cmndLineValidate(outcome=cmndOutcome):
                return cmndOutcome

        callParamsDict = {
            'bxoId': bxoId,
            'sr': sr,
            'inFile': inFile,
        }
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome
        bxoId = callParamsDict['bxoId']
        sr = callParamsDict['sr']
        inFile = callParamsDict['inFile']

        ####+END:
        G = icm.IcmGlobalContext()

        if not msg:
            if inFile:
                msg = msgIn.getMsgFromFile(inFile)
            else:
                # Stdin then
                msg = msgIn.getMsgFromStdin()
        else:
            # non-interactive call with msg
            if not bxoId:
                icm.EH_problem_usageError("")
                return cmndOutcome

        icm.LOG_here(msgOut.strLogMessage(
            "Msg As Input:",
            msg,
        ))

        icm.LOG_here(G.icmRunArgsGet().runMode)

        outcome = msgOut.sendingRunControlSet(msg, G.icmRunArgsGet().runMode)
        if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

        bx822Set_setMandatoryFields(msg)

        outcome = bx822Get_sendingFieldsPipelineLoad(
            bxoId,
            sr,
            msg,
        )
        if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

        if outcome.results != "INCOMPLETE":
            icm.LOG_here("Complete Message Being Sent")
            return (msgOut.sendBasedOnHeadersInfo(msg))

        icm.LOG_here("Incomplete Message -- using qmail+dryrun")

        msgOut.injectionParams(
            msg,
            injectionProgram=msgOut.InjectionProgram.qmail,
            sendingRunControl=msgOut.SendingRunControl.dryRun,
        )

        return msgOut.sendBasedOnHeadersInfo(msg)
示例#18
0
*  [[elisp:(org-cycle)][| ]]  [[elisp:(org-show-subtree)][|=]] [[elisp:(show-children 10)][|V]] [[elisp:(org-tree-to-indirect-buffer)][|>]] [[elisp:(blee:ppmm:org-mode-toggle)][Nat]] [[elisp:(beginning-of-buffer)][Top]] [[elisp:(delete-other-windows)][(1)]] || =Imports=      :: *IMPORTS*  [[elisp:(org-cycle)][| ]]
"""
####+END:

import os
#import collections
#import enum


####+BEGIN: bx:dblock:global:file-insert :file "/libre/ByStar/InitialTemplates/update/sw/icm/py/importUcfIcmG.py"
from unisos import ucf
from unisos import icm

icm.unusedSuppressForEval(ucf.__file__)  # in case icm and ucf are not used

G = icm.IcmGlobalContext()
G.icmLibsAppend = __file__
G.icmCmndsLibsAppend = __file__

####+END:


import sys
import os

import collections

from unisos import ucf
from unisos import icm

from blee.icmPlayer import bleep
示例#19
0
def g_argsExtraSpecify(parser, ):
    ####+END:
    """Module Specific Command Line Parameters.
    g_argsExtraSpecify is passed to G_main and is executed before argsSetup (can not be decorated)
    """
    G = icm.IcmGlobalContext()
    icmParams = icm.ICM_ParamDict()

    icmParams.parDictAdd(
        parName='moduleVersion',
        parDescription="Module Version",
        parDataType=None,
        parDefault=None,
        parChoices=list(),
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--version',
    )

    icmParams.parDictAdd(
        parName='rsrc',
        parDescription="Resource",
        parDataType=None,
        parDefault=None,
        parChoices=["someResource", "UserInput"],
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--rsrc',
    )

    icmParams.parDictAdd(
        parName='inFile',
        parDescription="Input File",
        parDataType=None,
        parDefault=None,
        parChoices=["someFile", "UserInput"],
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--inFile',
    )

    icmParams.parDictAdd(
        parName='baseDir',
        parDescription="Base Directory Name",
        parDataType=None,
        parDefault=None,
        parChoices=[],
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--baseDir',
    )

    icmParams.parDictAdd(
        parName='policy',
        parDescription="Encryption Policy",
        parDataType=None,
        parDefault=None,
        parChoices=[],
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--policy',
    )

    icmParams.parDictAdd(
        parName='keyringPolicy',
        parDescription="Policy For Setting Passwd In Keyring",
        parDataType=None,
        parDefault=None,
        parChoices=[
            'prompt',
            'default',
        ],
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--keyringPolicy',
    )

    icmParams.parDictAdd(
        parName='alg',
        parDescription="Symetric Encryption Algorithem",
        parDataType=None,
        parDefault=None,
        parChoices=[
            'default',
            'someAlg',
        ],
        parScope=icm.ICM_ParamScope.TargetParam,
        argparseShortOpt=None,
        argparseLongOpt='--alg',
    )

    bleep.commonParamsSpecify(icmParams)

    cryptKeyring.commonParamsSpecify(icmParams)

    icm.argsparseBasedOnIcmParams(parser, icmParams)

    # So that it can be processed later as well.
    G.icmParamDictSet(icmParams)

    return