key={'key_type':'ssh',
'key':'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4jNj8yT9ieEc6nSJz/ESu4fui9WrJ2y/MCfqIZ5WcdVKhBFUYyIenmUaeTduMcSqvoYRQ4QnFR1BFdLG8XR9D6FWZ5zTKUgpkew22EVNeqai4IXeWYKyt1Qf3ehaz9E3o1PG/bmQNIM6aQay6TD1Y4lqXI+eTVXVQev4K2fixySjFQpp9RB4UHbeA8c28yoa/cgAYHqCqlvm9uvpGMjgm/Qa4M+ZeO7NdjowfaF/wF4BQIzVFN9YRhvQ/d8WDz84B5Pr0J7pWpaX7EyC4bvdskxl6kmdNIwIRcIe4OcuIiX5Z9oO+7h/chsEVJWF4vqNIYlL9Zvyhnr0hLLhhuk2bw== root@onelab-test.inria.fr'}
+initscripts =[{ 'enabled' : True,
+ 'name':'Test1',
+ 'script' : '#! /bin/sh\n echo Starting test initscript: Stage 1\n date > /tmp/test_initscript_stage1.log \n ',
+ },
+ { 'enabled' : True,
+ 'name':'Test2',
+ 'script' : '#! /bin/sh\n echo Starting test initscript: Stage 2\n date > /tmp/test_initscript_stage2.log \n ',
+ }
+ ]
slice1_spec={
'slice_spec':{'name':'ts_slicetest1',
},
'slice_users' : [ site_users['pi_spec'], site_users['tech_spec'],site_users['tech_user_spec']],
'slice_nodes' : [ site1_nodes['node1'], site1_nodes['node2'] ],
+'slice_initscript' : initscripts[0],
}
-slices_specs= [slice1_spec]
-
-
+slice2_spec={
+'slice_spec':{'name':'ts_slicetest2',
+ 'instantiation':'plc-instantiated',
+ 'url':'http://foo2@ffo2.com',
+ 'description':'testslice the second slice for the site testsite',
+ 'max_nodes':100
+ },
+'slice_users' : [ site_users['pi_spec'], site_users['tech_spec'],site_users['tech_user_spec']],
+'slice_nodes' : [ site1_nodes['node1'], site1_nodes['node2'] ],
+'slice_initscript' : initscripts[1],
+}
+slices_specs= [slice1_spec, slice2_spec ]
test_plc.install_plc(url)
test_plc.config_plc(plc_spec)
##create all the sites under the new plc,and then populate them with
- ##nodes,persons and slices
+ ##nodes,persons and slices(with initscripts)
for site_spec in plc_spec['sites']:
utils.header('Creating site')
pp.pprint(site_spec)
pp.pprint(node_spec)
test_nodes.append(node_spec)
test_node = test_plc.init_node(test_site,node_spec,self.path)
+ test_node.add_initscripts()
test_node.create_slice ("pi")
utils.header('Starting vmware nodes')
test_site.run_vmware(test_nodes,display)
except Exception, e:
print str(e)
+ def add_initscripts(self):
+ try:
+ for initscript in TestConfig.initscripts:
+ utils.header('Adding Initscripts')
+ pp = pprint.PrettyPrinter(indent=4)
+ pp.pprint(initscript)
+ self.initscript_id=self.test_plc.server.AddInitScript(self.test_plc.auth_root(),
+ initscript)
+ except Exception, e:
+ print str(e)
+ exit (1)
+
def create_slice(self, role):
auth = self.test_site.anyuser_auth (role)
liste_hosts=[]
- #for l in liste_nodes_spec :
- # liste_hosts.append(l['hostname'])
try:
for slicespec in TestConfig.slices_specs :
utils.header('Creating Slice')
self.test_plc.server.AddSliceToNodes(auth,
slice_id,
liste_hosts)
+
+ self.test_plc.server.AddSliceAttribute(self.test_plc.auth_root(),
+ slice_id, 'initscript',
+ slicespec['slice_initscript']['name'])
+
except Exception, e:
print str(e)
sys.exit(1)