Lines Matching refs:role

42 def _add_role(server, role, action):  argument
52 server_models.validate(role=role)
53 if role in server.get_role_names():
55 'Server %s already has role %s.' % (server.hostname, role))
58 if not server_manager_utils.check_server(server.hostname, role):
60 'Server %s is not ready for role %s.' % (server.hostname, role))
62 if (role in server_models.ServerRole.ROLES_REQUIRE_UNIQUE_INSTANCE and
65 roles__role=role, status=server_models.Server.STATUS.PRIMARY)
69 (role, servers[0].hostname, role))
71 server_models.ServerRole.objects.create(server=server, role=role)
74 server_manager_actions.try_execute(server, [role], enable=True,
77 print 'Role %s is added to server %s.' % (role, server.hostname)
80 def _delete_role(server, role, action=False): argument
90 server_models.validate(role=role)
91 if role not in server.get_role_names():
93 'Server %s does not have role %s.' % (server.hostname, role))
96 server_manager_utils.warn_missing_role(role, server)
100 server_manager_actions.try_execute(server, [role], enable=False,
103 print 'Deleting role %s from server %s...' % (role, server.hostname)
104 server.roles.get(role=role).delete()
108 server_manager_actions.try_execute(server, [role], enable=False,
115 print 'Role %s is deleted from server %s.' % (role, server.hostname)
146 for role in unique_roles:
148 roles__role=role.role,
153 'role.' % (role.role, servers[0].hostname))
159 for role in server.get_role_names():
160 server_manager_utils.warn_missing_role(role, server)
184 def create(hostname, role=None, note=None): argument
195 server_models.validate(hostname=hostname, role=role)
199 server_models.ServerRole.objects.create(server=server, role=role)
220 for role in server.roles.all():
221 _delete_role(server, role.role)
228 def modify(hostname, role=None, status=None, delete=False, note=None, argument
248 if role:
250 _add_role(server, role, action)
252 _delete_role(server, role, action)