-# $Id$
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.SliceTags import SliceTag, SliceTags
from PLC.Persons import Person, Persons
from PLC.Sites import Site, Sites
+from PLC.Nodes import Nodes
from PLC.Slices import Slice, Slices
from PLC.Auth import Auth
]
returns = [SliceTag.fields]
-
+
def call(self, auth, slice_tag_filter = None, return_fields = None):
- # If we are not admin, make sure to only return our own slice
- # and sliver attributes.
+ # If we are not admin, make sure to only return our own slice
+ # and sliver attributes.
if isinstance(self.caller, Person) and \
'admin' not in self.caller['roles']:
# Get slices that we are able to view
sites = Sites(self.api, self.caller['site_ids'])
for site in sites:
valid_slice_ids += site['slice_ids']
+ # techs can view all slices on the nodes at their site
+ if 'tech' in self.caller['roles'] and self.caller['site_ids']:
+ nodes = Nodes(self.api, {'site_id': self.caller['site_ids']}, ['site_id', 'slice_ids'])
+ for node in nodes:
+ valid_slice_ids.extend(node['slice_ids'])
if not valid_slice_ids:
return []
# Remove slice_tag_id if not specified
if added_fields:
for slice_tag in slice_tags:
- if 'slice_tag_id' in slice_tag:
- del slice_tag['slice_tag_id']
+ if 'slice_tag_id' in slice_tag:
+ del slice_tag['slice_tag_id']
return slice_tags