git://git.onelab.eu
/
plcapi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- fix log message
[plcapi.git]
/
PLC
/
Methods
/
UpdateSite.py
diff --git
a/PLC/Methods/UpdateSite.py
b/PLC/Methods/UpdateSite.py
index
776b084
..
c9c40b7
100644
(file)
--- a/
PLC/Methods/UpdateSite.py
+++ b/
PLC/Methods/UpdateSite.py
@@
-5,7
+5,7
@@
from PLC.Sites import Site, Sites
from PLC.Auth import Auth
can_update = lambda (field, value): field in \
from PLC.Auth import Auth
can_update = lambda (field, value): field in \
- ['name', 'abbreviated_name',
+ ['name', 'abbreviated_name',
'login_base',
'is_public', 'latitude', 'longitude', 'url',
'max_slices', 'max_slivers']
'is_public', 'latitude', 'longitude', 'url',
'max_slices', 'max_slivers']
@@
-15,7
+15,7
@@
class UpdateSite(Method):
updated, all other fields are left untouched.
PIs can only update sites they are a member of. Only admins can
updated, all other fields are left untouched.
PIs can only update sites they are a member of. Only admins can
- update max_slices.
+ update max_slices
, max_slivers, and login_base
.
Returns 1 if successful, faults otherwise.
"""
Returns 1 if successful, faults otherwise.
"""
@@
-40,9
+40,11
@@
class UpdateSite(Method):
sites = Sites(self.api, [site_id_or_login_base])
if not sites:
raise PLCInvalidArgument, "No such site"
sites = Sites(self.api, [site_id_or_login_base])
if not sites:
raise PLCInvalidArgument, "No such site"
-
site = sites[0]
site = sites[0]
+ if site['peer_id'] is not None:
+ raise PLCInvalidArgument, "Not a local site"
+
# Authenticated function
assert self.caller is not None
# Authenticated function
assert self.caller is not None
@@
-52,10
+54,16
@@
class UpdateSite(Method):
if site['site_id'] not in self.caller['site_ids']:
raise PLCPermissionDenied, "Not allowed to modify specified site"
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 site_fields:
- raise PLCInvalidArgument, "Only admins can update max_slices and max_slivers"
+ # Remove admin only fields
+ for key in 'max_slices', 'max_slivers', 'login_base':
+ del site_fields[key]
site.update(site_fields)
site.sync()
site.update(site_fields)
site.sync()
+ # Logging variables
+ self.object_ids = [site['site_id']]
+ self.message = 'Site %d updated: %s' % \
+ (site['site_id'], ", ".join(site_fields.keys()))
+
return 1
return 1