• Home
  • History
  • Annotate
  • Raw
  • Download

Lines Matching full:role

9 create(hostname, role=None, note=None)
10 Create a server with given role, with status primary.
15 modify(hostname, role=None, status=None, note=None, delete=False,
17 Modify a server's role, status, note, or attribute:
18 1. Add role to a server. If the server is in primary status, proper actions
19 like service restart will be executed to enable the role.
20 2. Delete a role from a server. If the server is in primary status, proper
21 actions like service restart will be executed to disable the role.
24 or disable each role of the server.
47 def _add_role(server, role, action): argument
48 """Add a role to the server.
51 @param role: Role to be added to the server.
52 @param action: Execute actions after role or status is changed. Default to
55 @raise ServerActionError: If role is failed to be added.
57 server_models.validate(role=role)
58 if role in server.get_role_names():
60 'Server %s already has role %s.' % (server.hostname, role))
63 if not server_manager_utils.check_server(server.hostname, role):
65 'Server %s is not ready for role %s.' % (server.hostname, role))
67 if (role in server_models.ServerRole.ROLES_REQUIRE_UNIQUE_INSTANCE and
70 roles__role=role, status=server_models.Server.STATUS.PRIMARY)
73 'Role %s must be unique. Server %s already has role %s.' %
74 (role, servers[0].hostname, role))
76 server_models.ServerRole.objects.create(server=server, role=role)
78 # If needed, apply actions to enable the role for the server.
79 server_manager_actions.try_execute(server, [role], enable=True,
82 print('Role %s is added to server %s.' % (role, server.hostname))
85 def _delete_role(server, role, action=False): argument
86 """Delete a role from the server.
89 @param role: Role to be deleted from the server.
90 @param action: Execute actions after role or status is changed. Default to
93 @raise ServerActionError: If role is failed to be deleted.
95 server_models.validate(role=role)
96 if role not in server.get_role_names():
98 'Server %s does not have role %s.' % (server.hostname, role))
101 server_manager_utils.warn_missing_role(role, server)
103 # Apply actions to disable the role for the server before the role is
105 server_manager_actions.try_execute(server, [role], enable=False,
108 print('Deleting role %s from server %s...' % (role, server.hostname))
109 server.roles.get(role=role).delete()
111 # Apply actions to disable the role for the server after the role is
113 server_manager_actions.try_execute(server, [role], enable=False,
118 print ('Server %s has no role.')
120 print('Role %s is deleted from server %s.' % (role, server.hostname))
128 @param action: Execute actions after role or status is changed. Default to
141 'Server %s has no role associated. Server must have a role to '
145 # the Autotest instance already has another server running an unique role.
147 # server with role scheduler should not be changed to status primary.
151 for role in unique_roles:
153 roles__role=role.role,
157 'Role %s must be unique. Server %s already has the '
158 'role.' % (role.role, servers[0].hostname))
161 # other value and the server is running a unique role across database, e.g.
164 for role in server.get_role_names():
165 server_manager_utils.warn_missing_role(role, server)
189 def create(hostname, role=None, note=None): argument
195 @param role: role of the new server, default to None.
200 server_models.validate(hostname=hostname, role=role)
204 server_models.ServerRole.objects.create(server=server, role=role)
225 for role in server.roles.all():
226 _delete_role(server, role.role)
233 def modify(hostname, role=None, status=None, delete=False, note=None, argument
238 @param role: Role to be added to the server.
240 @param delete: True to delete given role from the server, default to False.
244 @param action: Execute actions after role or status is changed. Default to
253 if role:
255 _add_role(server, role, action)
257 _delete_role(server, role, action)