示例#1
0
 def get_AR_from_reported_to_manager(self, mmap):
     """
     Gets the platform unity ars from Reported to Manager table
     :param mmap: map containing the query params
     :return:
     """
     self.logger.debug("getting ARs from reported to manage table ..."
                       ) if self.logger else ""
     ars = erars.erARS()
     self._db_login(ars)
     schema = 'EMC:Issue Reported by Manager Join'
     query = self._generate_manager_query_string(mmap)
     """
     fields = ('Entry-Id','Summary','Assigned-to','Direct Manager','Reported by','Create-date','Status','Status Details',
         'Blocking','Priority','Type','Estimated Checkin Date','Reported by Group','Reported by Function',
         'Product Release', 'Product Family','Product Area','Major Area','Releases Built-in','Claassification',
         '# of Dup', 'Version Found')
     """
     fields = (536870921, 536870925, 600000701, 536870929, 600000700, 3, 7,
               536870941, 700000320, 536870922, 536871084, 536871606,
               536871388, 536871389, 536870940, 536871628, 8, 536871412,
               536871455, 536870927, 536870945, 536870914)
     try:
         self.logger.debug(
             "getting list entry with fields ...") if self.logger else ""
         (entries,
          num) = ars.GetListEntryWithFields(schema, query, fields, None)
         self.logger.debug("got %s of entries" %
                           (str(num))) if self.logger else ""
     except Exception, e:
         self.logger.error(e) if self.logger else ""
         time.sleep(5)
         (entries,
          num) = ars.GetListEntryWithFields(schema, query, fields, None)
示例#2
0
 def get_child_ar_from_audit_trail(self, entry_id, start_date, end_date):
     ars = erars.erARS()
     self._db_login(ars)
     schema = 'EMC:Issue_Audit_join'
     query = ""
     query = query + "'536870921'=\"" + str(
         entry_id) + "\" AND "  # Entry_ID
     query = query + "'536870925'=\"Classification\" AND "  # "attribute change part"="Product Area"
     query = query + "'536870917'=\"Child\""  # "To Value"="CS Linux"
     # Rules for change time of the "Attribute"
     #query = query + "('536870929'>=" + str(start_date) + ") AND ('536870929'<=" + str(end_date) + ")"
     #print "get child query:",query
     fields = (536870921, 536870916, 536870917, 536870929, 536870938)
     try:
         self.logger.debug(
             "getting list entry with fields ...") if self.logger else ""
         (entries,
          num) = ars.GetListEntryWithFields(schema, query, fields, None)
         self.logger.debug("got %s of entries" %
                           (str(num))) if self.logger else ""
     except Exception, e:
         self.logger.error(e) if self.logger else ""
         time.sleep(5)
         (entries,
          num) = ars.GetListEntryWithFields(schema, query, fields, None)
示例#3
0
 def get_AR_from_assigned_to_manager(self, mmap):
     """
     Gets the platform unity ars from Assigned to Manager table
     :param mmap: map containing the query params
     :return:
     """
     self.logger.debug("getting ARs from assigned to manage table ..."
                       ) if self.logger else ""
     ars = erars.erARS()
     self._db_login(ars)
     schema = 'EMC:Issue Assigned-to Manager Join'
     '''
     query = """
             ('Product Family' = "Unified Systems") AND ('Senior Manager' = "Yan, Sam")
             AND  ('Assigned-to' = ["\"wange11\"","\"niej\"","\"huangj30\"","\"luy14\"","\"caic2\"","\"zhuanc2\"","\"hux5\"","\"xiaa3\"","\"huj24\"","\"fanw4\"","\"fuf3\""])
             AND  ('Status' =  "Open" OR 'Status'  =  "Waiting on Originator")
             AND 'Parent Bug #' = $NULL$  AND 'Type' =  "Bug" AND 'Priority' <  "P03"
             AND 'Product Release' = "Merlin"
             """
     '''
     query = self._generate_manager_query_string(mmap)
     #remove 'AND' before ()
     import re
     query = re.sub("^(\s+\w+\s+)\(", "(", query, 1)
     #self.logger.debug("query : " + query)
     """
     fields = ('Entry-Id','Summary','Assigned-to','Direct Manager','Reported by','Create-date','Status','Status Details',
             'Blocking','Priority','Type','Estimated Checkin Date','Reported by Group','Reported by Function',
             'Product Release', 'Product Family','Product Area','Major Area', 'Releases Built-in', 'Claassification',
             '# of Dup', 'Version Found')
     """
     fields = (536870921, 536870925, 600000701, 536870929, 600000700, 3, 7,
               536870941, 700000320, 536870922, 536871084, 536871606,
               536871388, 536871389, 536870940, 536871628, 8, 536871412,
               536871455, 536870927, 536870945, 536870914, 536871535)
     try:
         self.logger.debug(
             "getting list entry with fields ...") if self.logger else ""
         (entries,
          num) = ars.GetListEntryWithFields(schema, query, fields, None)
         self.logger.debug("got %s of entries" %
                           (str(num))) if self.logger else ""
     except Exception, e:
         self.logger.error(e) if self.logger else ""
         time.sleep(5)
         (entries,
          num) = ars.GetListEntryWithFields(schema, query, fields, None)
示例#4
0
 def get_employee(self, ddict):
     ars = erars.erARS()
     self._db_login(ars)
     schema = 'EMC:SHARE:Employee'
     query = self._get_employee_query_string(ddict)
     fields = (536870929, 536870917, 536870930)
     try:
         self.logger.debug(
             "getting list entry with fields ...") if self.logger else ""
         (entries,
          num) = ars.GetListEntryWithFields(schema, query, fields, None)
         self.logger.debug("got %s of entries" %
                           (str(num))) if self.logger else ""
     except Exception, e:
         self._db_logoff(ars)
         self.logger.error(e) if self.logger else ""
         time.sleep(5)
         (entries,
          num) = ars.GetListEntryWithFields(schema, query, fields, None)
示例#5
0
 def get_AR_from_audit_trail(self, dict):
     ars = erars.erARS()
     self._db_login(ars)
     schema = 'EMC:Issue_Audit_join'
     query = self._get_audit_trail_query_string(dict)
     #fields =(536870929,536870917,536870916,536870921,536870925,536870927,536871628,536870940)
     # To retrieve following fields in schema: 'EMC:Issue_Audit_join'
     #    Entry-Id:                536870921
     #    From Value:              536870916
     #    To Value:                536870917
     #    Create Date(touch date): 536870929
     #    Submitter2(touch_man):   536870938
     #    Assigned-to Full Name:   600000701
     #    Product Area:            8
     #    Status:                  7
     #    Status Details:          536870941
     #    ckbx_Not A Child:        536871535
     #    Assigned-to:             4
     #    Major Area:              536871412
     #    Type:                    536871084
     #    Create-date:             3
     #    Attribute:               536870925
     #    Product Release :        536870940
     fields = (536870921, 536870916, 536870917, 536870929, 536870938,
               600000701, 8, 7, 536870941, 536871535, 4, 536871412,
               536871084, 3, 536870925, 536870940)
     try:
         self.logger.debug(
             "getting list entry with fields ...") if self.logger else ""
         (entries,
          num) = ars.GetListEntryWithFields(schema, query, fields, None)
         self.logger.debug("got %s of entries" %
                           (str(num))) if self.logger else ""
     except Exception, e:
         self._db_logoff(ars)
         self.logger.error(e) if self.logger else ""
         time.sleep(5)
         (entries,
          num) = ars.GetListEntryWithFields(schema, query, fields, None)
示例#6
0
    def get_fixed_time_from_audit_trail_with_rules(self, entry_id):
        """
        use ar's entry_id to search ar info in the table 'EMC:Issue_Audit_join'.
        :param entry_id: ar's id
        :return: (entries, num) the result is only one ar's info.
        """
        self.logger.debug("getting AR field from audi trial table by AR id..."
                          ) if self.logger else ""
        ars = erars.erARS()
        self._db_login(ars)
        schema = 'EMC:Issue_Audit_join'

        query = ""
        # Rules for "EntryId"
        #query = query + "('536870921'=\"" + entry_id + "\" AND "
        query = query + "('536870921'=\"" + entry_id + "\" AND "
        # Rules for Change of the "Attribute"
        query = query + "'536870926'=\"Field Change\" AND '536870925'=\"Status\""
        # Rules for change time of the "Attribute"
        query = query + " AND '536870917'=\"Fixed\")"

        #print "DEBUG query=[[" + query + "]]"
        # To retrieve following fields in schema: 'EMC:Issue_Audit_join'
        #    Entry-Id:                536870921
        #    Comment:                 536870926
        #    Attribute Label:         536870925
        #    To Value:                536870917
        #    Audit Create Date:       536870929
        #use fields to select which info should be shown in the search results, all the fileds are defined in the related table in library.
        fields = (536870921, 536870926, 536870925, 536870917, 536870929)
        try:
            (entries, num) = ars.GetListEntryWithFields(schema, query, fields)
        except erars.ARError as err:
            print "ARError: wait 5 seconds and try again"
            time.sleep(5)
            (entries, num) = ars.GetListEntryWithFields(schema, query, fields)
        self._db_logoff(ars)
        return (entries, num)
示例#7
0
from pyars import erars, cars
import sys, traceback

print "starting"

ars = erars.erARS()
ars.Login('newfozzy.nit.gwu.edu:3115', 'mwollenw', '')
print "logged in -maybe "




ip = "128.164.213.193"
dhcp = "Belgium:128.164.213.193:002170082498:2010/02/11 17:39:28 GMT:Active:GLSS-GRCFRONT 002170082498"
ticket_title = ip + " - Compromised Machine"
ticket_body = ticket_title + "\nEvent - Machine is hacked and backdoored\nRemediation - Rebuild System\nDCHP - " + dhcp

fieldValue = {#2: 'mwollenw',
              #5: 'mwollenw'
              8: ticket_title,
              200000003: 'Security', #category
              200000004: 'Compromised', #type
              200000005: 'Desktop', #item
              240000006: 'Tech Eng Network',
              240000007: ticket_body, #detailed description
              240000001: 'Unknown', #name   
              240000005: "unknown", #login name
              240000008: "Please disable network connection" #msg
              }
              
from pyars import erars
ars = erars.erARS()
ars.Login('arsystem.isus.emc.com', 'dimsreport', 'report')

for schema in ['EMC:Issue_Audit_join', 'EMC:Issue Notes Join', 'EMC:Issue_Assoc_Instance_join',
               'EMC:SHARE:Employee',
               'EMC:Issue Assigned-to Manager Join', 'EMC:Issue Reported by Manager Join']:
    userFields = ars.GetFieldTable(schema)
    filename = 'table(' + schema.replace(':', ' ') + ').txt'
    with open(filename, "w") as f:
        f.write(str(schema) + '\n')
        f.write('\n')
        for key, value in userFields.iteritems():
            f.write(str(key) + ' : ' + str(value) + '\n')
        f.close()

ars.Logoff()