Home | History | Annotate | Download | only in site_utils

Lines Matching full:role

37 def warn_missing_role(role, exclude_server):
39 given role.
41 @param role: Name of the role.
42 @param exclude_server: Server to be excluded from search for role.
45 roles__role=role,
49 message = ('WARNING! There will be no server with role %s after it\'s '
51 'normally without any server in role %s.' %
52 (role, exclude_server.hostname, role))
56 def get_servers(hostname=None, role=None, status=None):
57 """Find servers with given role and status.
60 @param role: Role of server, default to None.
63 @return: A list of server objects with given role and status.
68 if role:
69 filters['roles__role'] = role
99 No Role :
138 for role, _ in server_models.ServerRole.ROLE.choices():
139 servers_of_role = [s for s in servers if role in
140 [r.role for r in s.roles.all()]]
141 result += '%-15s: ' % role
147 result += '%-15s: %s' % ('No Role', ', '.join(servers_without_role))
152 def check_server(hostname, role):
153 """Confirm server with given hostname is ready to be primary of given role.
155 If the server is a backup and failed to be verified for the role, remove
156 the role from its roles list. If it has no other role, set its status to
160 @param role: Role to be checked.
161 @return: True if server can be verified for the given role, otherwise
164 # TODO(dshi): Add more logic to confirm server is ready for the role.
227 servers = get_servers(role=server_models.ServerRole.ROLE.DRONE,
281 servers = get_servers(role=server_models.ServerRole.ROLE.SHARD,
286 def confirm_server_has_role(hostname, role):
287 """Confirm a given server has the given role, and its status is primary.
290 @param role: Name of the role to be checked.
291 @raise ServerActionError: If localhost does not have given role or it's
298 servers = get_servers(role=role, status=server_models.Server.STATUS.PRIMARY)
302 raise ServerActionError('Server %s does not have role of %s running in '
303 'status primary.' % (hostname, role))