- filter={'boot_state':'rins'}
- self.test_plc.server.AddNode(auth,
- self.test_site.site_spec['site_fields']['login_base'],
- self.node_spec['node_fields'])
- self.test_plc.server.AddNodeNetwork(auth,self.name(),
- self.node_spec['network_fields'])
- self.test_plc.server.UpdateNode(auth, self.name(), filter)
-
- def conffile(self,image,hostname,path):
- template='%s/template-vmplayer/node.vmx'%(path)
- actual='%s/vmplayer-%s/node.vmx'%(path,hostname)
- sed_command="sed -e s,@BOOTCD@,%s,g %s > %s"%(image,template,actual)
- utils.header('Creating %s from %s'%(actual,template))
- utils.system(sed_command)
-
- def create_boot_cd(self,path):
- node_spec=self.node_spec
- hostname=node_spec['node_fields']['hostname']
- utils.header('Initializing vmplayer area for node %s'%hostname)
- clean_dir="rm -rf %s/vmplayer-%s"%(path,hostname)
- mkdir_command="mkdir -p %s/vmplayer-%s"%(path,hostname)
- tar_command="tar -C %s/template-vmplayer -cf - . | tar -C %s/vmplayer-%s -xf -"%(path,path,hostname)
- utils.system(clean_dir)
- utils.system(mkdir_command)
- utils.system(tar_command);
- utils.header('Creating boot medium for node %s'%hostname)
- encoded=self.test_plc.server.GetBootMedium(self.test_plc.auth_root(), hostname, 'node-iso', '')
+ rootauth=self.test_plc.auth_root()
+ server = self.test_plc.apiserver
+ node_id=server.AddNode(userauth,
+ self.test_site.site_spec['site_fields']['login_base'],
+ self.node_spec['node_fields'])
+ server.SetNodePlainBootstrapfs(userauth,
+ self.node_spec['node_fields']['hostname'],
+ 'YES')
+ # create as reinstall to avoid user confirmation
+ server.UpdateNode(userauth, self.name(), {'boot_state':'reinstall'})
+
+ if not self.test_plc.has_addresses_api():
+# print 'USING OLD INTERFACE'
+ # populate network interfaces - primary
+ server.AddInterface(userauth,self.name(),
+ self.node_spec['interface_fields'])
+ else:
+# print 'USING NEW INTERFACE with separate ip addresses'
+ # this is for setting the 'dns' stuff that now goes with the node
+ server.UpdateNode (userauth, self.name(), self.node_spec['node_fields_nint'])
+ interface_id = server.AddInterface (userauth, self.name(),self.node_spec['interface_fields_nint'])
+ server.AddIpAddress (userauth, interface_id, self.node_spec['ipaddress_fields'])
+ route_fields=self.node_spec['route_fields']
+ route_fields['interface_id']=interface_id
+ server.AddRoute (userauth, node_id, self.node_spec['route_fields'])
+ pass
+ # populate network interfaces - others
+ if self.node_spec.has_key('extra_interfaces'):
+ for interface in self.node_spec['extra_interfaces']:
+ server.AddInterface(userauth,self.name(), interface['interface_fields'])
+ if interface.has_key('settings'):
+ for (attribute,value) in interface['settings'].iteritems():
+ # locate node network
+ interface = server.GetInterfaces(userauth,{'ip':interface['interface_fields']['ip']})[0]
+ interface_id=interface['interface_id']
+ # locate or create node network attribute type
+ try:
+ interface_tagtype = server.GetTagTypes(userauth,{'name':attribute})[0]
+ except:
+ interface_tagtype = server.AddTagType(rootauth,{'category':'test',
+ 'tagname':attribute})
+ # attach value
+ server.AddInterfaceTag(userauth,interface_id,attribute,value)
+
+ def delete_node (self):
+ # uses the right auth as far as poss.
+ try:
+ ownername = self.node_spec['owner']
+ user_spec = self.test_site.locate_user(ownername)
+ test_user = TestUser(self.test_plc,self.test_site,user_spec)
+ auth = test_user.auth()
+ except:
+ auth=self.test_plc.auth_root()
+ self.test_plc.apiserver.DeleteNode(auth,self.name())
+
+ # Do most of the stuff locally - will be pushed on host_box - *not* the plc - later if needed
+ def qemu_local_init(self):
+ "all nodes : init a clean local directory for holding node-dep stuff like iso image..."
+ utils.system("rm -rf %s"%self.nodedir())
+ utils.system("mkdir %s"%self.nodedir())
+ if not self.is_qemu():
+ return True
+ return utils.system("rsync -v -a --exclude .svn template-qemu/ %s/"%self.nodedir())==0
+
+ def bootcd(self):
+ "all nodes: invoke GetBootMedium and store result locally"
+ utils.header("Calling GetBootMedium for %s"%self.name())
+ options = []
+ if self.is_qemu():
+ options.append('serial')
+ options.append('no-hangcheck')
+ encoded=self.test_plc.apiserver.GetBootMedium(self.test_plc.auth_root(),
+ self.name(), 'node-iso', '', options)