+
+
+ log.write( "Identifying boot server and setting up /etc/planetlab entries" )
+
+ # need to pull the server name we contacted. 2.x cds will have the
+ # info in /usr/bootme; 3.x cds in /usr/boot
+ if BOOT_CD_VERSION[0] == 2:
+ try:
+ boot_server= file(V2X_BOOTCD_SERVER_FILE).read().strip()
+ except IOError:
+ raise BootManagerException, \
+ "It appears we are running on a v2.x boot cd, but could " \
+ "not load contacted boot server from %s" % V2X_BOOTCD_SERVER_FILE
+
+ if boot_server == "":
+ raise BootManagerException, \
+ "It appears we are running on a v2.x boot cd, but %s " \
+ "appears to be blank." % V2X_BOOTCD_SERVER_FILE
+
+ cacert_file= "%s/%s/%s" % (V2X_BOOTCD_SERVER_CACERT_DIR,
+ boot_server, V2X_CACERT_NAME)
+
+ elif BOOT_CD_VERSION[0] == 3:
+ try:
+ boot_server= file(V3X_BOOTCD_SERVER_FILE).read().strip()
+ except IOError:
+ raise BootManagerException, \
+ "It appears we are running on a v3.x boot cd, but could " \
+ "not load contacted boot server from %s" % V3X_BOOTCD_SERVER_FILE
+
+ if boot_server == "":
+ raise BootManagerException, \
+ "It appears we are running on a v3.x boot cd, but %s " \
+ "appears to be blank." % V3X_BOOTCD_SERVER_FILE
+
+ cacert_file= V3X_BOOTCD_SERVER_CACERT
+
+ else:
+ raise BootManagerException, "Unknown boot cd version."
+
+ if not os.access(cacert_file, os.R_OK):
+ raise BootManagerException, \
+ "Could not find the certificate for the " \
+ "specified boot server (at %s)" % cacert_file
+
+ # tell the log instance about the boot server so it knows
+ # where to upload the logs
+ try:
+ log.SetUploadServer( self.VARS['MA_BOOT_SERVER'] )
+ except KeyError, e:
+ log.LogEntry( "configuration does not contain boot server name." )
+ return
+
+
+ # now that we have the boot server name and the location of its certificate,
+ # write out /etc/planetlab/primary_ma with this info.
+ try:
+ primary_ma_file= file("/etc/planetlab/primary_ma","w")
+ primary_ma_file.write( "MA_NAME=\"Unknown\"\n" )
+ primary_ma_file.write( "MA_BOOT_SERVER=\"%s\"\n" % boot_server )
+ primary_ma_file.write( "MA_BOOT_SERVER_CACERT=\"%s\"\n" % cacert_file )
+ primary_ma_file.close()
+ primary_ma_file= None
+ except IOError:
+ raise BootManagerException, "Unable to write out /etc/planetlab/primary_ma"
+
+ vars['MA_BOOT_SERVER']= boot_server
+ vars['MA_BOOT_SERVER_CACRET']= cacert_file
+
+ self.Message( "Using boot server %s with certificate" %
+ (boot_server,cacert_file) )
+
+
+ log.write( "Opening connection to API server\n" )
+ api_server_url= "https://%s/PLCAPI/" % vars['MA_BOOT_SERVER']
+ api_inst= xmlrpclib.Server( api_server_url, verbose=0 )
+ vars['API_SERVER_INST']= api_inst
+