Lines Matching full:role
39 def warn_missing_role(role, exclude_server): argument
41 given role.
43 @param role: Name of the role.
44 @param exclude_server: Server to be excluded from search for role.
47 roles__role=role,
51 message = ('WARNING! There will be no server with role %s after it\'s '
53 'normally without any server in role %s.' %
54 (role, exclude_server.hostname, role))
58 def get_servers(hostname=None, role=None, status=None): argument
59 """Find servers with given role and status.
62 @param role: Role of server, default to None.
65 @return: A list of server objects with given role and status.
70 if role:
71 filters['roles__role'] = role
133 @returns: Mapping of role strings to lists of servers.
135 roles = [role for role, _ in server_models.ServerRole.ROLE.choices()]
138 for role in server.get_role_names():
139 servers_by_role[role].append(server)
143 def _format_role_servers_summary(role, servers): argument
144 """Format one line of servers for a role in a server list summary.
146 @param role: Role string.
153 return '%-15s: %s' % (role, servers_part)
156 def check_server(hostname, role): argument
157 """Confirm server with given hostname is ready to be primary of given role.
159 If the server is a backup and failed to be verified for the role, remove
160 the role from its roles list. If it has no other role, set its status to
164 @param role: Role to be checked.
165 @return: True if server can be verified for the given role, otherwise
168 # TODO(dshi): Add more logic to confirm server is ready for the role.
231 servers = get_servers(role=server_models.ServerRole.ROLE.DRONE,
285 servers = get_servers(role=server_models.ServerRole.ROLE.SHARD,
290 def confirm_server_has_role(hostname, role): argument
291 """Confirm a given server has the given role, and its status is primary.
294 @param role: Name of the role to be checked.
295 @raise ServerActionError: If localhost does not have given role or it's
302 servers = get_servers(role=role, status=server_models.Server.STATUS.PRIMARY)
306 raise ServerActionError('Server %s does not have role of %s running in '
307 'status primary.' % (hostname, role))