• Home
  • Raw
  • Download

Lines Matching full:role

8 create(hostname, role=None, note=None)
9 Create a server with given role, with status backup.
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.
43 def _add_role(server, role, action): argument
44 """Add a role to the server.
47 @param role: Role to be added to the server.
48 @param action: Execute actions after role or status is changed. Default to
51 @raise ServerActionError: If role is failed to be added.
53 server_models.validate(role=role)
54 if role in server.get_role_names():
56 'Server %s already has role %s.' % (server.hostname, role))
59 if not server_manager_utils.check_server(server.hostname, role):
61 'Server %s is not ready for role %s.' % (server.hostname, role))
63 if (role in server_models.ServerRole.ROLES_REQUIRE_UNIQUE_INSTANCE and
66 roles__role=role, status=server_models.Server.STATUS.PRIMARY)
69 'Role %s must be unique. Server %s already has role %s.' %
70 (role, servers[0].hostname, role))
72 server_models.ServerRole.objects.create(server=server, role=role)
74 # If needed, apply actions to enable the role for the server.
75 server_manager_actions.try_execute(server, [role], enable=True,
78 print 'Role %s is added to server %s.' % (role, server.hostname)
81 def _delete_role(server, role, action=False): argument
82 """Delete a role from the server.
85 @param role: Role to be deleted from the server.
86 @param action: Execute actions after role or status is changed. Default to
89 @raise ServerActionError: If role is failed to be deleted.
91 server_models.validate(role=role)
92 if role not in server.get_role_names():
94 'Server %s does not have role %s.' % (server.hostname, role))
97 server_manager_utils.warn_missing_role(role, server)
99 # Apply actions to disable the role for the server before the role is
101 server_manager_actions.try_execute(server, [role], enable=False,
104 print 'Deleting role %s from server %s...' % (role, server.hostname)
105 server.roles.get(role=role).delete()
107 # Apply actions to disable the role for the server after the role is
109 server_manager_actions.try_execute(server, [role], enable=False,
112 # If the server is in status primary and has no role, change its status to
116 print ('Server %s has no role, change its status from primary to backup'
121 print 'Role %s is deleted from server %s.' % (role, server.hostname)
129 @param action: Execute actions after role or status is changed. Default to
142 'Server %s has no role associated. Server must have a role to '
146 # the Autotest instance already has another server running an unique role.
148 # with role scheduler should not be changed to status primary.
152 for role in unique_roles:
154 roles__role=role.role,
158 'Role %s must be unique. Server %s already has the '
159 'role.' % (role.role, servers[0].hostname))
162 # other value and the server is running a unique role across database, e.g.
165 for role in server.get_role_names():
166 server_manager_utils.warn_missing_role(role, server)
190 def create(hostname, role=None, note=None): argument
198 @param role: role of the new server, default to None.
203 server_models.validate(hostname=hostname, role=role)
207 server_models.ServerRole.objects.create(server=server, role=role)
228 for role in server.roles.all():
229 _delete_role(server, role.role)
236 def modify(hostname, role=None, status=None, delete=False, note=None, argument
241 @param role: Role to be added to the server.
243 @param delete: True to delete given role from the server, default to False.
247 @param action: Execute actions after role or status is changed. Default to
256 if role:
258 _add_role(server, role, action)
260 _delete_role(server, role, action)