From: Mark Huang Date: Wed, 29 Mar 2006 19:17:26 +0000 (+0000) Subject: - always update system slice attributes in case the url or SSL public X-Git-Tag: myplc-0_4-rc1~107 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=319a096ea775d3bdb27de6df3826b20480fdd235;p=myplc.git - always update system slice attributes in case the url or SSL public key changes --- diff --git a/api-config b/api-config index 215a840..d217042 100755 --- a/api-config +++ b/api-config @@ -6,7 +6,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: api-config,v 1.3 2006/03/28 22:03:21 mlhuang Exp $ +# $Id: api-config,v 1.4 2006/03/28 22:35:42 mlhuang Exp $ # import plcapilib @@ -186,39 +186,42 @@ def main(): attribute_type['min_role_id'], attribute_type['max_per_slice'], attribute_type['is_exclusive'], attribute_type['value_fields']) - if not SliceListNames(): - # Get contents of SSL public certificate used for signing tickets + # Get contents of SSL public certificate used for signing tickets + try: + plc_ticket_pubkey = "" + for line in file(plc_api['ssl_key_pub']): + # Skip comments + if line[0:5] != "-----": + # XXX The embedded newlines matter, do not strip()! + plc_ticket_pubkey += line + except: + plc_ticket_pubkey = '%KEY%' + + # Create/update system slices + slices = [{'name': "pl_conf", + 'description': "PlanetLab Slice Creation Service (SCS)", + 'url': url, + 'attributes': {'plc_slice_type': {'type': "VServerSlice"}, + 'plc_agent_version': {'version': "1.0"}, + 'plc_ticket_pubkey': {'key': plc_ticket_pubkey}}}, + {'name': "pl_conf_vserverslice", + 'description': "Default attributes for vserver slices", + 'url': url, + 'attributes': {'nm_cpu_share': {'cpu_share': 32}, + 'plc_slice_type': {'type': "VServerSlice"}, + 'nm_disk_quota': {'quota': 5000000}}}] + for slice in slices: try: - plc_ticket_pubkey = "" - for line in file(plc_api['ssl_key_pub']): - # Skip comments - if line[0:5] != "-----": - # XXX The embedded newlines matter, do not strip()! - plc_ticket_pubkey += line + SliceInfo([slice['name']]) except: - plc_ticket_pubkey = '%KEY%' - - # Create system slices - slices = [{'name': "pl_conf", - 'description': "PlanetLab Slice Creation Service (SCS)", - 'url': url, - 'attributes': {'plc_slice_type': {'type': "VServerSlice"}, - 'plc_agent_version': {'version': "1.0"}, - 'plc_ticket_pubkey': {'key': plc_ticket_pubkey}}}, - {'name': "pl_conf_vserverslice", - 'description': "Default attributes for vserver slices", - 'url': url, - 'attributes': {'nm_cpu_share': {'cpu_share': 32}, - 'plc_slice_type': {'type': "VServerSlice"}, - 'nm_disk_quota': {'quota': 5000000}}}] - for slice in slices: SliceCreate(slice['name']) - SliceUpdate(slice['name'], slice['url'], slice['description']) SliceSetInstantiationMethod(slice['name'], 'plc-instantiated') - # Renew forever - SliceRenew(slice['name'], sys.maxint) - for attribute, values in slice['attributes'].iteritems(): - SliceAttributeAdd(slice['name'], attribute, values) + SliceUpdate(slice['name'], slice['url'], slice['description']) + # Renew forever + SliceRenew(slice['name'], sys.maxint) + # Create/update all attributes + for attribute, values in slice['attributes'].iteritems(): + SliceAttributeSet(slice['name'], attribute, values) if __name__ == '__main__':