Пример #1
0
 def _should_touch(self):
     if not get_extra()['options'].has_key('ONDEMAND'):
         return True
     if self.chassis == get_extra()['system_id']:
         return True
     if self.peer is not None:
         return True
     return False
Пример #2
0
def insert_ovs_ipfix(br = 'br-int'):
    try:
        ovs_vsctl('clear', 'bridge', br, 'ipfix')

        options = get_extra()['options']
        if 'IPFIX_CFG' in options:
            cfg = options['IPFIX_CFG']
            logger.debug('add ipfix record {}'.format(cfg))

            ovs_vsctl('--', 'set', 'Bridge', br, 'ipfix=@i', '--', '--id=@i', \
                      'create', 'IPFIX', 'targets=\"{}\"'.format(cfg['collector']), \
                      'obs_domain_id={}'.format(cfg['domain_id']), \
                      'obs_point_id={}'.format(cfg['point_id']), \
                      'sampling={}'.format(cfg['sampling_rate']), \
                      'other_config:enable-tunnel-sampling=flase')
    except Exception as e:
        logger.error('failed to alter ipfix record for %s: %s', br, e)
        raise OVSToolErr('failed to alter ipfix record: ' + str(e))
Пример #3
0
    def add_entity(self, entity_type, *properties):
        entity_class = LogicalEntityZoo.logical_entity_types.get(entity_type)
        if entity_class is None:
            logger.warning('unknow entity_type %s', entity_type)
            return

        entity_id = properties[0]
        entity_group = self.entity_set[entity_type]
        with self.lock:
            if entity_group.has_key(entity_id) and \
               entity_group[entity_id].is_same(*properties):
                logger.info(
                    'entity_set[%s] has same property entity '
                    'exist entity:%s, conflict entity:%s', entity_type,
                    entity_group[entity_id], properties)
                return
            try:
                e = entity_class(*properties)
            except Exception as err:
                logger.exception(
                    "hit error in adding entity %s, "
                    "property:%s, err:%s", entity_type, properties, err)
                return
        e = self._add_entity_in_zoo(entity_type, e)
        if e is None:
            return None
        e.populate()

        # a chassis which a LR pin on should be touch to generate
        # tunnel. This tunnel was use to redirect traffic.
        if not get_extra()['options'].has_key('ONDEMAND'):
            return
        # a LR pin on a remote chassis means this chassis s a
        # gateway or agent. The tunnel should be generated immediately.
        if entity_type == LOGICAL_ENTITY_TYPE_LR:
            self._touch_gateway_by_LR(e)
        if entity_type == LOGICAL_ENTITY_TYPE_CHASSIS:
            self._touch_gateway_by_chassis(e)
Пример #4
0
 def _should_touch(self):
     if not get_extra()['options'].has_key('ONDEMAND'):
         return True
     if self.uuid == get_extra()['system_id']:
         return True
     return False
Пример #5
0
import logicalview as lgview
import lflow
import ecmp
import action as ovsaction
import match as ovsmatch
import time
from pyDatalog import pyDatalog
from tp_utils.run_env import is_gateway_chassis, get_extra
import tunnel

logger = logging.getLogger(__name__)
prev_zoo_ver = 0 # it should be 0 which same as entity_zoo's zoo_ver
had_clean_tunnel_ports = False
had_clean_ovs_flows = False
# NOTE: DO NOT revise the filename
MAC_IP_BIND_FILE = os.path.join(get_extra()['options']['TUPLENET_RUNDIR'],
                                'mac_ip_bind.data')
pyDatalog.create_terms('Table, Priority, Match, Action, State')
pyDatalog.create_terms('PORT_NAME, IP, UUID_CHASSIS')

def update_lsp_chassis(entity_set, system_id):
    lsp_chassis_changed = []
    lsp_portset = entity_set['lsp']
    ovsport_set = entity_set['ovsport']
    for _, ovsport in ovsport_set.items():
        key = ovsport.iface_id
        if lsp_portset.has_key(key) and \
           lsp_portset[key].chassis != system_id:
               lsp_chassis_changed.append(lsp_portset[key])
               logger.info('should update lsp %s chassis %s', key, system_id)
    return lsp_chassis_changed
Пример #6
0
def init_entity_clause(options):

    local_bond_lsp(LSP_WITH_OFPORT, LS, State) <= (
        ovsport(PORT_NAME, UUID_LSP, OFPORT, State1) &
        (OFPORT > 0) &
        ls_array(LS, UUID_LS, State2) &
        lsp_array(UUID_LSP, LSP, UUID_LS, UUID_CHASSIS, UUID_LRP, State3) &
        local_system_id(UUID_CHASSIS) &
        (LSP_WITH_OFPORT == (LSP + [OFPORT])) &
        (State == State1 + State2 + State3)
        )

    local_lsp(LSP, LS, State) <= (
        (UUID_LR_CHASSIS == None) &
        lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State)
        )
    local_lsp(LSP, LS, State) <= (
        local_system_id(UUID_LR_CHASSIS) &
        lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State)
        )
    local_lsp(LSP, LS, State) <= (local_bond_lsp(LSP, LS, State))

    active_lsp(LSP, LS, UUID_LS, State) <= (
        ls_array(LS, UUID_LS, State1) &
        lsp_array(UUID_LSP, LSP, UUID_LS, UUID_CHASSIS, UUID_LRP, State2) &
        chassis_array(PHY_CHASSIS, UUID_CHASSIS, State3) &
        (State == State1 + State2 + State3)
        )
    active_lsp(LSP, LS, UUID_LS, State) <= (
        lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State))

    remote_chassis(UUID_CHASSIS, PHY_CHASSIS_WITH_OFPORT, State) <= (
        ovsport_chassis(PORT_NAME, UUID_CHASSIS, OFPORT, State1) &
        (OFPORT > 0) &
        chassis_array(PHY_CHASSIS, UUID_CHASSIS, State2) &
        (PHY_CHASSIS_WITH_OFPORT == PHY_CHASSIS + [OFPORT]) &
        (State == State1 + State2)
        )

    local_chassis(PHY_CHASSIS, State) <= (
        local_system_id(UUID_CHASSIS) &
        chassis_array(PHY_CHASSIS, UUID_CHASSIS, State)
        )

    remote_lsp(LSP, LS, PHY_CHASSIS, State) <= (
        remote_chassis(UUID_CHASSIS, PHY_CHASSIS, State1) &
        lsp_array(UUID_LSP, LSP, UUID_LS, UUID_CHASSIS, UUID_LRP, State2) &
        ls_array(LS, UUID_LS, State3) &
        (State == State1 + State2 + State3)
        )

    remote_lsp(LSP, LS, PHY_CHASSIS, State) <= (
        lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State1) &
        remote_chassis(UUID_LR_CHASSIS, PHY_CHASSIS, State2) &
        (State == State1 + State2)
        )


    lsp_link_lrp(LSP, LS, UUID_LS, LRP, LR, UUID_LR, UUID_LR_CHASSIS, State) <= (
        lrp_array(UUID_LRP, LRP, UUID_LR, UUID_LSP, State1) &
        exchange_lsp_array(UUID_LSP, LSP, UUID_LS, UUID_CHASSIS, UUID_LRP, State2) &
        ls_array(LS, UUID_LS, State3) &
        lr_array(LR, UUID_LR, State4) &
        (UUID_LR_CHASSIS == LR[LR_CHASSIS_UUID]) &
        (State == State1 + State2 + State3 +State4)
        )

    next_hop_ovsport(UUID_LRP, OFPORT, State) <= (
        lrp_array(UUID_LRP, LRP, UUID_LR, UUID_LSP, State1) &
        exchange_lsp_array(UUID_LSP1, LSP1, UUID_LS, UUID_CHASSIS1, UUID_LRP, State2) &
        exchange_lsp_array(UUID_LSP2, LSP2, UUID_LS, UUID_CHASSIS2, UUID_LRP2, State3) &
        lrp_array(UUID_LRP2, LRP2, UUID_LR2, UUID_LSP2, State4) & (UUID_LR != UUID_LR2) &
        lr_array(LR2, UUID_LR2, State5) &
        ovsport_chassis(PORT_NAME, LR2[LR_CHASSIS_UUID], OFPORT, State6) & (OFPORT > 0) &
        (State == State1 + State2 + State3 + State4 + State5 + State6)
        )

    if not get_extra()['options'].has_key('ENABLE_PERFORMANCE_TESTING'):
        lnat_data(LNAT, LR, XLATE_TYPE, UUID_LR, State) <= (
            lr_array(LR, UUID_LR, State1) &
            # TODO local_system_id, UUID_CHASSIS here introduce
            # performance regression
            (UUID_CHASSIS == LR[LR_CHASSIS_UUID]) &
            local_system_id(UUID_CHASSIS) &
            lnat_array(LNAT, UUID_LR, XLATE_TYPE, State2) &
            (State == State1 + State2)
        )
    else:
        lnat_data(LNAT, LR, XLATE_TYPE, UUID_LR, State) <= (
            lr_array(LR, UUID_LR, State1) &
            lnat_array(LNAT, UUID_LR, XLATE_TYPE, State2) &
            (State == State1 + State2)
        )
Пример #7
0
 def _is_update_clause(self):
     if not get_extra()['options'].has_key('ONDEMAND'):
         return True
     if self.uuid == get_extra()['system_id']:
         return True
     return self.touched
Пример #8
0
                                              random.randint(1, 254)),
            int(time.time()))
        chassis_set[chassis_id] = ch
        populate_all()
        start_time = time.time()
        tunnel.tunnel_port_oper(A, B, C)
        tmp = A.data
        tmp = B.data
        tmp = C.data
        logger.info('tunnel_port_oper cost time:%s, num:%d',
                    time.time() - start_time, len(tmp))
        start_time = time.time()
        active_lsp(A, B, C, State)
        tmp = A.data
        logger.info('active_lsp cost time:%s', time.time() - start_time)

        logger.info('\n\n')


extra = get_extra()
extra['system_id'] = 'chassis-local'
extra['options'] = {}
extra['options']['ENABLE_REDIRECT'] = ''
extra['options']['ENABLE_PERFORMANCE_TESTING'] = ''
extra['options']['ONDEMAND'] = ''
extra['options']['ENABLE_UNTUNNEL'] = ''
extra['options']['br-int_mac'] = '00:00:00:11:11:11'
entity_set = entity_zoo.entity_set
lflow.init_build_flows_clause(extra['options'])
test_rand_entity(entity_set, 20, 500, 5000)
Пример #9
0
from pyDatalog import pyDatalog
from tp_utils import run_env
hash_fn = run_env.get_extra()['options']['HASH_FN']

Action_output = 1
Action_output_reg = 2
Action_output_max_len = 3
Action_output_group = 4
Action_normal = 5
Action_flood = 6
Action_all = 7
Action_local = 8
Action_output_inport = 9

Action_enqueue = 20
Action_drop = 21

Action_mod_vlan_vid = 31
Acton_mod_vlan_pcp = 32
Action_strip_vlan = 33
Action_push_vlan = 34
Action_push_mpls = 35
Action_pop_mpls = 36

Action_mod_dl_src = 40
Action_mod_dl_dst = 41
Action_mod_nw_src = 42
Action_mod_nw_dst = 43
Action_mod_nw_tos = 44
Action_mod_nw_ecn = 45
Action_mod_nw_ttl = 46
Пример #10
0
sys.path = [parent_dir, ppparent_dir, py_third_dir] + sys.path
import lflow
import commit_ovs as cm
import logicalview as lgview
import state_update
import tentacle
import tuplesync
import link_master as lm
from optparse import OptionParser
from pyDatalog import pyDatalog
from tp_utils import run_env, pipe
import syscmd
import version

logger = None
extra = run_env.get_extra()
entity_zoo = lgview.get_zoo()


def handle_exit_signal(signum, frame):
    logger.info('receive signum:%s', signum)
    try:
        clean_env(extra, 0)
    except Exception as err:
        logger.warning("error in clearning environment, err:%s", err)
    logger.info('Exit tuplenet')
    sys.exit(0)


def killme():
    os.kill(os.getpid(), signal.SIGTERM)