1########################################################################## 2# Copyright (c) 2009, 2013, ETH Zurich. 3# All rights reserved. 4# 5# This file is distributed under the terms in the attached LICENSE file. 6# If you do not find this file, copies can be found by writing to: 7# ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8########################################################################## 9 10import socket, os 11import debug 12 13class BaseSite(object): 14 def __getattr__(self, name): 15 raise AttributeError('site configuration (%s) has no parameter named %s' 16 % (self.__name__, name)) 17 18 def get_load_generator(self): 19 """Returns a (username, hostname/IP) tuple for a host to which we can 20 SSH to run network load generators. May be called multiple times.""" 21 raise NotImplementedError 22 23# this refers to the singleton site instance after importing the correct module 24site = None 25 26# Are we at ETH? 27if os.path.isdir('/home/netos') and socket.getfqdn().endswith('.ethz.ch'): 28 import eth 29elif socket.getfqdn().endswith('.europe.corp.microsoft.com'): 30 import msrc 31elif socket.getfqdn().endswith('triangle') or socket.getfqdn().endswith('.cs.washington.edu'): 32 import uw 33else: 34 debug.warning("unable to guess site, using ETH... expect breakage!") 35 import eth 36 37# shortcut to lookup a configuration parameter for a site 38def get(name): 39 return getattr(site, name) 40