Maximo Open Forum

 View Only
  • 1.  Automation Script error writing to S3 bucket in AWS (Red Hat) environment

    Posted 4 days ago

    I am having an issue with automation script.  It used to work fine on Prim in Maximo 7.6.1.3.  The script creates an AWARD memo (BIRT report) and attach it to Work order and saves it in DOCLINK folder.

    Now in MAS9, it's giving error writing to S3 folders in AWSs environment, any help or guidance will be great, I am new to AWS- Red Hat arena.

    here is script:

    from psdi.server import MXServer

    from com.ibm.tivoli.maximo.report.birt.admin import ReportAdminServiceRemote

    from com.ibm.tivoli.maximo.report.birt.runtime import ReportParameterData

    from java.text import SimpleDateFormat

    from psdi.mbo import MboConstants

    from psdi.util.logging import MXLoggerFactory

    # var_rptname = ''

    #userinfo = mbo.getUserInfo()

    #para = ReportParameterData()

    def getDoclinksDir(myDocType):

        doctypesMboSet = MXServer.getMXServer().getMboSet("DOCTYPES", mbo.getUserInfo())

        doctypesMboSet.setWhere("DOCTYPE = " + "'" + myDocType + "'")

        doctypesMboSet.reset()

        doctypesMbo = doctypesMboSet.moveFirst();

        return doctypesMbo.getString("DEFAULTFILEPATH")

       

    def generateReport():

        if mbo.getString("STATUS") == 'APPR' and not mbo.isNull("glaccount") :

            sdf = SimpleDateFormat("yyyyMMddhhmmss")

            maximo= MXServer.getMXServer()

            userinfo = mbo.getUserInfo()

            para = ReportParameterData()

            var_rptname = ''

            var_filename ='AwardMemo'

            var_wonum = mbo.getString("WONUM")

            filepath = getDoclinksDir("AwardMemo")

            newType ='SentAward'

            var_rptname = 'FMS_PROJECT_Award_Memo.rptdesign'

            xdoclinksMboSet = mbo.getMboSet("PROJECTAWARDLINKS")

            # Relationship to DOCLINKS

            # (ownertable='WORKORDER' and ownerid=:workorderid  and doctype='InspMemo')

            filename2 = var_filename+ "-"+var_wonum+"-"+ sdf.format(maximo.getDate())

            filename3 = filepath + "/" + filename2 + ".pdf"

            para.addParameter("wonum", var_wonum)

            reportService = MXServer.getMXServer().lookup("BIRTREPORT")

            outputReport = reportService.runReport(userinfo, var_rptname, "WOTRACK", para, filename2, "pdf")

            report_file = open(filename3,"wb")

    #        report_file.write(outputReport)

    #        report_file.flush()

    #        report_file.close()

        # change the previous awardmemo to a diff doctype so that on the communication template only

        # the latest memo will be sent - template sends all Image folder

         

            docl = xdoclinksMboSet.moveFirst()

            if docl is not None:

                var_DOCTYPE = newType

            else:

                var_DOCTYPE = var_filename

           

            doclinksMboSet = mbo.getMboSet("DOCLINKS")

            doclinksMbo = doclinksMboSet.add()

            doclinksMbo.setValue("URLTYPE", "FILE")

            doclinksMbo.setValue("URLNAME", filename3)

            doclinksMbo.setValue("NEWURLNAME", filename3)

            doclinksMbo.setValue("DOCTYPE", var_DOCTYPE)

            doclinksMbo.setValue("ADDINFO", True)

            doclinksMbo.setValue("DOCUMENT", var_filename)

            doclinksMbo.setValue("DESCRIPTION", filename2)

            doclinksMboSet.save()

           

            clMbo =  mbo.createComm()

            clMbo.setValue('TEMPLATEID', 'PROJAWARD')

            try:

                clMbo.sendMessage()

            except:

                clMbo.setValue("ISSENDFAIL", True, mbo.NOACCESSCHECK)

    if (mbo.getString("STATUS") == 'APPR') and mbo.getString("WORKTYPE") == 'PROJECT':

        generateReport()


    #MaximoApplicationSuite

    ------------------------------
    Hardev Bal
    Navitas
    ------------------------------


  • 2.  RE: Automation Script error writing to S3 bucket in AWS (Red Hat) environment

    Posted 4 days ago
    Edited by Steven Shull 4 days ago

    There's a generic framework for attachment handling that will simplify your experience. Add the following import

    from com.ibm.tivoli.maximo.oslc.provider import AttachmentStorage

    And then after you call doclinksMbo = doclinksMboSet.add() do the following

    docStore=AttachmentStorage.getInstance()
    newFileName=docStore.getAttachmentQualifiedName(doclinksMbo,filename2)
    docStore.createAttachment(newFileName,outputReport,"application/pdf")

    Note: filename3 and filepath would go away as well as getDoclinksDir method. DOCTYPES are now metadata only meaning it doesn't change the folder structure for new attachments. On the NEWURLNAME and URLNAME you would set the value to newFileName



    ------------------------------
    Steven Shull
    Naviam
    ------------------------------



  • 3.  RE: Automation Script error writing to S3 bucket in AWS (Red Hat) environment

    Posted 21 hours ago
      |   view attached

    @Steven Shull, thank you for this tip. To confirm before getting overly excited, is it possible to request the MAS 9.2 logic in comparison to 7.6.1?

    My request is not a priority; however, regarding the script shared by @Hardev Bal, the full scope of the script would be helpful. 

    For context, I'm sharing a recent analysis of my responses to More Maximo's forum in July regarding MAS 9.2 enhancements released in parallel. I am still drawing insights from the analysis. Using IBM's MAS 9.2 documentation as an unbiased source of truth is providing a broader perspective on the underlying root causes of performance degradation for the questions I have answered.  

    MAS adds a level of complexity to DOCLINKS

     



    ------------------------------
    Fredrick Ndwaru
    Perpetual Ignition
    ------------------------------

    Attachment(s)



  • 4.  RE: Automation Script error writing to S3 bucket in AWS (Red Hat) environment

    Posted 20 hours ago

    The logic I shared works on at least 7.6.1.2+ (I can't remember what version of Maximo S3 attachments were supported in, but I know it existed at least in 7.6.1.2) including MAS 9.0, 9.1, and 9.2. This is what the Maximo framework utilizes to abstract attachment handling so that the REST API for example can work with any supported storage provider. In MAS 9.1+ this includes Azure blob storage. This also supports customers that have configured their own handler via automation script for systems like SharePoint, Box, etc. 



    ------------------------------
    Steven Shull
    Naviam
    ------------------------------



  • 5.  RE: Automation Script error writing to S3 bucket in AWS (Red Hat) environment

    Posted 14 hours ago

    Thanks, @Steven Shull. As a baseline, your response is more than sufficient and much appreciated. 



    ------------------------------
    Fredrick Ndwaru
    Perpetual Ignition
    ------------------------------



  • 6.  RE: Automation Script error writing to S3 bucket in AWS (Red Hat) environment

    Posted 13 hours ago

    @Steven Shull - Thanks 



    ------------------------------
    Fredrick Ndwaru
    Perpetual Ignition
    ------------------------------



Newest Episode
Ep. 4 | System Properties in IBM Maximo

Watch Steven Shull walk through practical IBM Maximo system properties that can improve usability, query behavior, attachment handling, and the overall Maximo user experience.

MORE by Naviam Episode 4 cover
Watch Episode 4
Also available: Ep. 3 | Work Order Role-Based Application