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 Auth
7 can_update = lambda (field, value): field in \
8 ['name', 'abbreviated_name', 'login_base',
9 'is_public', 'latitude', 'longitude', 'url',
10 'max_slices', 'max_slivers']
12 class AddSite(Method):
14 Adds a new site, and creates a node group for that site. Any
15 fields specified in site_fields are used, otherwise defaults are
18 Returns the new site_id (> 0) if successful, faults otherwise.
23 site_fields = dict(filter(can_update, Site.fields.items()))
30 returns = Parameter(int, 'New site_id (> 0) if successful')
33 def call(self, auth, site_fields):
34 site_fields = dict(filter(can_update, site_fields.items()))
35 site = Site(self.api, site_fields)
38 self.object_ids = [site['site_id']]
40 return site['site_id']