Lines Matching refs:role

39 def warn_missing_role(role, exclude_server):
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):
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
186 for role, role_servers in servers_by_role.iteritems():
187 result_lines.append(_format_role_servers_summary(role, role_servers))
198 @returns: Mapping of role strings to lists of servers.
200 roles = [role for role, _ in server_models.ServerRole.ROLE.choices()]
203 for role in server.get_role_names():
204 servers_by_role[role].append(server)
208 def _format_role_servers_summary(role, servers):
209 """Format one line of servers for a role in a server list summary.
211 @param role: Role string.
218 return '%-15s: %s' % (role, servers_part)
221 def check_server(hostname, role):
222 """Confirm server with given hostname is ready to be primary of given role.
224 If the server is a backup and failed to be verified for the role, remove
225 the role from its roles list. If it has no other role, set its status to
229 @param role: Role to be checked.
230 @return: True if server can be verified for the given role, otherwise
233 # TODO(dshi): Add more logic to confirm server is ready for the role.
296 servers = get_servers(role=server_models.ServerRole.ROLE.DRONE,
350 servers = get_servers(role=server_models.ServerRole.ROLE.SHARD,
355 def confirm_server_has_role(hostname, role):
356 """Confirm a given server has the given role, and its status is primary.
359 @param role: Name of the role to be checked.
360 @raise ServerActionError: If localhost does not have given role or it's
367 servers = get_servers(role=role, status=server_models.Server.STATUS.PRIMARY)
371 raise ServerActionError('Server %s does not have role of %s running in '
372 'status primary.' % (hostname, role))