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
split plc.d/ and db-config.d between myplc and plcapi modules as a first step
[plcapi.git]
/
PLC
/
Methods
/
AddSite.py
diff --git
a/PLC/Methods/AddSite.py
b/PLC/Methods/AddSite.py
index
322c356
..
239de70
100644
(file)
--- a/
PLC/Methods/AddSite.py
+++ b/
PLC/Methods/AddSite.py
@@
-1,17
+1,20
@@
+# $Id$
+# $URL$
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.Sites import Site, Sites
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
Password
Auth
+from PLC.Auth import Auth
can_update = lambda (field, value): field in \
can_update = lambda (field, value): field in \
- ['is_public', 'latitude', 'longitude', 'url',
- 'organization_id', 'ext_consortium_id']
+ ['name', 'abbreviated_name', 'login_base',
+ 'is_public', 'latitude', 'longitude', 'url',
+ 'max_slices', 'max_slivers', 'enabled', 'ext_consortium_id']
class AddSite(Method):
"""
Adds a new site, and creates a node group for that site. Any
class AddSite(Method):
"""
Adds a new site, and creates a node group for that site. Any
- fields specified in
optional_val
s are used, otherwise defaults are
+ fields specified in
site_field
s are used, otherwise defaults are
used.
Returns the new site_id (> 0) if successful, faults otherwise.
used.
Returns the new site_id (> 0) if successful, faults otherwise.
@@
-19,24
+22,22
@@
class AddSite(Method):
roles = ['admin']
roles = ['admin']
-
upda
te_fields = dict(filter(can_update, Site.fields.items()))
+
si
te_fields = dict(filter(can_update, Site.fields.items()))
accepts = [
accepts = [
- PasswordAuth(),
- Site.fields['name'],
- Site.fields['abbreviated_name'],
- Site.fields['login_base'],
- update_fields
+ Auth(),
+ site_fields
]
returns = Parameter(int, 'New site_id (> 0) if successful')
]
returns = Parameter(int, 'New site_id (> 0) if successful')
- def call(self, auth,
name, abbreviated_name, login_base, site_fields = {}
):
+ def call(self, auth,
site_fields
):
site_fields = dict(filter(can_update, site_fields.items()))
site = Site(self.api, site_fields)
site_fields = dict(filter(can_update, site_fields.items()))
site = Site(self.api, site_fields)
- site['name'] = name
- site['abbreviated_name'] = abbreviated_name
- site['login_base'] = login_base
site.sync()
site.sync()
-
+
+ # Logging variables
+ self.event_objects = {'Site': [site['site_id']]}
+ self.message = 'Site %d created' % site['site_id']
+
return site['site_id']
return site['site_id']