Ejemplo n.º 1
0
def testRest():
    # cfg = store.readConfig()
    cfg = {'host': '172.27.0.1:8000', 'masterKey': '8f914604ad2c5c558575856299866bbb', 'ssl': False}
    print(cfg)
    print("Intefaces: ", list(operations.getNetworkInfo()))
    print("Joined Domain: ", operations.getDomainName())

    # renameComputer('win7-64')
    # joinDomain('dom.dkmon.com', 'ou=pruebas_2,dc=dom,dc=dkmon,dc=com', '*****@*****.**', 'Temporal2012', True)
    # reboot()
    r = REST.Api(cfg['host'], cfg['masterKey'], cfg['ssl'], scrambledResponses=True)
    print("Connected: {}".format(r.isConnected))
    r.test()
    try:
        r.init('02:46:00:00:00:07')
    except REST.UnmanagedHostError:
        print('Unmanaged host (confirmed)')

    uuid = r.init('02:46:00:00:00:08')
    print("Notify comm:", r.notifyComm('http://172.27.0.1:8000/'))

    print("Connected: {}".format(r.isConnected))

    print('uuid = {}'.format(uuid))

    # print 'Login: {}'.format(r.login('test-user'))
    # print 'Logout: {}'.format(r.logout('test-user'))
    print("Information: >>{}<<".format(r.information()))
    print("Login: >>{}<<".format(r.login('Pepito')))

    print(r.setReady([(v.mac, v.ip) for v in operations.getNetworkInfo()]))
    print(r.log(10000, 'Test error message'))
Ejemplo n.º 2
0
 def multiStepJoin(self, name, domain, ou, account, password):
     currName = operations.getComputerName()
     if currName.lower() == name.lower():
         currDomain = operations.getDomainName()
         logger.debug('Name: "{}" vs "{}", Domain: "{}" vs "{}"'.format(currName.lower(), name.lower(), currDomain.lower(), domain.lower()))
         if currDomain is not None:
             logger.info(
                 'Machine {} is part of domain {}'.format(name, domain))
             self.setReady()
         else:
             operations.joinDomain(
                 domain, ou, account, password, executeInOneStep=False)
     else:
         operations.renameComputer(name)
         logger.info(
             'Rebooting computer got activate new name {}'.format(name))
         self.reboot()
Ejemplo n.º 3
0
 def multiStepJoin(self, name, domain, ou, account, password):
     currName = operations.getComputerName()
     if currName.lower() == name.lower():
         currDomain = operations.getDomainName()
         if currDomain is not None:
             # logger.debug('Name: "{}" vs "{}", Domain: "{}" vs "{}"'.format(currName.lower(), name.lower(), currDomain.lower(), domain.lower()))
             logger.info(
                 'Machine {} is part of domain {}'.format(name, domain))
             self.setReady()
         else:
             operations.joinDomain(
                 domain, ou, account, password, executeInOneStep=False)
             self.reboot()
     else:
         operations.renameComputer(name)
         logger.info(
             'Rebooting computer got activate new name {}'.format(name))
         self.reboot()
Ejemplo n.º 4
0
def testRest():
    # cfg = store.readConfig()
    cfg = {
        'host': '172.27.0.1:8000',
        'masterKey': '8f914604ad2c5c558575856299866bbb',
        'ssl': False
    }
    print(cfg)
    print("Intefaces: ", list(operations.getNetworkInfo()))
    print("Joined Domain: ", operations.getDomainName())

    # renameComputer('win7-64')
    # joinDomain('dom.dkmon.com', 'ou=pruebas_2,dc=dom,dc=dkmon,dc=com', '*****@*****.**', 'Temporal2012', True)
    # reboot()
    r = REST.Api(cfg['host'],
                 cfg['masterKey'],
                 cfg['ssl'],
                 scrambledResponses=True)
    print("Connected: {}".format(r.isConnected))
    r.test()
    try:
        r.init('02:46:00:00:00:07')
    except REST.UnmanagedHostError:
        print('Unmanaged host (confirmed)')

    uuid = r.init('02:46:00:00:00:08')
    print("Notify comm:", r.notifyComm('http://172.27.0.1:8000/'))

    print("Connected: {}".format(r.isConnected))

    print('uuid = {}'.format(uuid))

    # print 'Login: {}'.format(r.login('test-user'))
    # print 'Logout: {}'.format(r.logout('test-user'))
    print("Information: >>{}<<".format(r.information()))
    print("Login: >>{}<<".format(r.login('Pepito')))

    print(r.setReady([(v.mac, v.ip) for v in operations.getNetworkInfo()]))
    print(r.log(10000, 'Test error message'))