Exemplo n.º 1
0
 def sendEvent(self, msg, type):
     self.sock = socket(AF_INET, SOCK_DGRAM)
     if type == 'syslog':
         port = SYSLOG_PORT
         if '$randomNum' in msg:
             msg = msg.replace('$randomNum',
                               randomGen.getRandomNum(100, 900))
         if '$randomIP' in msg:
             msg = msg.replace('$randomIP', randomGen.getRandomIPAddr())
     elif type == 'netflow':
         port = NETFLOW_PORT
         msg = GenerateNetFlowData.getNetFlowPacket(msg)
     try:
         self.sock.connect((self.dataCollector, port))
     except error:
         print 'Cannot open socket to %s' % self.dataCollector
         exit()
     self.sock.sendall(msg)
Exemplo n.º 2
0
 def __init__(self):
     self.attribute = {}
     self.attribute['size'] = getRandomNum(5000000, 9000000)
     self.attribute['used'] = getRandomNum(0, 5000000)
Exemplo n.º 3
0
 def __init__(self):
     self.attribute = {}
     self.attribute['name'] = ''
     self.attribute['used'] = getRandomNum(1000000, 3000000)
     self.attribute['total'] = getRandomNum(30000000, 90000000)
Exemplo n.º 4
0
 def __init__(self):
     self.attribute = {}
     self.attribute['id'] = ''
     self.attribute['load'] = getRandomNum(1, 10)
Exemplo n.º 5
0
def addUser(id, type, totalUsers, postFix=False):
    userlist = []
    if postFix:
        name = USER_NAME + postFix
    else:
        name = USER_NAME

    for i in range(totalUsers):
        myUser = user()
        myUser.name = name + type.replace(" ", "") + str(i + 1)
        myUser.naturalId = 'autoUserId' + type.replace(" ", "") + str(i + 1)
        myUser.fullName = 'autoUser autoTester' + type.replace(" ",
                                                               "") + str(i + 1)
        myUser.jobTitle = 'autoUser job-tester' + type.replace(" ",
                                                               "") + str(i + 1)
        myUser.company = 'auto testing company'
        myUser.description = 'auto tester description item' + str(i + 1)
        myUser.domain = 'autotesting'
        myUser.dn = 'cn=test,cn=users,dc=autotest,dc=com'
        myUser.privileged = "true"
        myUser.password = '******'
        myUser.active = "true"
        myUser.effectiveCustId = id

        contacts = []
        myContact = contact()
        myContact.primary = "false"
        myContact.name = 'autoTester' + type.replace(" ", "") + str(i + 1)
        myContact.address = 'autoTest address item' + str(i + 1)
        myContact.address2 = 'Suite Number 1000' + str(i + 1)
        myContact.city = 'Santa Clara'
        myContact.state = 'CA'
        myContact.country = 'USA'
        myContact.description = 'contact item' + str(i + 1)
        myContact.zip = '97654'
        myContact.email = myUser.name + '@tester.com'
        myContact.homePhone = getRandomNum(500, 900) + '-' + getRandomNum(
            1000, 9999)
        myContact.workPhone = getRandomNum(500, 900) + '-' + getRandomNum(
            1000, 9999)
        myContact.mobilePhone = getRandomNum(500, 900) + '-' + getRandomNum(
            1000, 9999)
        myContact.smsNumber = getRandomNum(600000, 700000)
        myContact.smsProvider = 'att'
        contacts.append(myContact)
        myUser.contacts = contacts

        myRbac = RbacProfile()
        myRbac.name = type
        myUser.primaryProfile = myRbac

        myOrg = domain()
        myOrg.id = id
        orgs = []
        orgs.append(myOrg)
        myUser.orgs = orgs

        mapping = []
        mapping.append(myOrg)
        mapping.append(myRbac)
        myUser.orgRoleMappings = mapping

        userlist.append(myUser)

    myDoc = dom.Document()
    attribute = dict(custId=id)
    node = XMLHelper.pickle(userlist, myDoc, 'users')
    node.setAttribute("custId", id)

    #myObj=config(userlist)
    # node=XMLHelper.pickle(root=userlist, fabric=dom.Document(), elementName='users')
    myXml = node.toxml()
    #myId='<users custId="'+org+'">'
    myXml = myXml.replace('key', 'domain')
    myXml = myXml.replace('value', 'RbacProfile')
    print myXml

    return myXml
Exemplo n.º 6
0
                        myHandler.sendEvent(setMsg2)
                        time.sleep(120)

                for i in range(0, int(case.repeatCount)):
                    for j in range(0, len(case.events)):
                        if testSuite.method == 'netflow':
                            realMsg = GenerateNetFlowData.getNetFlowPacket(
                                case.events[j].incidentMsg)
                        else:
                            if '$randomIP' in case.events[j].incidentMsg:
                                ipMsg = case.events[j].incidentMsg.replace(
                                    "$randomIP", randomGen.getRandomIPAddr())
                            elif 'randomNum' in case.events[j].incidentMsg:
                                ipMsg = case.events[j].incidentMsg.replace(
                                    "$randomNum",
                                    randomGen.getRandomNum(100, 900))
                            else:
                                ipMsg = case.events[j].incidentMsg
                            realMsg = ipMsg.decode()
                        myHandler.sendEvent(realMsg)
                        logging.debug(realMsg)
                    if case.repeatInterval != '':
                        time.sleep(float(case.repeatInterval))

            myHandler.udpClientClose()

    finalResult = None
    if option != "SendOnly":
        if 'sleep' in config:
            sleepTime = float(config['sleep']) * 60
        else:
Exemplo n.º 7
0
 def up_time(self, map):
     map['up_time']=randomGen.getRandomNum(2722222, 3733333)
Exemplo n.º 8
0
 def hw_sn(self, map):
     map['hw_sn']=randomGen.getRandomNum(1000000000000000, 5999999999999999)