Example #1
0
    def set_password(self, kwargs):
        self.logger.debug('Setting password')
        if self.state != self.S_RUNNING:
            self.logger.debug('Service not runnning')
            return HttpErrorResponse('ERROR: Service not running')
        if not 'user' in kwargs:
            return HttpErrorResponse('ERROR: Required argument \'user\' doesn\'t exist')
        if not 'password' in kwargs:
            return HttpErrorResponse('ERROR: Required argument \'password\' doesn\'t exist')

        # Get the master
        masters = self.config.getMySQLmasters()

        #TODO: modify this when multiple masters
        try:
            for master in masters:
                client.set_password(master.ip, self.config.AGENT_PORT, kwargs['user'], kwargs['password'])
        except:
            e = sys.exc_info()[1]
            self.logger.exception('set_password: Could not set password: %s' % e)
            self.state = self.S_ERROR
            return HttpErrorResponse('Failed to set password')
        else:
            self.root_pass = kwargs['password']
            return HttpJsonResponse()
Example #2
0
    def set_password(self, kwargs):
        self.logger.debug('Setting password')
        if self.state != self.S_RUNNING:
            self.logger.debug('Service not runnning')
            return HttpErrorResponse('ERROR: Service not running')
        if not 'user' in kwargs:
            return HttpErrorResponse('ERROR: Required argument \'user\' doesn\'t exist')
        if not 'password' in kwargs:
            return HttpErrorResponse('ERROR: Required argument \'password\' doesn\'t exist')

        # Get the master
        masters = self.config.getMySQLmasters()

        #TODO: modify this when multiple masters
        try:
            for master in masters:
                client.set_password(master.ip, self.config.AGENT_PORT, kwargs['user'], kwargs['password'])
        except:
            e = sys.exc_info()[1]
            self.logger.exception('set_password: Could not set password: %s' % e)
            self.state = self.S_ERROR
            return HttpErrorResponse('Failed to set password')
        else:
            self.root_pass = kwargs['password']
            return HttpJsonResponse()
Example #3
0
    def set_password(self, kwargs):
        self.logger.debug('Setting password')
        try:
            exp_params = [('user', is_string),
                          ('password', is_string)]
            user, password = check_arguments(exp_params, kwargs)
            self.check_state([self.S_RUNNING])
        except Exception as ex:
            return HttpErrorResponse("%s" % ex)

        one_node = self.config.get_nodes()[0]

        try:
            agent.set_password(one_node.ip, self.config.AGENT_PORT, user, password)
        except Exception as ex:
            self.logger.exception()
            return HttpErrorResponse('Failed to set new password: %s.' % ex)
        else:
            return HttpJsonResponse()