+++ /dev/null
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.NodeGroups import NodeGroup, NodeGroups
-from PLC.Nodes import Node, Nodes
-from PLC.Auth import PasswordAuth
-
-class RemoveNodeFromNodeGroup(Method):
- """
- Removes a node from the specified node group.
-
- Returns 1 if successful, faults otherwise.
- """
-
- roles = ['admin']
-
- accepts = [
- PasswordAuth(),
- Mixed(NodeGroup.fields['nodegroup_id'],
- NodeGroup.fields['name']),
- Mixed(Node.fields['node_id'],
- Node.fields['hostname'])
- ]
-
- returns = Parameter(int, '1 if successful')
-
- def call(self, auth, nodegroup_id_or_name, node_id_or_hostname):
- # Get node info
- nodes = Nodes(self.api, [node_id_or_hostname])
- if not nodes:
- raise PLCInvalidArgument, "No such node"
-
- node = nodes.values()[0]
-
- # Get nodegroup info
- nodegroups = NodeGroups(self.api, [nodegroup_id_or_name])
- if not nodegroups:
- raise PLCInvalidArgument, "No such nodegroup"
-
- nodegroup = nodegroups.values()[0]
-
- # Remove node from nodegroup
- if node['node_id'] in nodegroup['node_ids']:
- nodegroup.remove_node(node)
-
- return 1
+++ /dev/null
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Persons import Person, Persons
-from PLC.Sites import Site, Sites
-from PLC.Auth import PasswordAuth
-
-class RemovePersonFromSite(Method):
- """
- Removes the specified person from the specified site. If the
- person is not a member of the specified site, no error is
- returned.
-
- Returns 1 if successful, faults otherwise.
- """
-
- roles = ['admin']
-
- accepts = [
- PasswordAuth(),
- Mixed(Person.fields['person_id'],
- Person.fields['email']),
- Mixed(Site.fields['site_id'],
- Site.fields['login_base'])
- ]
-
- returns = Parameter(int, '1 if successful')
-
- def call(self, auth, person_id_or_email, site_id_or_login_base):
- # Get account information
- persons = Persons(self.api, [person_id_or_email])
- if not persons:
- raise PLCInvalidArgument, "No such account"
-
- person = persons.values()[0]
-
- # Get site information
- sites = Sites(self.api, [site_id_or_login_base])
- if not sites:
- raise PLCInvalidArgument, "No such site"
-
- site = sites.values()[0]
-
- if site['site_id'] in person['site_ids']:
- site.remove_person(person)
-
- return 1