from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.Nodes import Node, Nodes
-from PLC.NodeGroups import NodeGroup, NodeGroups
from PLC.Sites import Site, Sites
from PLC.Auth import PasswordAuth
+from PLC.Methods.AddNode import AddNode
-class AdmAddNode(Method):
+class AdmAddNode(AddNode):
"""
- Adds a new node. Any values specified in optional_vals are used,
- otherwise defaults are used.
-
- PIs and techs may only add nodes to their own sites. Admins may
- add nodes to any site.
-
- Returns the new node_id (> 0) if successful, faults otherwise.
+ Deprecated. See AddNode.
"""
- roles = ['admin', 'pi', 'tech']
-
- can_update = lambda (field, value): field in \
- ['model', 'version']
- update_fields = dict(filter(can_update, Node.fields.items()))
+ status = "deprecated"
accepts = [
PasswordAuth(),
Site.fields['login_base']),
Node.fields['hostname'],
Node.fields['boot_state'],
- update_fields
+ AddNode.update_fields
]
- returns = Parameter(int, 'New node_id (> 0) if successful')
-
- def call(self, auth, site_id_or_login_base, hostname, boot_state, optional_vals = {}):
- if filter(lambda field: field not in self.update_fields, optional_vals):
- raise PLCInvalidArgument, "Invalid fields specified"
-
- # Get site information
- sites = Sites(self.api, [site_id_or_login_base])
- if not sites:
- raise PLCInvalidArgument, "No such site"
-
- site = sites.values()[0]
-
- # Authenticated function
- assert self.caller is not None
-
- # If we are not an admin, make sure that the caller is a
- # member of the site.
- if 'admin' not in self.caller['roles']:
- if site['site_id'] not in self.caller['site_ids']:
- assert self.caller['person_id'] not in site['person_ids']
- raise PLCPermissionDenied, "Not allowed to add nodes to specified site"
- else:
- assert self.caller['person_id'] in site['person_ids']
-
- node = Node(self.api, optional_vals)
- node['hostname'] = hostname
- node['boot_state'] = boot_state
- node['site_id'] = site['site_id']
- node.sync()
-
- return node['node_id']
+ def call(self, auth, site_id_or_login_base, hostname, boot_state, node_fields = {}):
+ node_fields['boot_state'] = boot_state
+ return AddNode.call(self, auth, site_id_or_login_base, hostname, node_fields)
from PLC.Parameter import Parameter, Mixed
from PLC.NodeGroups import NodeGroup, NodeGroups
from PLC.Auth import PasswordAuth
+from PLC.Methods.AddNodeGroup import AddNodeGroup
-class AdmAddNodeGroup(Method):
+class AdmAddNodeGroup(AddNodeGroup):
"""
- Adds a new node group. Any values specified in optional_vals are used,
- otherwise defaults are used.
-
- Returns the new nodegroup_id (> 0) if successful, faults otherwise.
+ Deprecated. See AddNodeGroup.
"""
- roles = ['admin']
+ status = "deprecated"
accepts = [
PasswordAuth(),
NodeGroup.fields['description']
]
- returns = Parameter(int, 'New nodegroup_id (> 0) if successful')
-
def call(self, auth, name, description):
- # Create node group
- nodegroup = NodeGroup(self.api, {'name': name, 'description': description})
- nodegroup.sync()
-
- return nodegroup['nodegroup_id']
+ return AddNodeGroup.call(self, auth, name, {'description': description})
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Sites import Site, Sites
-from PLC.Auth import PasswordAuth
+from PLC.Methods.AddSite import AddSite
-class AdmAddSite(Method):
+class AdmAddSite(AddSite):
"""
- Adds a new site, and creates a node group for that site. Any
- fields specified in optional_vals are used, otherwise defaults are
- used.
-
- Returns the new site_id (> 0) if successful, faults otherwise.
+ Deprecated. See AddSite.
"""
- roles = ['admin']
-
- can_update = lambda (field, value): field in \
- ['is_public', 'latitude', 'longitude', 'url',
- 'organization_id', 'ext_consortium_id']
- update_fields = dict(filter(can_update, Site.fields.items()))
-
- accepts = [
- PasswordAuth(),
- Site.fields['name'],
- Site.fields['abbreviated_name'],
- Site.fields['login_base'],
- update_fields
- ]
-
- returns = Parameter(int, 'New site_id (> 0) if successful')
-
- def call(self, auth, name, abbreviated_name, login_base, optional_vals = {}):
- if filter(lambda field: field not in self.update_fields, optional_vals):
- raise PLCInvalidArgument, "Invalid field specified"
-
- site = Site(self.api, optional_vals)
- site['name'] = name
- site['abbreviated_name'] = abbreviated_name
- site['login_base'] = login_base
- site.sync()
-
- return site['site_id']
+ status = "deprecated"
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Auth import PasswordAuth
-from PLC.Nodes import Node, Nodes
+from PLC.Methods.DeleteNode import DeleteNode
-class AdmDeleteNode(Method):
+class AdmDeleteNode(DeleteNode):
"""
- Mark an existing node as deleted.
-
- PIs and techs may only delete nodes at their own sites. Admins may
- delete nodes at any site.
-
- Returns 1 if successful, faults otherwise.
+ Deprecated. See DeleteNode.
"""
- roles = ['admin', 'pi', 'tech']
-
- accepts = [
- PasswordAuth(),
- Mixed(Node.fields['node_id'],
- Node.fields['hostname'])
- ]
-
- returns = Parameter(int, '1 if successful')
-
- def call(self, auth, node_id_or_hostname):
- # Get account information
- nodes = Nodes(self.api, [node_id_or_hostname])
- if not nodes:
- raise PLCInvalidArgument, "No such node"
-
- node = nodes.values()[0]
-
- # If we are not an admin, make sure that the caller is a
- # member of the site at which the node is located.
- if 'admin' not in self.caller['roles']:
- # Authenticated function
- assert self.caller is not None
-
- if node['site_id'] not in self.caller['site_ids']:
- raise PLCPermissionDenied, "Not allowed to delete nodes from specified site"
-
- node.delete()
-
- return 1
+ status = "deprecated"
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Auth import PasswordAuth
-from PLC.NodeGroups import NodeGroup, NodeGroups
+from PLC.Methods.DeleteNodeGroup import DeleteNodeGroup
-class AdmDeleteNodeGroup(Method):
+class AdmDeleteNodeGroup(DeleteNodeGroup):
"""
- Delete an existing Node Group.
-
- Admins may delete any node group
-
- Returns 1 if successful, faults otherwise.
+ Deprecated. See DeleteNodeGroup.
"""
- roles = ['admin']
-
- accepts = [
- PasswordAuth(),
- Mixed(NodeGroup.fields['nodegroup_id'],
- NodeGroup.fields['name'])
- ]
-
- returns = Parameter(int, '1 if successful')
-
- def call(self, auth, node_group_id_or_name):
- # Get account information
- nodegroups = NodeGroups(self.api, [node_group_id_or_name])
- if not nodegroups:
- raise PLCInvalidArgument, "No such node group"
-
- nodegroup = nodegroups.values()[0]
-
- nodegroup.delete()
-
- return 1
+ status = "deprecated"
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Sites import Site, Sites
-from PLC.Persons import Person, Persons
-from PLC.Nodes import Node, Nodes
-from PLC.PCUs import PCU, PCUs
-from PLC.Auth import PasswordAuth
+from PLC.Methods.DeleteSite import DeleteSite
-class AdmDeleteSite(Method):
+class AdmDeleteSite(DeleteSite):
"""
- Mark an existing site as deleted. The accounts of people who are
- not members of at least one other non-deleted site will also be
- marked as deleted. Nodes, PCUs, and slices associated with the
- site will be deleted.
-
- Returns 1 if successful, faults otherwise.
+ Deprecated. See DeleteSite.
"""
- roles = ['admin']
-
- accepts = [
- PasswordAuth(),
- Mixed(Site.fields['site_id'],
- Site.fields['login_base'])
- ]
-
- returns = Parameter(int, '1 if successful')
-
- def call(self, auth, site_id_or_login_base):
- # Get account information
- sites = Sites(self.api, [site_id_or_login_base])
- if not sites:
- raise PLCInvalidArgument, "No such site"
-
- site = sites.values()[0]
- site.delete()
-
- return 1
+ status = "deprecated"
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Nodes import Node, Nodes
-from PLC.Auth import PasswordAuth
+from PLC.Methods.UpdateNode import UpdateNode
-class AdmUpdateNode(Method):
+class AdmUpdateNode(UpdateNode):
"""
- Updates a node. Only the fields specified in update_fields are
- updated, all other fields are left untouched.
-
- To remove a value without setting a new one in its place (for
- example, to remove an address from the node), specify -1 for int
- and double fields and 'null' for string fields. hostname and
- boot_state cannot be unset.
-
- PIs and techs can only update the nodes at their sites.
-
- Returns 1 if successful, faults otherwise.
+ Deprecated. See UpdateNode.
"""
- roles = ['admin', 'pi', 'tech']
-
- can_update = lambda (field, value): field in \
- ['hostname', 'boot_state', 'model', 'version']
- update_fields = dict(filter(can_update, Node.fields.items()))
-
- accepts = [
- PasswordAuth(),
- Mixed(Node.fields['node_id'],
- Node.fields['hostname']),
- update_fields
- ]
-
- returns = Parameter(int, '1 if successful')
-
- def call(self, auth, node_id_or_hostname, update_fields):
- if filter(lambda field: field not in self.update_fields, update_fields):
- raise PLCInvalidArgument, "Invalid field specified"
-
- # XML-RPC cannot marshal None, so we need special values to
- # represent "unset".
- for key, value in update_fields.iteritems():
- if value == -1 or value == "null":
- if key in ['hostname', 'boot_state']:
- raise PLCInvalidArgument, "hostname and boot_state cannot be unset"
- update_fields[key] = None
-
- # Get account information
- nodes = Nodes(self.api, [node_id_or_hostname])
- if not nodes:
- raise PLCInvalidArgument, "No such node"
-
- node = nodes.values()[0]
-
- # Authenticated function
- assert self.caller is not None
-
- # If we are not an admin, make sure that the caller is a
- # member of the site at which the node is located.
- if 'admin' not in self.caller['roles']:
- if node['site_id'] not in self.caller['site_ids']:
- raise PLCPermissionDenied, "Not allowed to delete nodes from specified site"
-
- node.update(update_fields)
- node.sync()
-
- return 1
+ status = "deprecated"
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.NodeGroups import NodeGroup, NodeGroups
-from PLC.Auth import PasswordAuth
+from PLC.Methods.UpdateNodeGroup import UpdateNodeGroup
-class AdmUpdateNodeGroup(Method):
+class AdmUpdateNodeGroup(UpdateNodeGroup):
"""
- Updates a custom node group.
-
- Returns 1 if successful, faults otherwise.
+ Deprecated. See UpdateNodeGroup.
"""
-
- roles = ['admin']
-
- accepts = [
- PasswordAuth(),
- Mixed(NodeGroup.fields['nodegroup_id'],
- NodeGroup.fields['name']),
- NodeGroup.fields['name'],
- NodeGroup.fields['description']
- ]
-
- returns = Parameter(int, '1 if successful')
-
- def call(self, auth, nodegroup_id_or_name, name, description):
- # Get nodegroup information
- nodegroups = NodeGroups(self.api, [nodegroup_id_or_name])
- if not nodegroups:
- raise PLCInvalidArgument, "No such nodegroup"
-
- nodegroup = nodegroups.values()[0]
-
- # Modify node group
- update_fields = {
- 'name': name,
- 'description': description
- }
-
- nodegroup.update(update_fields)
- nodegroup.sync()
-
- return 1
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Sites import Site, Sites
-from PLC.Auth import PasswordAuth
+from PLC.Methods.UpdateSite import UpdateSite
-class AdmUpdateSite(Method):
+class AdmUpdateSite(UpdateSite):
"""
- Updates a site. Only the fields specified in update_fields are
- updated, all other fields are left untouched.
-
- To remove a value without setting a new one in its place (for
- example, to remove an address from the node), specify -1 for int
- and double fields and 'null' for string fields. hostname and
- boot_state cannot be unset.
-
- PIs can only update sites they are a member of. Only admins can
- update max_slices.
-
- Returns 1 if successful, faults otherwise.
+ Deprecated. See UpdateSite.
"""
- roles = ['admin', 'pi']
-
- can_update = lambda (field, value): field in \
- ['name', 'abbreviated_name',
- 'is_public', 'latitude', 'longitude', 'url',
- 'max_slices', 'max_slivers']
- update_fields = dict(filter(can_update, Site.fields.items()))
-
- accepts = [
- PasswordAuth(),
- Mixed(Site.fields['site_id'],
- Site.fields['login_base']),
- update_fields
- ]
-
- returns = Parameter(int, '1 if successful')
-
- def call(self, auth, site_id_or_login_base, update_fields):
- # Check for invalid fields
- if filter(lambda field: field not in self.update_fields, update_fields):
- raise PLCInvalidArgument, "Invalid field specified"
-
- # XML-RPC cannot marshal None, so we need special values to
- # represent "unset".
- for key, value in update_fields.iteritems():
- if value == -1 or value == "null":
- if key not in ['latitude', 'longitude', 'url']:
- raise PLCInvalidArgument, "%s cannot be unset" % key
- update_fields[key] = None
-
- # Get site information
- sites = Sites(self.api, [site_id_or_login_base])
- if not sites:
- raise PLCInvalidArgument, "No such site"
-
- site = sites.values()[0]
-
- # Authenticated function
- assert self.caller is not None
-
- # If we are not an admin, make sure that the caller is a
- # member of the site.
- if 'admin' not in self.caller['roles']:
- if site['site_id'] not in self.caller['site_ids']:
- raise PLCPermissionDenied, "Not allowed to modify specified site"
-
- if 'max_slices' or 'max_slivers' in update_fields:
- raise PLCInvalidArgument, "Only admins can update max_slices and max_slivers"
-
- site.update(update_fields)
- site.sync()
-
- return 1
+ status = "deprecated"