returned.
"""
- roles = ['admin', 'pi', 'user', 'tech']
+ roles = ['admin', 'pi', 'user', 'tech', 'node']
accepts = [
Auth(),
specified, only the specified details will be returned.
"""
- roles = ['admin', 'pi', 'user', 'tech']
+ roles = ['admin', 'pi', 'user', 'tech', 'node']
accepts = [
Auth(),
Returns an array of all valid node boot states.
"""
- roles = ['admin', 'pi', 'user', 'tech']
+ roles = ['admin', 'pi', 'user', 'tech', 'node']
accepts = [
Auth()
details will be returned.
"""
- roles = ['admin']
+ roles = ['admin', 'node']
accepts = [
Auth(),
Returns an array of all valid key types.
"""
- roles = ['admin', 'pi', 'user', 'tech']
+ roles = ['admin', 'pi', 'user', 'tech', 'node']
accepts = [
Auth()
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.Filter import Filter
+from PLC.Persons import Person, Persons
from PLC.Keys import Key, Keys
from PLC.Auth import Auth
keys.
"""
- roles = ['admin', 'pi', 'user', 'tech']
+ roles = ['admin', 'pi', 'user', 'tech', 'node']
accepts = [
Auth(),
keys = Keys(self.api, key_filter, return_fields)
# If we are not admin, make sure to only return our own keys
- if 'admin' not in self.caller['roles']:
+ if isinstance(self.caller, Person) and \
+ 'admin' not in self.caller['roles']:
keys = filter(lambda key: key['key_id'] in self.caller['key_ids'], keys)
return keys
"""
Returns an array of structs containing details about message
templates. If message template_filter is specified and is an array
- of message template identifiers or hostnames, or a struct of
- message template attributes, only message templates matching the
- filter will be returned. If return_fields is specified, only the
- specified details will be returned.
+ of message template identifiers, or a struct of message template
+ attributes, only message templates matching the filter will be
+ returned. If return_fields is specified, only the specified
+ details will be returned.
"""
- roles = ['admin']
+ roles = ['admin', 'node']
accepts = [
Auth(),
Returns a list of all valid network methods.
"""
- roles = ['admin', 'pi', 'user', 'tech']
+ roles = ['admin', 'pi', 'user', 'tech', 'node']
accepts = [
Auth()
Returns a list of all valid network types.
"""
- roles = ['admin', 'pi', 'user', 'tech']
+ roles = ['admin', 'pi', 'user', 'tech', 'node']
accepts = [
Auth()
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.Filter import Filter
+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 Auth
their sites.
"""
- roles = ['admin', 'pi', 'tech']
+ roles = ['admin', 'pi', 'tech', 'node']
accepts = [
Auth(),
returns = [PCU.fields]
def call(self, auth, pcu_filter = None, return_fields = None):
- # If we are not admin, make sure to only return our own PCUs
- if 'admin' not in self.caller['roles']:
- # Get list of PCUs that we are able to view
+ # If we are not admin
+ if not (isinstance(self.caller, Person) and 'admin' in self.caller['roles']):
+ # Return only the PCUs at our site
valid_pcu_ids = []
- if self.caller['site_ids']:
- sites = Sites(self.api, self.caller['site_ids'])
- for site in sites:
- valid_pcu_ids += site['pcu_ids']
+
+ if isinstance(self.caller, Person):
+ site_ids = self.caller['site_ids']
+ elif isinstance(self.caller, Node):
+ site_ids = [self.caller['site_id']]
+
+ for site in Sites(self.api, site_ids):
+ valid_pcu_ids += site['pcu_ids']
if not valid_pcu_ids:
return []
pcus = PCUs(self.api, pcu_filter, return_fields)
# Filter out PCUs that are not viewable
- if 'admin' not in self.caller['roles']:
+ if not (isinstance(self.caller, Person) and 'admin' in self.caller['roles']):
pcus = filter(lambda pcu: pcu['pcu_id'] in valid_pcu_ids, pcus)
return pcus
Returns this peer's name, as defined in the config as PLC_NAME
"""
- roles = ['admin', 'peer']
+ roles = ['admin', 'peer', 'node']
accepts = [Auth()]
specified details will be returned.
"""
- roles = ['admin']
+ roles = ['admin', 'node']
accepts = [
Auth(),
Users and techs may only retrieve details about themselves. PIs
may retrieve details about themselves and others at their
- sites. Admins may retrieve details about all accounts.
+ sites. Admins and nodes may retrieve details about all accounts.
"""
- roles = ['admin', 'pi', 'user', 'tech']
+ roles = ['admin', 'pi', 'user', 'tech', 'node']
accepts = [
Auth(),
def call(self, auth, person_filter = None, return_fields = None):
# If we are not admin, make sure to only return viewable accounts
- if 'admin' not in self.caller['roles']:
+ if isinstance(self.caller, Person) and \
+ 'admin' not in self.caller['roles']:
# Get accounts that we are able to view
valid_person_ids = [self.caller['person_id']]
if 'pi' in self.caller['roles'] and self.caller['site_ids']:
persons = Persons(self.api, person_filter, return_fields)
# Filter out accounts that are not viewable
- if 'admin' not in self.caller['roles']:
+ if isinstance(self.caller, Person) and \
+ 'admin' not in self.caller['roles']:
persons = filter(self.caller.can_view, persons)
return persons
Get an array of structs containing details about all roles.
"""
- roles = ['admin', 'pi', 'user', 'tech']
+ roles = ['admin', 'pi', 'user', 'tech', 'node']
accepts = [
Auth()
returns = [Role.fields]
-
def call(self, auth):
return Roles(self.api)
specified, only the specified details will be returned.
"""
- roles = ['admin', 'pi', 'user', 'tech']
+ roles = ['admin', 'pi', 'user', 'tech', 'node']
accepts = [
Auth(),
returns = [SliceAttributeType.fields]
-
def call(self, auth, attribute_type_filter = None, return_fields = None):
return SliceAttributeTypes(self.api, attribute_type_filter, return_fields)
Returns an array of all valid slice instantiation states.
"""
- roles = ['admin', 'pi', 'user', 'tech']
+ roles = ['admin', 'pi', 'user', 'tech', 'node']
accepts = [
Auth()
returns = [SliceInstantiation.fields['instantiation']]
-
def call(self, auth):
return [slice_instantiation['instantiation'] for slice_instantiation in SliceInstantiations(self.api)]
from PLC.Parameter import Parameter, Mixed
from PLC.Filter import Filter
from PLC.Auth import Auth
+from PLC.Persons import Person, Persons
from PLC.Slices import Slice, Slices
class GetSlices(Method):
specified details will be returned.
Users may only query slices of which they are members. PIs may
- query any of the slices at their sites. Admins may query any
- slice. If a slice that cannot be queried is specified in
+ query any of the slices at their sites. Admins and nodes may query
+ any slice. If a slice that cannot be queried is specified in
slice_filter, details about that slice will not be returned.
"""
- roles = ['admin', 'pi', 'user']
+ roles = ['admin', 'pi', 'user', 'node']
accepts = [
Auth(),
def call(self, auth, slice_filter = None, return_fields = None):
# If we are not admin, make sure to return only viewable
# slices.
- if 'admin' not in self.caller['roles']:
+ if isinstance(self.caller, Person) and \
+ 'admin' not in self.caller['roles']:
# Get slices that we are able to view
valid_slice_ids = self.caller['slice_ids']
if 'pi' in self.caller['roles'] and self.caller['site_ids']:
slices = Slices(self.api, slice_filter, return_fields)
# Filter out slices that are not viewable
- if 'admin' not in self.caller['roles']:
+ if isinstance(self.caller, Person) and \
+ 'admin' not in self.caller['roles']:
slices = filter(lambda slice: slice['slice_id'] in valid_slice_ids, slices)
return slices