Loading ccserver/handlers.py +87 −12 Original line number Diff line number Diff line Loading @@ -131,12 +131,46 @@ class HypervisorHandler(OnlineCCHandler): class CliHandler(OnlineCCHandler): ''' Handler binded to 'cli' role. Summary of methods: ================ ================================ ============= Method name Description Right(s) ================ ================================ ============= list list objects list start start a vm start stop stop a vm stop destroy destroy a vm destroy pause suspend a vm pause resume resume a paused vm resume passwd change password of accounts passwd addaccount add a new account addaccount copyaccount copy an account addaccount addtag add a tag to accounts addtag deltag remove a tag from accounts deltag tags show tags of accounts tags delaccount delete an account delaccount close close an account close declose declose an account declose kill kill a connected account kill rights show rights of accounts rights addright add right rules to accounts addright delright remove right rules from accounts delright execute execute remote command on hosts execute shutdown shutdown a connected client shutdown jobs show jobs jobs cancel cancel a running job cancel jobspurge remove done jobs from jobs list jobspurge dbstats show stats from cache OPEN FOR ALL ================ ================================ ============= ''' @listed def list(self, conn, query): ''' List all objects registered on this instance. :param query: the query to select objects to show ''' self._check(conn, 'list', query) Loading Loading @@ -191,7 +225,12 @@ class CliHandler(OnlineCCHandler): @listed def passwd(self, conn, query, password, method='ssha'): ''' Define a new password for specified user. Define a new password for selected user. :param query: the query to select the objects to change :param password: the password to set (None to remove password) :param method: the hash method (sha, ssha, md5, smd5 or plain) :return: a standard report output ''' self._check(conn, 'passwd', query) Loading @@ -212,6 +251,10 @@ class CliHandler(OnlineCCHandler): def addaccount(self, conn, login, role, password=None): ''' Create a new account with specified login. :param login: the login of the new account :param role: the role of the new account :param password: the password of the new account (None = not set) ''' self._check(conn, 'addaccount') Loading @@ -237,7 +280,11 @@ class CliHandler(OnlineCCHandler): @listed def addtag(self, conn, query, tag_name, tag_value): ''' Add a tag to the account which match the specified query. Add a tag to the accounts which match the specified query. :param query: the query to select objects :param tag_name: the name of the tag to add :param tag_value: the value of the tag ''' self._check(conn, 'addtag', query) Loading Loading @@ -265,7 +312,10 @@ class CliHandler(OnlineCCHandler): @listed def deltag(self, conn, query, tag_name): ''' Remove a tag of the account with specified login. Remove a tag of the selected accounts. :param query: the query to select objects :param tag_name: the name of the tag to remove ''' self._check(conn, 'deltag', query) Loading @@ -292,7 +342,9 @@ class CliHandler(OnlineCCHandler): @listed def tags(self, conn, query): ''' Return all static tags attached to the specified login. Return all static tags attached to the selected accounts. :param query: the query to select objects ''' self._check(conn, 'tags', query) Loading @@ -310,7 +362,9 @@ class CliHandler(OnlineCCHandler): @listed def delaccount(self, conn, query): ''' Delete the account with specified login. Delete the accounts selected by query. :param query: the query to select objects ''' self._check(conn, 'delaccount', query) Loading @@ -337,7 +391,9 @@ class CliHandler(OnlineCCHandler): @listed def close(self, conn, query): ''' Close an account without deleting it. Close selected account an account without deleting them. :param query: the query to select objects ''' self._check(conn, 'close', query) Loading Loading @@ -365,7 +421,9 @@ class CliHandler(OnlineCCHandler): @listed def declose(self, conn, query): ''' Re-open an closed account. Re-open selected closed accounts. :param query: the query to select objects ''' self._check(conn, 'declose', query) Loading @@ -389,6 +447,8 @@ class CliHandler(OnlineCCHandler): def kill(self, conn, query): ''' Disconnect all connected accounts selected by query. :param query: the query to select objects ''' self._check(conn, 'kill', query) Loading @@ -411,7 +471,9 @@ class CliHandler(OnlineCCHandler): @listed def rights(self, conn, query): ''' Get the rights of an object set. Get the rights of selected accounts. :param query: the query to select objects ''' self._check(conn, 'rights', query) Loading @@ -428,7 +490,15 @@ class CliHandler(OnlineCCHandler): @listed def addright(self, conn, query, tql, method=None, allow=True, index=None): ''' Add a right rule to the selected objects. Add a right rule to the selected accounts. :param query: the query to select objects :param tql: the TQL of the right rule :param method: the method of the right rule :param allow: target = allow if True, else False :param index: the index of the rule in list (can be negative to index from the end, if the index is out of range, the rule is added to the end. ''' self._check(conn, 'addright', query) Loading @@ -453,6 +523,9 @@ class CliHandler(OnlineCCHandler): def delright(self, conn, query, index): ''' Remove a right rule from the selected objects. :param query: the query to select objects :param index: the index of the right rule to remove ''' self._check(conn, 'delright', query) Loading Loading @@ -544,6 +617,9 @@ class CliHandler(OnlineCCHandler): def jobs(self, conn, done=None): ''' Return all jobs. :param done: if True, show only done jobs, False, only not done jobs, and None (default) to show all. ''' jobs = [] Loading @@ -556,6 +632,8 @@ class CliHandler(OnlineCCHandler): def cancel(self, conn, jobid): ''' Cancel a job. :param jobid: the id of the job to cancel. ''' self._server.jobs.cancel(jobid) Loading @@ -568,9 +646,6 @@ class CliHandler(OnlineCCHandler): self._server.jobs.purge() def threads(self, conn): import threading return threading.active_count() @listed def dbstats(self, conn): Loading Loading
ccserver/handlers.py +87 −12 Original line number Diff line number Diff line Loading @@ -131,12 +131,46 @@ class HypervisorHandler(OnlineCCHandler): class CliHandler(OnlineCCHandler): ''' Handler binded to 'cli' role. Summary of methods: ================ ================================ ============= Method name Description Right(s) ================ ================================ ============= list list objects list start start a vm start stop stop a vm stop destroy destroy a vm destroy pause suspend a vm pause resume resume a paused vm resume passwd change password of accounts passwd addaccount add a new account addaccount copyaccount copy an account addaccount addtag add a tag to accounts addtag deltag remove a tag from accounts deltag tags show tags of accounts tags delaccount delete an account delaccount close close an account close declose declose an account declose kill kill a connected account kill rights show rights of accounts rights addright add right rules to accounts addright delright remove right rules from accounts delright execute execute remote command on hosts execute shutdown shutdown a connected client shutdown jobs show jobs jobs cancel cancel a running job cancel jobspurge remove done jobs from jobs list jobspurge dbstats show stats from cache OPEN FOR ALL ================ ================================ ============= ''' @listed def list(self, conn, query): ''' List all objects registered on this instance. :param query: the query to select objects to show ''' self._check(conn, 'list', query) Loading Loading @@ -191,7 +225,12 @@ class CliHandler(OnlineCCHandler): @listed def passwd(self, conn, query, password, method='ssha'): ''' Define a new password for specified user. Define a new password for selected user. :param query: the query to select the objects to change :param password: the password to set (None to remove password) :param method: the hash method (sha, ssha, md5, smd5 or plain) :return: a standard report output ''' self._check(conn, 'passwd', query) Loading @@ -212,6 +251,10 @@ class CliHandler(OnlineCCHandler): def addaccount(self, conn, login, role, password=None): ''' Create a new account with specified login. :param login: the login of the new account :param role: the role of the new account :param password: the password of the new account (None = not set) ''' self._check(conn, 'addaccount') Loading @@ -237,7 +280,11 @@ class CliHandler(OnlineCCHandler): @listed def addtag(self, conn, query, tag_name, tag_value): ''' Add a tag to the account which match the specified query. Add a tag to the accounts which match the specified query. :param query: the query to select objects :param tag_name: the name of the tag to add :param tag_value: the value of the tag ''' self._check(conn, 'addtag', query) Loading Loading @@ -265,7 +312,10 @@ class CliHandler(OnlineCCHandler): @listed def deltag(self, conn, query, tag_name): ''' Remove a tag of the account with specified login. Remove a tag of the selected accounts. :param query: the query to select objects :param tag_name: the name of the tag to remove ''' self._check(conn, 'deltag', query) Loading @@ -292,7 +342,9 @@ class CliHandler(OnlineCCHandler): @listed def tags(self, conn, query): ''' Return all static tags attached to the specified login. Return all static tags attached to the selected accounts. :param query: the query to select objects ''' self._check(conn, 'tags', query) Loading @@ -310,7 +362,9 @@ class CliHandler(OnlineCCHandler): @listed def delaccount(self, conn, query): ''' Delete the account with specified login. Delete the accounts selected by query. :param query: the query to select objects ''' self._check(conn, 'delaccount', query) Loading @@ -337,7 +391,9 @@ class CliHandler(OnlineCCHandler): @listed def close(self, conn, query): ''' Close an account without deleting it. Close selected account an account without deleting them. :param query: the query to select objects ''' self._check(conn, 'close', query) Loading Loading @@ -365,7 +421,9 @@ class CliHandler(OnlineCCHandler): @listed def declose(self, conn, query): ''' Re-open an closed account. Re-open selected closed accounts. :param query: the query to select objects ''' self._check(conn, 'declose', query) Loading @@ -389,6 +447,8 @@ class CliHandler(OnlineCCHandler): def kill(self, conn, query): ''' Disconnect all connected accounts selected by query. :param query: the query to select objects ''' self._check(conn, 'kill', query) Loading @@ -411,7 +471,9 @@ class CliHandler(OnlineCCHandler): @listed def rights(self, conn, query): ''' Get the rights of an object set. Get the rights of selected accounts. :param query: the query to select objects ''' self._check(conn, 'rights', query) Loading @@ -428,7 +490,15 @@ class CliHandler(OnlineCCHandler): @listed def addright(self, conn, query, tql, method=None, allow=True, index=None): ''' Add a right rule to the selected objects. Add a right rule to the selected accounts. :param query: the query to select objects :param tql: the TQL of the right rule :param method: the method of the right rule :param allow: target = allow if True, else False :param index: the index of the rule in list (can be negative to index from the end, if the index is out of range, the rule is added to the end. ''' self._check(conn, 'addright', query) Loading @@ -453,6 +523,9 @@ class CliHandler(OnlineCCHandler): def delright(self, conn, query, index): ''' Remove a right rule from the selected objects. :param query: the query to select objects :param index: the index of the right rule to remove ''' self._check(conn, 'delright', query) Loading Loading @@ -544,6 +617,9 @@ class CliHandler(OnlineCCHandler): def jobs(self, conn, done=None): ''' Return all jobs. :param done: if True, show only done jobs, False, only not done jobs, and None (default) to show all. ''' jobs = [] Loading @@ -556,6 +632,8 @@ class CliHandler(OnlineCCHandler): def cancel(self, conn, jobid): ''' Cancel a job. :param jobid: the id of the job to cancel. ''' self._server.jobs.cancel(jobid) Loading @@ -568,9 +646,6 @@ class CliHandler(OnlineCCHandler): self._server.jobs.purge() def threads(self, conn): import threading return threading.active_count() @listed def dbstats(self, conn): Loading