Example #1
0
def del_router(context, router_id):
    # kill vm and delete router
    router = tn_db.query_record(context, tn_db.Tn_Router, id=router_id)
    if router is not None:
        tn_drv.destroy_vm(router_id, router.image_name)
        tn_db.delete_record(context, tn_db.Tn_Router, id=router_id)
        del TNOS_CLIENT[router_id]
Example #2
0
def del_static_route(context, router_id, dest, prefix, next_hop):
    api_client = get_tn_client(context, router_id)
    try:
        api_client.request(templates.DEL_STATIC_ROUTE, dest=dest, netmask=prefix, gw_ip=next_hop)
    except Exception:
        raise
    else:
        tn_db.delete_record(context, tn_db.Tn_Static_Route,
                            router_id=router_id, dest=dest, prefix=prefix, next_hop=next_hop)
Example #3
0
def del_intf(context, router_id, intf_id):
    intf = tn_db.query_record(context, tn_db.Tn_Interface, id=intf_id)

    if intf is not None:
        api_client = get_tn_client(context, router_id)

        if intf.is_gw == 'True':
            ovsctl.del_port(context, INT_BRIDGE_NAME, intf.extern_name)
        else:
            api_client.request(templates.DEL_SUB_INTF, intf_name=intf.inner_name, id=intf.inner_id)
            ovsctl.del_trunk_port_tag(context, intf.extern_name, intf.vlan_id)

            count = tn_db.query_count(context, tn_db.Tn_Interface, router_id=router_id, is_gw='False')
            if count == 1:
                # the last one
                ovsctl.del_port(context, INT_BRIDGE_NAME, intf.extern_name)

        tn_db.delete_record(context, tn_db.Tn_Interface, id=intf.id)

        # todo xiongjun: patch, fix bug: namespace interface will be up when add interface
        shutdown_old_intf(context, router_id)
Example #4
0
 def delete(context, rule_id):
     tn_db.delete_record(context, tn_db.Tn_Service, rule_id=rule_id)
Example #5
0
 def delete(context, rule_id, name):
     tn_db.delete_record(context, tn_db.Tn_Address, rule_id=rule_id, name=name)
Example #6
0
 def delete(context, fw):
     TNFirewall.del_policy(context, fw)
     tn_db.delete_record(context, tn_db.Tn_Firewall, id=fw.id)
Example #7
0
    def delete(context, policy):
        rules = TNRule.gets(context, policy_id=policy.id)
        for rule in rules:
            TNPolicy.del_rule(context, policy, rule)

        tn_db.delete_record(context, tn_db.Tn_Policy, id=policy.id)
Example #8
0
 def delete(context, rule):
     TNL3Address.delete(context, rule.id, rule.srcaddr)
     TNL3Address.delete(context, rule.id, rule.dstaddr)
     TNService.delete(context, rule.id)
     tn_db.delete_record(context, tn_db.Tn_Rule, id=rule.id)
Example #9
0
 def delete(context, snat_rule):
     TNL3Address.delete(context, snat_rule.router_id, snat_rule.srcaddr_name)
     TNL3Address.delete(context, snat_rule.router_id, snat_rule.dstaddr_name)
     TNL3Address.delete(context, snat_rule.router_id, snat_rule.trans_addr_name)
     tn_db.delete_record(context, tn_db.Tn_Snat_rule, router_id=snat_rule.router_id, inner_id=snat_rule.inner_id)