- add PlanetLabAuth to MyPLC installation
[myplc.git] / api-config
1 #!/usr/bin/python
2 #
3 # Bootstraps the PLC database with a default administrator account and
4 # a default site.
5 #
6 # Mark Huang <mlhuang@cs.princeton.edu>
7 # Copyright (C) 2006 The Trustees of Princeton University
8 #
9 # $Id: api-config,v 1.11 2006/05/26 19:57:30 mlhuang Exp $
10 #
11
12 import plcapilib
13 (plcapi, moreopts, argv) = plcapilib.plcapi(globals())
14 from plc_config import PLCConfiguration
15 import sys
16
17
18 def main():
19     cfg = PLCConfiguration()
20     cfg.load()
21     variables = cfg.variables()
22
23     # Load variables into dictionaries
24     (category, variablelist) = variables['plc']
25     plc = dict(zip(variablelist.keys(),
26                    [variable['value'] for variable in variablelist.values()]))
27
28     (category, variablelist) = variables['plc_www']
29     plc_www = dict(zip(variablelist.keys(),
30                        [variable['value'] for variable in variablelist.values()]))
31
32     (category, variablelist) = variables['plc_api']
33     plc_api = dict(zip(variablelist.keys(),
34                        [variable['value'] for variable in variablelist.values()]))
35
36     # Create/update the default administrator account (should be
37     # person_id 2).
38     admin = { 'person_id': 2,
39               'first_name': "Default",
40               'last_name': "Administrator",
41               'email': plc['root_user'],
42               'password': plc['root_password'] }
43     persons = AdmGetPersons([admin['person_id']])
44     if not persons:
45         person_id = AdmAddPerson(admin['first_name'], admin['last_name'], admin)
46         if person_id != admin['person_id']:
47             # Huh? Someone deleted the account manually from the database.
48             AdmDeletePerson(person_id)
49             raise Exception, "Someone deleted the \"%s %s\" account from the database!" % \
50                   (admin['first_name'], admin['last_name'])
51         AdmSetPersonEnabled(person_id, True)
52     else:
53         person_id = persons[0]['person_id']
54         AdmUpdatePerson(person_id, admin)
55
56     # Create/update the default site (should be site_id 1)
57     if plc_www['port'] == '80':
58         url = "http://" + plc_www['host'] + "/"
59     elif plc_www['port'] == '443':
60         url = "https://" + plc_www['host'] + "/"
61     else:
62         url = "http://" + plc_www['host'] + ":" + plc_www['port'] + "/"
63     site = { 'site_id': 1,
64              'name': plc['name'] + " Central",
65              'abbreviated_name': plc['name'],
66              # XXX Default site slice_prefix/login_base must be "pl_"
67              # 'login_base': plc['slice_prefix'],
68              'login_base': "pl",
69              'is_public': False,
70              'url': url,
71              'max_slices': 100 }
72
73     sites = AdmGetSites([site['site_id']])
74     if not sites:
75         site_id = AdmAddSite(site['name'], site['abbreviated_name'], site['login_base'], site)
76         if site_id != site['site_id']:
77             AdmDeleteSite(site_id)
78             raise Exception, "Someone deleted the \"%s\" site from the database!" % \
79                   site['name']
80         sites = [site]
81
82     # Must call AdmUpdateSite() even after AdmAddSite() to update max_slices
83     site_id = sites[0]['site_id']
84     # XXX login_base cannot be updated
85     del site['login_base']
86     AdmUpdateSite(site_id, site)
87
88     # The default administrator account must be associated with a site
89     # in order to login.
90     AdmAddPersonToSite(admin['person_id'], site['site_id'])
91     AdmSetPersonPrimarySite(admin['person_id'], site['site_id'])
92
93     # Grant admin and PI roles to the default administrator account
94     AdmGrantRoleToPerson(admin['person_id'], 10)
95     AdmGrantRoleToPerson(admin['person_id'], 20)
96
97     # Setup default PlanetLabConf entries
98     default_conf_files = [
99         # NTP configuration
100         {'enabled': 1,
101          'source': 'PlanetLabConf/ntpconf.php',
102          'dest': '/etc/ntp.conf',
103          'file_permissions': '644',
104          'file_owner': 'root',
105          'file_group': 'root',
106          'preinstall_cmd': '',
107          'postinstall_cmd': '/etc/rc.d/init.d/ntpd restart',
108          'error_cmd': '',
109          'ignore_cmd_errors': 0,
110          'always_update': 0},
111         {'enabled': 1,
112          'source': 'PlanetLabConf/ntptickers.php',
113          'dest': '/etc/ntp/step-tickers',
114          'file_permissions': '644',
115          'file_owner': 'root',
116          'file_group': 'root',
117          'preinstall_cmd': '',
118          'postinstall_cmd': '/etc/rc.d/init.d/ntpd restart',
119          'error_cmd': '',
120          'ignore_cmd_errors': 0,
121          'always_update': 0},
122
123         # SSH server configuration
124         {'enabled': 1,
125          'source': 'PlanetLabConf/sshd_config',
126          'dest': '/etc/ssh/sshd_config',
127          'file_permissions': '600',
128          'file_owner': 'root',
129          'file_group': 'root',
130          'preinstall_cmd': '',
131          'postinstall_cmd': '/etc/init.d/sshd restart',
132          'error_cmd': '',
133          'ignore_cmd_errors': 0,
134          'always_update': 0},
135
136         # Administrative SSH keys
137         {'enabled': 1,
138          'source': 'PlanetLabConf/keys.php?root',
139          'dest': '/root/.ssh/authorized_keys',
140          'file_permissions': '644',
141          'file_owner': 'root',
142          'file_group': 'root',
143          'preinstall_cmd': '',
144          'postinstall_cmd': '',
145          'error_cmd': '',
146          'ignore_cmd_errors': 0,
147          'always_update': 0},
148         {'enabled': 1,
149          'source': 'PlanetLabConf/keys.php?site_admin',
150          'dest': '/home/site_admin/.ssh/authorized_keys',
151          'file_permissions': '644',
152          'file_owner': 'site_admin',
153          'file_group': 'site_admin',
154          'preinstall_cmd': 'grep -q site_admin /etc/passwd',
155          'postinstall_cmd': '',
156          'error_cmd': '',
157          'ignore_cmd_errors': 0,
158          'always_update': 0},
159         {'enabled': 1,
160          'source': 'PlanetLabConf/keys.php?role=admin',
161          'dest': '/home/pl_admin/.ssh/authorized_keys',
162          'file_permissions': '644',
163          'file_owner': 'pl_admin',
164          'file_group': 'pl_admin',
165          'preinstall_cmd': 'grep -q pl_admin /etc/passwd',
166          'postinstall_cmd': '',
167          'error_cmd': '',
168          'ignore_cmd_errors': 0,
169          'always_update': 0},
170
171         # Log rotation configuration
172         {'enabled': 1,
173          'source': 'PlanetLabConf/logrotate.conf',
174          'dest': '/etc/logrotate.conf',
175          'file_permissions': '644',
176          'file_owner': 'root',
177          'file_group': 'root',
178          'preinstall_cmd': '',
179          'postinstall_cmd': '',
180          'error_cmd': '',
181          'ignore_cmd_errors': 0,
182          'always_update': 0},
183
184         # updatedb/locate nightly cron job
185         {'enabled': 1,
186          'source': 'PlanetLabConf/slocate.cron',
187          'dest': '/etc/cron.daily/slocate.cron',
188          'file_permissions': '755',
189          'file_owner': 'root',
190          'file_group': 'root',
191          'preinstall_cmd': '',
192          'postinstall_cmd': '',
193          'error_cmd': '',
194          'ignore_cmd_errors': 0,
195          'always_update': 0},
196
197         # YUM configuration
198         {'enabled': 1,
199          'source': 'PlanetLabConf/yum.conf.php?gpgcheck=1',
200          'dest': '/etc/yum.conf',
201          'file_permissions': '644',
202          'file_owner': 'root',
203          'file_group': 'root',
204          'preinstall_cmd': '',
205          'postinstall_cmd': '',
206          'error_cmd': '',
207          'ignore_cmd_errors': 0,
208          'always_update': 0},
209         {'enabled': 1,
210          'source': 'PlanetLabConf/delete-rpm-list-production',
211          'dest': '/etc/planetlab/delete-rpm-list',
212          'file_permissions': '644',
213          'file_owner': 'root',
214          'file_group': 'root',
215          'preinstall_cmd': '',
216          'postinstall_cmd': '',
217          'error_cmd': '',
218          'ignore_cmd_errors': 0,
219          'always_update': 0},
220
221         # PLC configuration
222         {'enabled': 1,
223          'source': 'PlanetLabConf/get_plc_config.php',
224          'dest': '/etc/planetlab/plc_config',
225          'file_permissions': '644',
226          'file_owner': 'root',
227          'file_group': 'root',
228          'preinstall_cmd': '',
229          'postinstall_cmd': '',
230          'error_cmd': '',
231          'ignore_cmd_errors': 0,
232          'always_update': 0},
233         {'enabled': 1,
234          'source': 'PlanetLabConf/get_plc_config.php?python',
235          'dest': '/etc/planetlab/plc_config.py',
236          'file_permissions': '644',
237          'file_owner': 'root',
238          'file_group': 'root',
239          'preinstall_cmd': '',
240          'postinstall_cmd': '',
241          'error_cmd': '',
242          'ignore_cmd_errors': 0,
243          'always_update': 0},
244         {'enabled': 1,
245          'source': 'PlanetLabConf/get_plc_config.php?perl',
246          'dest': '/etc/planetlab/plc_config.pl',
247          'file_permissions': '644',
248          'file_owner': 'root',
249          'file_group': 'root',
250          'preinstall_cmd': '',
251          'postinstall_cmd': '',
252          'error_cmd': '',
253          'ignore_cmd_errors': 0,
254          'always_update': 0},
255         {'enabled': 1,
256          'source': 'PlanetLabConf/get_plc_config.php?php',
257          'dest': '/etc/planetlab/php/plc_config.php',
258          'file_permissions': '644',
259          'file_owner': 'root',
260          'file_group': 'root',
261          'preinstall_cmd': '',
262          'postinstall_cmd': '',
263          'error_cmd': '',
264          'ignore_cmd_errors': 0,
265          'always_update': 0},
266
267         # Node Manager configuration
268         {'enabled': 1,
269          'source': 'PlanetLabConf/pl_nm-v3.conf',
270          'dest': '/etc/planetlab/pl_nm.conf',
271          'file_permissions': '644',
272          'file_owner': 'root',
273          'file_group': 'root',
274          'preinstall_cmd': '',
275          'postinstall_cmd': '/etc/init.d/pl_nm restart',
276          'error_cmd': '',
277          'ignore_cmd_errors': 0,
278          'always_update': 0},
279         {'enabled': 1,
280          'source': 'PlanetLabConf/RootResources/plc_slice_pool.php',
281          'dest': '/home/pl_nm/RootResources/plc_slice_pool',
282          'file_permissions': '644',
283          'file_owner': 'pl_nm',
284          'file_group': 'pl_nm',
285          'preinstall_cmd': '',
286          'postinstall_cmd': '',
287          'error_cmd': '',
288          'ignore_cmd_errors': 0,
289          'always_update': 0},
290         {'enabled': 1,
291          'source': 'PlanetLabConf/RootResources/pl_conf.py',
292          'dest': '/home/pl_nm/RootResources/pl_conf',
293          'file_permissions': '644',
294          'file_owner': 'pl_nm',
295          'file_group': 'pl_nm',
296          'preinstall_cmd': '',
297          'postinstall_cmd': '/etc/init.d/pl_nm restart',
298          'error_cmd': '',
299          'ignore_cmd_errors': 0,
300          'always_update': 0},
301         {'enabled': 1,
302          'source': 'PlanetLabConf/RootResources/pl_netflow.py',
303          'dest': '/home/pl_nm/RootResources/pl_netflow',
304          'file_permissions': '644',
305          'file_owner': 'pl_nm',
306          'file_group': 'pl_nm',
307          'preinstall_cmd': '',
308          'postinstall_cmd': '',
309          'error_cmd': '',
310          'ignore_cmd_errors': 0,
311          'always_update': 0},
312
313         # Proper configuration
314         {'enabled': 1,
315          'source': 'PlanetLabConf/propd-NM-1.0.conf',
316          'dest': '/etc/proper/propd.conf',
317          'file_permissions': '644',
318          'file_owner': 'root',
319          'file_group': 'root',
320          'preinstall_cmd': '',
321          'postinstall_cmd': '/etc/init.d/proper restart',
322          'error_cmd': '',
323          'ignore_cmd_errors': 1,
324          'always_update': 0},
325
326         # Bandwidth cap
327         {'enabled': 1,
328          'source': 'PlanetLabConf/bwlimit.php',
329          'dest': '/etc/planetlab/bwcap',
330          'file_permissions': '644',
331          'file_owner': 'root',
332          'file_group': 'root',
333          'preinstall_cmd': '',
334          'postinstall_cmd': '/etc/init.d/pl_nm restart',
335          'error_cmd': '',
336          'ignore_cmd_errors': 1,
337          'always_update': 0},
338
339         # Proxy ARP setup
340         {'enabled': 1,
341          'source': 'PlanetLabConf/proxies.php',
342          'dest': '/etc/planetlab/proxies',
343          'file_permissions': '644',
344          'file_owner': 'root',
345          'file_group': 'root',
346          'preinstall_cmd': '',
347          'postinstall_cmd': '',
348          'error_cmd': '',
349          'ignore_cmd_errors': 0,
350          'always_update': 0},
351
352         # Firewall configuration
353         {'enabled': 1,
354          'source': 'PlanetLabConf/iptables',
355          'dest': '/etc/sysconfig/iptables',
356          'file_permissions': '600',
357          'file_owner': 'root',
358          'file_group': 'root',
359          'preinstall_cmd': '',
360          'postinstall_cmd': '',
361          'error_cmd': '',
362          'ignore_cmd_errors': 0,
363          'always_update': 0},
364         {'enabled': 1,
365          'source': 'PlanetLabConf/blacklist.php',
366          'dest': '/etc/planetlab/blacklist',
367          'file_permissions': '600',
368          'file_owner': 'root',
369          'file_group': 'root',
370          'preinstall_cmd': '',
371          'postinstall_cmd': '/sbin/iptables-restore --noflush < /etc/planetlab/blacklist',
372          'error_cmd': '',
373          'ignore_cmd_errors': 1,
374          'always_update': 1},
375
376         # /etc/issue
377         {'enabled': 1,
378          'source': 'PlanetLabConf/issue.php',
379          'dest': '/etc/issue',
380          'file_permissions': '644',
381          'file_owner': 'root',
382          'file_group': 'root',
383          'preinstall_cmd': '',
384          'postinstall_cmd': '',
385          'error_cmd': '',
386          'ignore_cmd_errors': 0,
387          'always_update': 0},
388
389         # Kernel parameters
390         {'enabled': 1,
391          'source': 'PlanetLabConf/sysctl.php',
392          'dest': '/etc/sysctl.conf',
393          'file_permissions': '644',
394          'file_owner': 'root',
395          'file_group': 'root',
396          'preinstall_cmd': '',
397          'postinstall_cmd': '/sbin/sysctl -e -p /etc/sysctl.conf',
398          'error_cmd': '',
399          'ignore_cmd_errors': 0,
400          'always_update': 1},
401
402         # Sendmail configuration
403         {'enabled': 1,
404          'source': 'PlanetLabConf/alpha-sendmail.mc',
405          'dest': '/etc/mail/sendmail.mc',
406          'file_permissions': '644',
407          'file_owner': 'root',
408          'file_group': 'root',
409          'preinstall_cmd': '',
410          'postinstall_cmd': '',
411          'error_cmd': '',
412          'ignore_cmd_errors': 0,
413          'always_update': 0},
414         {'enabled': 1,
415          'source': 'PlanetLabConf/alpha-sendmail.cf',
416          'dest': '/etc/mail/sendmail.cf',
417          'file_permissions': '644',
418          'file_owner': 'root',
419          'file_group': 'root',
420          'preinstall_cmd': '',
421          'postinstall_cmd': 'service sendmail restart',
422          'error_cmd': '',
423          'ignore_cmd_errors': 0,
424          'always_update': 0},
425
426         # GPG signing keys
427         {'enabled': 1,
428          'source': 'PlanetLabConf/RPM-GPG-KEY-fedora',
429          'dest': '/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora',
430          'file_permissions': '644',
431          'file_owner': 'root',
432          'file_group': 'root',
433          'preinstall_cmd': '',
434          'postinstall_cmd': 'rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora',
435          'error_cmd': '',
436          'ignore_cmd_errors': 0,
437          'always_update': 0},
438         {'enabled': 1,
439          'source': 'PlanetLabConf/get_gpg_key.php',
440          'dest': '/etc/pki/rpm-gpg/RPM-GPG-KEY-planetlab',
441          'file_permissions': '644',
442          'file_owner': 'root',
443          'file_group': 'root',
444          'preinstall_cmd': '',
445          'postinstall_cmd': 'rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-planetlab',
446          'error_cmd': '',
447          'ignore_cmd_errors': 0,
448          'always_update': 0},
449
450         # Ping of death configuration
451         {'enabled': 1,
452          'source': 'PlanetLabConf/ipod.conf.php',
453          'dest': '/etc/ipod.conf',
454          'file_permissions': '644',
455          'file_owner': 'root',
456          'file_group': 'root',
457          'preinstall_cmd': '',
458          'postinstall_cmd': '',
459          'error_cmd': '',
460          'ignore_cmd_errors': 0,
461          'always_update': 0},
462
463         # sudo configuration
464         {'enabled': 1,
465          'source': 'PlanetLabConf/v3-sudoers.php',
466          'dest': '/etc/sudoers',
467          'file_permissions': '440',
468          'file_owner': 'root',
469          'file_group': 'root',
470          'preinstall_cmd': '',
471          'postinstall_cmd': '/usr/sbin/visudo -c',
472          'error_cmd': '',
473          'ignore_cmd_errors': 0,
474          'always_update': 0}]
475
476     # Get list of existing (enabled, global) files
477     conf_files = AdmGetConfFile()
478     conf_files = filter(lambda conf_file: conf_file['enabled'] and \
479                                           not conf_file['node_id'] and \
480                                           not conf_file['nodegroup_id'],
481                         conf_files)
482     dests = [conf_file['dest'] for conf_file in conf_files]
483     conf_files = dict(zip(dests, conf_files))
484
485     # Create/update default PlanetLabConf entries
486     for default_conf_file in default_conf_files:
487         if default_conf_file['dest'] not in dests:
488             AdmCreateConfFile(default_conf_file['enabled'],
489                               default_conf_file['source'],
490                               default_conf_file['dest'],
491                               default_conf_file['file_permissions'],
492                               default_conf_file['file_owner'],
493                               default_conf_file['file_group'],
494                               default_conf_file['preinstall_cmd'],
495                               default_conf_file['postinstall_cmd'],
496                               default_conf_file['error_cmd'],
497                               default_conf_file['ignore_cmd_errors'],
498                               default_conf_file['always_update'])
499         else:
500             conf_file = conf_files[default_conf_file['dest']]
501             AdmUpdateConfFile(conf_file['conf_file_id'], default_conf_file)
502
503     # Setup default slice attribute types
504     default_attribute_types = [
505         # Slice type (only vserver is supported)
506         {'name': "plc_slice_type",
507          'description': "Type of slice rspec to be created",
508          'is_exclusive': True, 'min_role_id': 20, 'max_per_slice': 1,
509          'value_fields': [{'description': "rspec class",
510                            'name': "type",
511                            'type': "string"}]},
512
513         # Slice initialization script
514         {'name': "initscript",
515          'description': "slice initialization script",
516          'is_exclusive': False, 'min_role_id': 10, 'max_per_slice': 1,
517          'value_fields': [{'description': "",
518                            'name': "initscript_id",
519                            'type': "integer"}]},
520
521         # CPU share (general_prop_share is deprecated)
522         {'name': "general_prop_share",
523          'description': "general share",
524          'is_exclusive': False, 'min_role_id': 10, 'max_per_slice': 1,
525          'value_fields': [{'description': "",
526                            'name': "general_prop_share",
527                            'type': "integer"}]},
528         {'name': "nm_cpu_share",
529          'description': "Number of CPU shares to be allocated to slice",
530          'is_exclusive': True, 'min_role_id': 10, 'max_per_slice': 1,
531          'value_fields': [{'description': "number of shares",
532                            'name': "cpu_share",
533                            'type': "integer"}]},
534
535         # Bandwidth limits
536         {'name': "nm_net_min_rate",
537          'description': "Minimum network Tx bandwidth",
538          'is_exclusive': True, 'min_role_id': 10, 'max_per_slice': 1,
539          'value_fields': [{'description': "rate (bps)",
540                            'name': "rate",
541                            'type': "integer"}]},
542         {'name': "nm_net_max_rate",
543          'description': "Maximum network Tx bandwidth",
544          'is_exclusive': True, 'min_role_id': 10, 'max_per_slice': 1,
545          'value_fields': [{'description': "rate (bps)",
546                            'name': "rate",
547                            'type': "integer"}]},
548         {'name': "nm_net_avg_rate",
549          'description': "Average daily network Tx bandwidth",
550          'is_exclusive': True, 'min_role_id': 10, 'max_per_slice': 1,
551          'value_fields': [{'description': "rate (bps)",
552                            'name': "rate",
553                            'type': "integer"}]},
554         {'name': "nm_net_exempt_min_rate",
555          'description': "Minimum network Tx bandwidth to Internet2 destinations",
556          'is_exclusive': True, 'min_role_id': 10, 'max_per_slice': 1,
557          'value_fields': [{'description': "rate (bps)",
558                            'name': "rate",
559                            'type': "integer"}]},
560         {'name': "nm_net_exempt_max_rate",
561          'description': "Maximum network Tx bandwidth to Internet2 destinations",
562          'is_exclusive': True, 'min_role_id': 10, 'max_per_slice': 1,
563          'value_fields': [{'description': "rate (bps)",
564                            'name': "rate",
565                            'type': "integer"}]},
566         {'name': "nm_net_exempt avg_rate",
567          'description': "Average daily network Tx bandwidth to Internet2 destinations",
568          'is_exclusive': True, 'min_role_id': 10, 'max_per_slice': 1,
569          'value_fields': [{'description': "rate (bps)",
570                            'name': "rate",
571                            'type': "integer"}]},
572
573         # Disk quota
574         {'name': "nm_disk_quota",
575          'description': "Disk quota",
576          'is_exclusive': True, 'min_role_id': 10, 'max_per_slice': 1,
577          'value_fields': [{'description': "Number of 1k disk blocks",
578                            'name': "quota",
579                            'type': "integer"}]},
580
581         # Special attributes applicable to Slice Creation Service (pl_conf) slice
582         {'name': "plc_agent_version",
583          'description': "Version of PLC agent (slice creation service) software to be deployed",
584          'is_exclusive': True, 'min_role_id': 10, 'max_per_slice': 1,
585          'value_fields': [{'description': "current version of PLC agent (SCS)",
586                            'name': "version",
587                            'type': "string"}]},
588         {'name': "plc_ticket_pubkey",
589          'description': "Public key used to verify PLC-signed tickets",
590          'is_exclusive': True, 'min_role_id': 10, 'max_per_slice': 1,
591          'value_fields': [{'description': "PEM-encoded public key",
592                            'name': "key",
593                            'type': "string"}]}]
594
595     # Get list of existing attribute types
596     attribute_types = SliceAttributeTypeList()
597
598     # Create/update default slice attribute types
599     for default_attribute_type in default_attribute_types:
600         if default_attribute_type['name'] not in attribute_types:
601             SliceAttributeTypeCreate(default_attribute_type['name'],
602                                      default_attribute_type['description'],
603                                      default_attribute_type['min_role_id'],
604                                      default_attribute_type['max_per_slice'],
605                                      default_attribute_type['is_exclusive'],
606                                      default_attribute_type['value_fields'])
607         else:
608             # XXX No way to update slice attribute types
609             pass
610
611     # Get contents of SSL public certificate used for signing tickets
612     try:
613         plc_ticket_pubkey = ""
614         for line in file(plc_api['ssl_key_pub']):
615             # Skip comments
616             if line[0:5] != "-----":
617                 # XXX The embedded newlines matter, do not strip()!
618                 plc_ticket_pubkey += line
619     except:
620         plc_ticket_pubkey = '%KEY%'
621
622     # Create/update system slices
623     slices = [{'name': "pl_conf",
624                'description': "PlanetLab Slice Creation Service (SCS)",
625                'url': url,
626                'attributes': {'plc_slice_type': {'type': "VServerSlice"},
627                               'plc_agent_version': {'version': "1.0"},
628                               'plc_ticket_pubkey': {'key': plc_ticket_pubkey}}},
629               {'name': "pl_conf_vserverslice",
630                'description': "Default attributes for vserver slices",
631                'url': url,
632                'attributes': {'nm_cpu_share': {'cpu_share': 32},
633                               'plc_slice_type': {'type': "VServerSlice"},
634                               'nm_disk_quota': {'quota': 5000000}}}]
635     for slice in slices:
636         try:
637             SliceInfo([slice['name']])
638         except:
639             SliceCreate(slice['name'])
640             SliceSetInstantiationMethod(slice['name'], 'plc-instantiated')
641         SliceUpdate(slice['name'], slice['url'], slice['description'])
642         # Renew forever
643         SliceRenew(slice['name'], sys.maxint)
644         # Create/update all attributes
645         for attribute, values in slice['attributes'].iteritems():
646             SliceAttributeSet(slice['name'], attribute, values)
647
648
649 if __name__ == '__main__':
650     main()