Exemplo n.º 1
0
    def __init__(self):
        self._cfg = config.CiscoDFAConfig('nova').cfg
        self._tenant_name = self._cfg.keystone_authtoken.admin_tenant_name
        self._user_name = self._cfg.keystone_authtoken.admin_user
        self._admin_password = self._cfg.keystone_authtoken.admin_password
        self._timeout_respoonse = 10
        self._token = None
        self._project_id = None
        self._auth_url = None
        self._token_id = None
        self._token = None
        self._novaclnt = None
        self._url = self._cfg.keystone_authtoken.auth_uri
        if not self._url:
            proto = self._cfg.keystone_authtoken.auth_protocol
            auth_host = self._cfg.keystone_authtoken.auth_host
            auth_port = self._cfg.keystone_authtoken.auth_port
            self._url = '%(proto)s://%(host)s:%(port)s/v2.0' % (
                {'proto': proto if proto else 'http',
                 'host': auth_host if auth_host else 'localhost',
                 'port': auth_port if auth_port else '5000'})
        else:
            url_s = self._url.split('/')
            if len(url_s) == 4:
                url_s[-1] = 'v2.0'
                self._url = '/'.join(url_s)
            elif len(url_s) == 3:
                self._url += '/v2.0'
            else:
                LOG.error('Invalid auth_uri=%s value.', self._url)

        self._inst_info_cache = {}
        LOG.debug('DFAInstanceAPI: initialization done...')
Exemplo n.º 2
0
 def __init__(self):
     ''' Class init '''
     LOG.debug("Initializing Native Firewall")
     super(NativeFw, self).__init__()
     self.tenant_dict = {}
     self.os_helper = OsHelper()
     self.cfg = config.CiscoDFAConfig().cfg
     self.mgmt_ip_addr = None
     self.dcnm_obj = None
     self.que_obj = None
Exemplo n.º 3
0
 def initialize_app(self, argv):
     super(DFAShell, self).initialize_app(argv)
     cli = (sys.argv)[3:]
     sys.argv = sys.argv[:3]
     self.ctl_host = platform.node()
     self._cfg = config.CiscoDFAConfig().cfg
     url = self._cfg.dfa_rpc.transport_url % (
         {'ip': self.ctl_host})
     self.clnt = rpc.DfaRpcClient(url, constants.DFA_SERVER_QUEUE,
                                  exchange=constants.DFA_EXCHANGE)
     return self.clnt
Exemplo n.º 4
0
 def read_vdp_cfg(self):
     ''' Read VDP related configs '''
     self._cfg = config.CiscoDFAConfig().cfg
     self.vdp_opts = dict()
     self.vdp_opts['mgrid'] = self._cfg.vdp.mgrid2
     self.vdp_opts['typeid'] = self._cfg.vdp.typeid
     self.vdp_opts['typeidver'] = self._cfg.vdp.typeidver
     self.vdp_opts['vsiidfrmt'] = self._cfg.vdp.vsiidfrmt
     self.vdp_opts['hints'] = self._cfg.vdp.hints
     self.vdp_opts['filter'] = self._cfg.vdp.filter
     self.vdp_opts['vdp_sync_timeout'] = self._cfg.vdp.vdp_sync_timeout
Exemplo n.º 5
0
def main():

    # Setup logger
    cfg = config.CiscoDFAConfig().cfg
    logging.setup_logger('agent', cfg)

    # Get pid of the process and save it.
    save_my_pid(cfg)

    # Create DFA agent object
    dfa_agent = DfaAgent(thishost, constants.DFA_AGENT_QUEUE)

    LOG.debug('Starting tasks in agent...')
    try:
        # Start all task in the agent.
        dfa_agent.start_tasks()

        # Endless loop
        while True:
            start = time.time()

            # Send heartbeat to controller, data includes:
            # - timestamp
            # - host name
            dfa_agent.send_heartbeat()

            # If the agent comes up for the fist time (could be after crash),
            # ask for the uplink info.
            if dfa_agent._need_uplink_info or (
                    not dfa_agent.is_uplink_received()):
                dfa_agent.request_uplink_info()

            for trd in dfa_agent.agent_task_list:
                if not trd.am_i_active:
                    LOG.info("Thread %s is not active." % (trd.name))
                    # TODO should something be done?

            end = time.time()
            delta = end - start
            eventlet.sleep(constants.HB_INTERVAL - delta)
    except Exception as e:
        dfa_agent.stop_rpc()
        LOG.exception('Exception %s is received' % str(e))
        LOG.error('Exception %s is received' % str(e))
        sys.exit("ERROR: %s" % str(e))
Exemplo n.º 6
0
    def __init__(self, host, rpc_qn):
        self._cfg = config.CiscoDFAConfig('neutron').cfg

        self._host_name = host
        self._my_host = self._cfg.DEFAULT.host if self._cfg.DEFAULT.host else (
            utils.find_agent_host_id(host))
        self._qn = '_'.join((rpc_qn, self._my_host))
        LOG.debug('Starting DFA Agent on %s', self._my_host)

        # List of task in the agent
        self.agent_task_list = []

        # This flag indicates the agent started for the first time.
        self._need_uplink_info = True

        # Initialize iptables driver. This will be used to update the ip
        # rules in iptables, after launching an instance.

        if self._cfg.dcnm.dcnm_dhcp:
            self._iptd = iptd.IptablesDriver(self._cfg)
        else:
            self._iptd = None
            LOG.info("Using native dhcp, iptable driver is not needed")

        # Setup RPC client for sending heartbeat to controller
        self._url = self._cfg.dfa_rpc.transport_url
        self.setup_client_rpc()

        # Initialize VPD manager.
        # TODO read it from config.
        br_int = self._cfg.dfa_agent.integration_bridge
        br_ext = self._cfg.dfa_agent.external_dfa_bridge
        config_dict = {}
        config_dict['integration_bridge'] = br_int
        config_dict['external_bridge'] = br_ext
        config_dict['host_id'] = self._my_host
        config_dict['root_helper'] = self._cfg.sys.root_helper
        config_dict['node_list'] = self._cfg.general.node
        config_dict['node_uplink_list'] = self._cfg.general.node_uplink
        config_dict['ucs_fi_evb_dmac'] = self._cfg.general.ucs_fi_evb_dmac
        self._vdpm = vdpm.VdpMgr(config_dict, self.clnt, self._host_name)
        self.pool = eventlet.GreenPool()
        self.setup_rpc()
Exemplo n.º 7
0
    def __init__(self, ser_name, pqueue, c_pri, d_pri):
        self._service = None
        self._service_name = ser_name
        self._clients = {}
        self._pq = pqueue
        self._create_pri = c_pri
        self._update_pri = c_pri
        self._delete_pri = d_pri
        self._cfg = config.CiscoDFAConfig(ser_name).cfg
        self._q_agent = constants.DFA_AGENT_QUEUE
        self._url = self._cfg.dfa_rpc.transport_url
        self._events_to_ignore = constants.EVENTS_FILTER_LIST
        dfaq = self._cfg.dfa_notify.cisco_dfa_notify_queue % ({
            'service_name':
            ser_name
        })
        notify_queue = self._cfg.DEFAULT.notification_topics.split(',')
        self._notify_queue = dfaq if dfaq in notify_queue else None
        if self._service_name == 'keystone':
            endpoint = self._cfg.DEFAULT.admin_endpoint
            admin_port = self._cfg.DEFAULT.admin_port
            if endpoint:
                self._endpoint_url = (endpoint + 'v3/') % ({
                    'admin_port':
                    admin_port if admin_port else '35357'
                })
            else:
                host = self._cfg.DEFAULT.admin_bind_host
                proto = self._cfg.DEFAULT.auth_protocol
                self._endpoint_url = '%(proto)s://%(host)s:%(port)s/v3/' % (
                    {
                        'proto': proto if proto else 'http',
                        'host': host if host else 'localhost',
                        'port': admin_port if admin_port else '35357'
                    })
            self._service = client.Client(token=self._cfg.DEFAULT.admin_token,
                                          endpoint=self._endpoint_url)

        # Setup notification listener for the events.
        self._setup_notification_listener(self._notify_queue, self._url)
Exemplo n.º 8
0
 def __init__(self):
     ''' Initialization '''
     self.neutron_help = deh.EventsHandler('neutron', None, 20, 25)
     cfg = config.CiscoDFAConfig('neutron').cfg
     self.root_helper = cfg.sys.root_helper