def __init__(self, cfg): SystemLocalDB.__init__(self, cfg) ssl = cfg.phantom.system.rabbit_ssl self._rabbit = cfg.phantom.system.rabbit self._rabbit_port = cfg.phantom.system.rabbit_port self._rabbitpw = cfg.phantom.system.rabbit_pw self._rabbituser = cfg.phantom.system.rabbit_user self._rabbitexchange = cfg.phantom.system.rabbit_exchange log(logging.INFO, "Connecting to epu messaging fabric: %s, %s, XXXXX, %d, ssl=%s" % (self._rabbit, self._rabbituser, self._rabbit_port, str(ssl))) self._dashi_conn = DashiCeiConnection(self._rabbit, self._rabbituser, self._rabbitpw, exchange=self._rabbitexchange, timeout=60, port=self._rabbit_port, ssl=ssl) self._epum_client = EPUMClient(self._dashi_conn)
def get_autoscale_groups(self, user_obj, names=None, max=-1, startToken=None): self._clean_up_db() try: (asg_list_type, next_token) = SystemLocalDB.get_autoscale_groups(self, user_obj, names, max, startToken) epu_list = self._epum_client.list_domains() log(logging.DEBUG, "Incoming epu list is %s" %(str(epu_list))) # verify that the names are in thelist my_list = [] for grp in asg_list_type.type_list: if grp.AutoScalingGroupName not in epu_list: # perhaps all we should do here is log the error and remove the item from the DB # for now make it very obvious that this happened raise PhantomAWSException('InternalFailure', "%s is in the DB but the epu does not know about it" % (grp.AutoScalingGroupName)) epu_desc = self._epum_client.describe_domain(grp.AutoScalingGroupName) convert_epu_description_to_asg_out(epu_desc, grp) except Exception, ex: raise
def __init__(self, CFG): self._CFG = CFG self._logger = logging.getLogger("phantom") if self._CFG.phantom.authz.type == "simple_file": fname = self._CFG.phantom.authz.filename self._authz = SimpleFileDataStore(fname) elif self._CFG.phantom.authz.type == "cumulus": from pyhantom.authz.cumulus_sqlalch import CumulusDataStore dburl = self._CFG.phantom.authz.dburl self._authz = CumulusDataStore(dburl) elif self._CFG.phantom.authz.type == "sqldb": self._authz_sessionmaker = SimpleSQLSessionMaker(CFG.phantom.authz.dburl) else: raise PhantomAWSException('InternalFailure', details="Phantom authz module is not setup.") if self._CFG.phantom.system.type == "tester": self._system = TestSystem() elif self._CFG.phantom.system.type == "localdb": self._system = SystemLocalDB(self._CFG, log=self._logger) elif self._CFG.phantom.system.type == "epu_localdb": self._system = EPUSystemWithLocalDB(self._CFG) elif self._CFG.phantom.system.type == "epu": self._system = EPUSystem(self._CFG) else: raise PhantomAWSException('InternalFailure', details="Phantom authz module is not setup.") self.statsd_client = None try: if self._CFG.statsd is not None: host = self._CFG.statsd["host"] port = self._CFG.statsd["port"] self._logger.info("Setting up statsd client with host %s and port %d" % (host, port)) self.statsd_client = StatsClient(host, port) except AttributeError: # This means that there is not statsd block in the configuration pass except: self._logger.exception("Failed to set up statsd client")