Esempio n. 1
0
def create(s, sip):
    if len(s) == 12:
        os = OS()
        os.operatingsystem = s['operatingsystem']
        os.operatingsystemrelease = s['operatingsystemrelease']
        os.kernel = s['kernel']
        os.kernelversion = s['kernelversion']
        os.save()

        hardware = HARDWARE()
        hardware.architecture = s['architecture']
        hardware.processortype = s['processortype']
        hardware.processorcount = s['processorcount']
        hardware.memorytotal = s['memorytotal']
        hardware.uniqueid = s['uniqueid']
        hardware.is_virtual = True if s['is_virtual'] == 'True' else False
        hardware.save()

        ip = IP()
        ip.ipv4 = sip
        ip.save()

        host = Host()
        host.name = s['hostname']
        host.save()

        for u in s['user']:
            user = USER()
            user.name = u['name']
            user.group = u['group']
            user.locked = True if u['locked'] == 'true' else False
            user.save()

            res = Resource()
            res.name = 'User list'
            res.type = 'user'
            res.resource_id = user.id
            res.host = host
            res.save()

        res = Resource()
        res.name = 'OS'
        res.type = 'os'
        res.resource_id = os.id
        res.host = host
        res.save()

        res = Resource()
        res.name = 'Hardware'
        res.type = 'hardware'
        res.resource_id = hardware.id
        res.host = host
        res.save()

        res = Resource()
        res.name = 'IP Address'
        res.type = 'ip'
        res.resource_id = ip.id
        res.host = host
        res.save()
Esempio n. 2
0
File: host.py Progetto: qsm365/cmdb
def create(s,sip):
    if len(s)==12:
        os=OS()
        os.operatingsystem=s['operatingsystem']
        os.operatingsystemrelease=s['operatingsystemrelease']
        os.kernel=s['kernel']
        os.kernelversion=s['kernelversion']
        os.save()
        
        hardware=HARDWARE()
        hardware.architecture=s['architecture']
        hardware.processortype=s['processortype']
        hardware.processorcount=s['processorcount']
        hardware.memorytotal=s['memorytotal']
        hardware.uniqueid=s['uniqueid']
        hardware.is_virtual=True if s['is_virtual']=='True' else False
        hardware.save()
        
        ip=IP()
        ip.ipv4=sip
        ip.save()
                
        host=Host()
        host.name=s['hostname']
        host.save()
                
        for u in s['user']:
            user=USER()
            user.name=u['name']
            user.group=u['group']
            user.locked=True if u['locked']=='true' else False
            user.save()
            
            res=Resource()
            res.name='User list'
            res.type='user'
            res.resource_id=user.id
            res.host=host
            res.save()
        
        res=Resource()
        res.name='OS'
        res.type='os'
        res.resource_id=os.id
        res.host=host
        res.save()
        
        res=Resource()
        res.name='Hardware'
        res.type='hardware'
        res.resource_id=hardware.id
        res.host=host
        res.save()
        
        res=Resource()
        res.name='IP Address'
        res.type='ip'
        res.resource_id=ip.id
        res.host=host
        res.save()
Esempio n. 3
0
def update(hostid, s, sip):
    if len(s) == 12:
        host = Host.objects.filter(id=hostid)
        if host:
            host = host.first()
            os_rid = Resource.objects.filter(host=host, type='os')
            hw_rid = Resource.objects.filter(host=host, type='hardware')
            user_rid = Resource.objects.filter(host=host, type='user')
            for rid in os_rid:
                OS.objects.filter(id=rid.resource_id).all().delete()
                rid.delete()
            for rid in hw_rid:
                HARDWARE.objects.filter(id=rid.resource_id).all().delete()
                rid.delete()
            for rid in user_rid:
                USER.objects.filter(id=rid.resource_id).all().delete()
                rid.delete()
            os = OS()
            os.operatingsystem = s['operatingsystem']
            os.operatingsystemrelease = s['operatingsystemrelease']
            os.kernel = s['kernel']
            os.kernelversion = s['kernelversion']
            os.save()

            res = Resource()
            res.name = 'OS'
            res.type = 'os'
            res.resource_id = os.id
            res.host = host
            res.save()

            hardware = HARDWARE()
            hardware.architecture = s['architecture']
            hardware.processortype = s['processortype']
            hardware.processorcount = s['processorcount']
            hardware.memorytotal = s['memorytotal']
            hardware.uniqueid = s['uniqueid']
            hardware.is_virtual = True if s['is_virtual'] == 'True' else False
            hardware.save()

            res = Resource()
            res.name = 'Hardware'
            res.type = 'hardware'
            res.resource_id = hardware.id
            res.host = host
            res.save()

            for u in s['user']:
                user = USER()
                user.name = u['name']
                user.group = u['group']
                user.locked = True if u['locked'] == 'true' else False
                user.save()

                res = Resource()
                res.name = 'User list'
                res.type = 'user'
                res.resource_id = user.id
                res.host = host
                res.save()
Esempio n. 4
0
File: host.py Progetto: qsm365/cmdb
def update(hostid,s,sip):
    if len(s)==12:
        host=Host.objects.filter(id=hostid)
        if host:
            host=host.first()
            os_rid=Resource.objects.filter(host=host,type='os')
            hw_rid=Resource.objects.filter(host=host,type='hardware')
            user_rid=Resource.objects.filter(host=host,type='user')
            for rid in os_rid:
                OS.objects.filter(id=rid.resource_id).all().delete()
                rid.delete()
            for rid in hw_rid:
                HARDWARE.objects.filter(id=rid.resource_id).all().delete()
                rid.delete()
            for rid in user_rid:
                USER.objects.filter(id=rid.resource_id).all().delete()
                rid.delete()
            os=OS()
            os.operatingsystem=s['operatingsystem']
            os.operatingsystemrelease=s['operatingsystemrelease']
            os.kernel=s['kernel']
            os.kernelversion=s['kernelversion']
            os.save()
            
            res=Resource()
            res.name='OS'
            res.type='os'
            res.resource_id=os.id
            res.host=host
            res.save()
            
            hardware=HARDWARE()
            hardware.architecture=s['architecture']
            hardware.processortype=s['processortype']
            hardware.processorcount=s['processorcount']
            hardware.memorytotal=s['memorytotal']
            hardware.uniqueid=s['uniqueid']
            hardware.is_virtual=True if s['is_virtual']=='True' else False
            hardware.save()
            
            res=Resource()
            res.name='Hardware'
            res.type='hardware'
            res.resource_id=hardware.id
            res.host=host
            res.save()
            
            for u in s['user']:
                user=USER()
                user.name=u['name']
                user.group=u['group']
                user.locked=True if u['locked']=='true' else False
                user.save()
                
                res=Resource()
                res.name='User list'
                res.type='user'
                res.resource_id=user.id
                res.host=host
                res.save()