Ejemplo n.º 1
0
    def rename(self, name, user=None, oldPassword=None, newPassword=None):
        '''
        Renames the computer, and optionally sets a password for an user
        before this
        '''
        hostName = operations.getComputerName()

        if hostName.lower() == name.lower():
            logger.info('Computer name is now {}'.format(hostName))
            self.setReady()
            return

        # Check for password change request for an user
        if user is not None:
            logger.info('Setting password for user {}'.format(user))
            try:
                operations.changeUserPassword(user, oldPassword, newPassword)
            except Exception as e:
                # We stop here without even renaming computer, because the
                # process has failed
                raise Exception(
                    'Could not change password for user {} (maybe invalid current password is configured at broker): {} '
                    .format(user, unicode(e)))

        operations.renameComputer(name)
        # Reboot just after renaming
        logger.info('Rebooting computer to activate new name {}'.format(name))
        self.reboot()
Ejemplo n.º 2
0
    def rename(self, name, user=None, oldPassword=None, newPassword=None):
        '''
        Renames the computer, and optionally sets a password for an user
        before this
        '''
        hostName = operations.getComputerName()

        if hostName.lower() == name.lower():
            logger.info('Computer name is now {}'.format(hostName))
            self.setReady()
            return

        # Check for password change request for an user
        if user is not None:
            logger.info('Setting password for user {}'.format(user))
            try:
                operations.changeUserPassword(user, oldPassword, newPassword)
            except Exception as e:
                # We stop here without even renaming computer, because the
                # process has failed
                raise Exception(
                    'Could not change password for user {} (maybe invalid current password is configured at broker): {} '.format(user, unicode(e)))

        operations.renameComputer(name)
        # Reboot just after renaming
        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()
         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.º 4
0
 def oneStepJoin(self, name, domain, ou, account, password):
     '''
     Ejecutes the join domain in exactly one step
     '''
     currName = operations.getComputerName()
     # If name is desired, simply execute multiStepJoin, because computer
     # name will not change
     if currName.lower() == name.lower():
         self.multiStepJoin(name, domain, ou, account, password)
     else:
         operations.renameComputer(name)
         logger.debug('Computer renamed to {} without reboot'.format(name))
         operations.joinDomain(
             domain, ou, account, password, executeInOneStep=True)
         logger.debug(
             'Requested join domain {} without errors'.format(domain))
         self.reboot()
Ejemplo n.º 5
0
 def oneStepJoin(self, name, domain, ou, account, password):
     '''
     Ejecutes the join domain in exactly one step
     '''
     currName = operations.getComputerName()
     # If name is desired, simply execute multiStepJoin, because computer
     # name will not change
     if currName.lower() == name.lower():
         self.multiStepJoin(name, domain, ou, account, password)
     else:
         operations.renameComputer(name)
         logger.debug('Computer renamed to {} without reboot'.format(name))
         operations.joinDomain(
             domain, ou, account, password, executeInOneStep=True)
         logger.debug(
             'Requested join domain {} without errors'.format(domain))
         self.reboot()
Ejemplo n.º 6
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()