1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Sites import Site, Sites
5 from PLC.Auth import PasswordAuth
7 class AdmAddSite(Method):
9 Adds a new site, and creates a node group for that site. Any
10 fields specified in optional_vals are used, otherwise defaults are
13 Returns the new site_id (> 0) if successful, faults otherwise.
18 can_update = lambda (field, value): field in \
19 ['is_public', 'latitude', 'longitude', 'url',
20 'organization_id', 'ext_consortium_id']
21 update_fields = dict(filter(can_update, Site.fields.items()))
26 Site.fields['abbreviated_name'],
27 Site.fields['login_base'],
31 returns = Parameter(int, 'New site_id (> 0) if successful')
33 def call(self, auth, name, abbreviated_name, login_base, optional_vals = {}):
34 if filter(lambda field: field not in self.update_fields, optional_vals):
35 raise PLCInvalidArgument, "Invalid field specified"
37 site = Site(self.api, optional_vals)
39 site['abbreviated_name'] = abbreviated_name
40 site['login_base'] = login_base
43 return site['site_id']