X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=bin%2Fplc-kml.py;h=f091b82df77b7f730d6d930672a74f5b50faf091;hb=b466ae5477434db790d03928349f0d0aa18798d4;hp=3b0b8c62645398d88fe512289aeccddf33dadfef;hpb=82d099c7771dd3517bb300552e5b182f49bb27bc;p=myplc.git diff --git a/bin/plc-kml.py b/bin/plc-kml.py index 3b0b8c6..f091b82 100755 --- a/bin/plc-kml.py +++ b/bin/plc-kml.py @@ -46,7 +46,7 @@ class KmlMap: self.open() self.write_header() # cache peers - peers = GetPeers({},['peer_id','peername']) + peers = GetPeers() all_sites = GetSites({'enabled':True,'is_public':True}) all_sites.sort(KmlMap.site_compare) for site in all_sites: @@ -75,12 +75,13 @@ class KmlMap: self.write(""" """) - def peer_name (self,site, peers): + def peer_info (self,site, peers): if not site['peer_id']: - return "local" + return (api.config.PLC_NAME, "http://%s/"%api.config.PLC_API_HOST,) for peer in peers: if peer['peer_id'] == site['peer_id']: - return peer['peername'] + return (peer['peername'],peer['peer_url'].replace("PLCAPI/",""),) + return "Unknown peer_name" def write_site (self, site, peers): # discard sites with missing lat or lon @@ -100,94 +101,96 @@ class KmlMap: baseurl='http://%s'%api.config.PLC_WWW_HOST peer_id=site['peer_id'] + # STYLE + # the size for google icons + if not self.options.use_custom_icons: + if not peer_id: + # local sites + iconfile=default_local_builtin + xyspec="12803232" + else: + # remote + iconfile=default_foreign_builtin + xyspec="16003232" + iconurl="root://icons/%(iconfile)s"%locals() + # the size for our own brew of icons + else: + if not peer_id: + iconfile=self.options.local_icon + else: + iconfile=self.options.foreign_icon + iconurl="%(baseurl)s/%(iconfile)s"%locals() + xyspec="" + + iconspec="%(iconurl)s%(xyspec)s"%locals() + # open description - description = "
" + # can't seem to get classes to get through to the google maps API + # so have to use hard-wired settings + description = "" + description += "
" + description += "" # TESTBED - description += "" - description += "" + description += "" + description += "" + (peername,peerurl) = self.peer_info (site,peers) + description += "" # URL if site['url']: site_url=site['url'] - description += "" + description += "" + description += "" + description += "" + description += "" + + # Usage area + description += "" + description += "" - description += "" - description += "" - description += "" + # encapsulate usage in a table of its own + description += "" # close description - description += "
 
" - description += "Testbed" - description += "" - if peer_id: - peername = 'PlanetLab Central' - peerurl = 'http://www.planet-lab.org' - #self.peer_name(site,peers) - else: - peername = 'PlanetLab Europe' - peerurl = 'http://www.planet-lab.eu' - description += " %(peername)s "%locals() - #description += "[description]"%locals() - description += "" - if peer_id: - description += ""%locals() - else: - description += ""%locals() - description += "
Testbed" + description += "

"%locals() + description += " %(peername)s "%locals() + description += "

" - description += "Website" - description += "" + description += "
Website" description += " %(site_url)s "%locals() - description += "
Usage
 
Usage details:
 
" + description += "" + description += "" # NODES description += "" + description += "" #SLICES description += "" - - description += "" + description += "No slice" + description += "" + + # close usage table + description += "
" - description += ""%locals() + description += ""%locals() description += "" if nb_nodes: description += "%(nb_nodes)d node(s)"%locals() #description += " (in Comon)"%locals() else: description += "No node" - description += "
" - description += ""%locals() + description += ""%locals() description += "" if nb_slices: description += "%(nb_slices)d slice(s)"%locals() else: - description += "No slice" - description += "
 
" + description += "
" + description += "" if not self.options.labels: name="" description="" - # STYLE - if self.options.use_google_icons: - if not peer_id: - # local sites - iconfile=default_local_builtin - xyspec="12803232" - else: - # remote - iconfile=default_foreign_builtin - xyspec="16003232" - iconurl="root://icons/%(iconfile)s"%locals() - else: - if not peer_id: - iconfile=self.options.local_icon - else: - iconfile=self.options.foreign_icon - iconurl="%(baseurl)s/%(iconfile)s"%locals() - xyspec="" - - iconspec="%(iconurl)s%(xyspec)s"%locals() - # set the camera 50km high template=""" @@ -216,15 +219,16 @@ def main () : parser.add_option("-n","--no-label",action="store_false",dest="labels", default=True, help="outputs only geographic positions, no labels") - parser.add_option("-c","--custom",action="store_false",dest="use_google_icons", - default=True, - help="use locally customized icons rather than the google-provided defaults") + # default - for private depls. - is to use google-provided icons like palette-3 + parser.add_option("-c","--custom",action="store_true",dest="use_custom_icons", + default=False, + help="use locally customized icons rather than the %s and %s defaults"%(default_local_builtin,default_foreign_builtin)) parser.add_option("-l","--local",action="store",dest="local_icon", default=default_local_icon, - help="set icon url to use for local sites marker -- default is %s"%default_local_icon) + help="set icon url to use for local sites marker -- requires -c -- default is %s"%default_local_icon) parser.add_option("-f","--foreign",action="store",dest="foreign_icon", default=default_foreign_icon, - help="set icon url to use for foreign sites marker -- default is %s"%default_foreign_icon) + help="set icon url to use for foreign sites marker -- requires -c -- default is %s"%default_foreign_icon) (options, args) = parser.parse_args() if len(args) != 0: