def __init__(self, args=None, kube_api_connected=False, queue=None): self.args = args if 'kube_timer_interval' not in self.args: self.args.kube_timer_interval = '60' # randomize collector list self.args.random_collectors = args.collectors if self.args.collectors: self.args.random_collectors = random.sample( self.args.collectors, len(self.args.collectors)) self.logger = logger.KubeManagerLogger(args) if queue: self.q = queue else: self.q = Queue() # All monitors supported by this manager. self.monitors = {} self.kube = None while not kube_api_connected: try: self.kube = kube_monitor.KubeMonitor(args=self.args, logger=self.logger, q=self.q) self.monitors[ 'namespace'] = namespace_monitor.NamespaceMonitor( args=self.args, logger=self.logger, q=self.q) self.monitors['pod'] = pod_monitor.PodMonitor( args=self.args, logger=self.logger, q=self.q) self.monitors['service'] = service_monitor.ServiceMonitor( args=self.args, logger=self.logger, q=self.q) self.monitors['network_policy'] =\ network_policy_monitor.NetworkPolicyMonitor(args=self.args, logger=self.logger, q=self.q) self.monitors['endpoint'] = \ endpoint_monitor.EndPointMonitor(args=self.args, logger=self.logger, q=self.q) self.monitors['ingress'] = \ ingress_monitor.IngressMonitor(args=self.args, logger=self.logger, q=self.q) kube_api_connected = True except Exception as e: time.sleep(30) # Register all the known monitors. for monitor in self.monitors.values(): monitor.register_monitor() self.vnc = vnc_kubernetes.VncKubernetes(args=self.args, logger=self.logger, q=self.q, kube=self.kube)
def __init__(self, args=None): self.args = args self.logger = logger.KubeManagerLogger(args) self.q = Queue() self.vnc = vnc_kubernetes.VncKubernetes(args=self.args, logger=self.logger, q=self.q) kube_api_connected = False while not kube_api_connected: try: self.namespace = namespace_monitor.NamespaceMonitor( args=self.args, logger=self.logger, q=self.q) self.pod = pod_monitor.PodMonitor(args=self.args, logger=self.logger, q=self.q) self.service = service_monitor.ServiceMonitor( args=self.args, logger=self.logger, q=self.q) self.network_policy =\ network_policy_monitor.NetworkPolicyMonitor(args=self.args, logger=self.logger, q=self.q) self.endpoint = \ endpoint_monitor.EndPointMonitor( args=self.args, logger=self.logger, q=self.q) kube_api_connected = True except Exception as e: time.sleep(5)
def __init__(self, args=None, logger=None, kube_api_connected=False, queue=None, vnc_kubernetes_config_dict=None, is_master=True): self.q = queue if queue else Queue() self.args = args self.logger = logger self.is_master = is_master # All monitors supported by this manager. self.monitors = {} self.kube = None self.greenlets = [] while not kube_api_connected: try: self.kube = kube_monitor.KubeMonitor(args=self.args, logger=self.logger, q=self.q) self.monitors[ 'namespace'] = namespace_monitor.NamespaceMonitor( args=self.args, logger=self.logger, q=self.q) self.monitors['pod'] = pod_monitor.PodMonitor( args=self.args, logger=self.logger, q=self.q) self.monitors['service'] = service_monitor.ServiceMonitor( args=self.args, logger=self.logger, q=self.q) self.monitors['network_policy'] =\ network_policy_monitor.NetworkPolicyMonitor( args=self.args, logger=self.logger, q=self.q) self.monitors['endpoint'] = \ endpoint_monitor.EndPointMonitor( args=self.args, logger=self.logger, q=self.q) self.monitors['ingress'] = \ ingress_monitor.IngressMonitor( args=self.args, logger=self.logger, q=self.q) kube_api_connected = True except Exception: # FIXME: Except clause is too broad time.sleep(30) # Register all the known monitors. for monitor in self.monitors.values(): monitor.register_monitor() self.vnc = vnc_kubernetes.VncKubernetes( args=self.args, logger=self.logger, q=self.q, kube=self.kube, vnc_kubernetes_config_dict=vnc_kubernetes_config_dict)