3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.Sites import Site, Sites
7 from PLC.Auth import Auth
9 can_update = lambda (field, value): field in \
10 ['name', 'abbreviated_name', 'login_base',
11 'is_public', 'latitude', 'longitude', 'url',
12 'max_slices', 'max_slivers', 'enabled', 'ext_consortium_id']
14 class AddSite(Method):
16 Adds a new site, and creates a node group for that site. Any
17 fields specified in site_fields are used, otherwise defaults are
20 Returns the new site_id (> 0) if successful, faults otherwise.
25 site_fields = dict(filter(can_update, Site.fields.items()))
32 returns = Parameter(int, 'New site_id (> 0) if successful')
34 def call(self, auth, site_fields):
35 site_fields = dict(filter(can_update, site_fields.items()))
36 site = Site(self.api, site_fields)
40 self.event_objects = {'Site': [site['site_id']]}
41 self.message = 'Site %d created' % site['site_id']
43 return site['site_id']