File: dr

package info (click to toggle)
neutron-dynamic-routing 2%3A13.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,052 kB
  • sloc: python: 7,315; sh: 207; makefile: 34
file content (111 lines) | stat: -rw-r--r-- 3,233 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
function is_protocol_enabled {
    local enabled=1
    local protocol=$1
    for temp in $DR_SUPPORTED_PROTOCOLS ;do
        if [ $protocol == $temp ] ; then
            enabled=0
        fi
    done

    return $enabled
}


##############################
#   BGP Section              #
##############################

function configure_dr_agent_bgp_config {
    cp $NEUTRON_DYNAMIC_ROUTING_DIR/etc/bgp_dragent.ini.sample $DR_AGENT_BGP_CONF_FILE
    iniset $DR_AGENT_BGP_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
    iniset $DR_AGENT_BGP_CONF_FILE bgp bgp_router_id $BGP_ROUTER_ID
}

function configure_dr_agent_bgp_driver {
    if [ -z "$BGP_SPEAKER_DRIVER" ] ; then
        BGP_SPEAKER_DRIVER=$RYU_BGP_SPEAKER_DRIVER
    fi
    iniset $DR_AGENT_BGP_CONF_FILE bgp bgp_speaker_driver $BGP_SPEAKER_DRIVER
}

function configure_dr_agent_scheduler_driver {
    if [ -n "$BGP_SCHEDULER_DRIVER" ] ; then
        iniset $NEUTRON_CONF DEFAULT bgp_drscheduler_driver $BGP_SCHEDULER_DRIVER
    fi
}

#############################
# Stack Install Section     #
#############################

#This API will be called for phase "install"

function dr_install {
    setup_develop $NEUTRON_DYNAMIC_ROUTING_DIR
    if is_service_enabled q-dr neutron-dr && is_service_enabled q-svc neutron-api; then
        sudo install -d -o $STACK_USER $NEUTRON_CONF_DIR/policy.d
        cp -v $NEUTRON_DYNAMIC_ROUTING_DIR/etc/neutron/policy.d/dynamic_routing.conf $NEUTRON_CONF_DIR/policy.d
    fi
}

#############################
# Stack Post-config Section #
#############################

#This API will be called for phase "post-config"
function dr_generate_config_files {
    (cd $NEUTRON_DYNAMIC_ROUTING_DIR && exec ./tools/generate_config_file_samples.sh)
}

function dr_post_configure {
    if is_service_enabled q-dr neutron-dr && is_service_enabled q-svc neutron-api; then
        if is_protocol_enabled BGP; then
            neutron_service_plugin_class_add $BGP_PLUGIN
        fi
    fi
    if is_service_enabled q-dr-agent neutron-dr-agent; then
        dr_generate_config_files
        if is_protocol_enabled BGP; then
            configure_dr_agent_bgp_config
            configure_dr_agent_bgp_driver
            configure_dr_agent_scheduler_driver
        fi
    fi
}

#############################
# Stack Extra Section       #
#############################

#This API will be called for phase "extra"
function start_dr_agent {
    local process="$DR_AGENT_BINARY --config-file $NEUTRON_CONF "
    local bgp_parameter
    if is_protocol_enabled BGP; then
        bgp_parameter="--config-file $DR_AGENT_BGP_CONF_FILE"
    fi

    agent_process=$process$bgp_parameter
    if is_neutron_legacy_enabled; then
        if is_service_enabled q-dr-agent; then
            run_process q-dr-agent "$agent_process"
        fi
    else
        if is_service_enabled neutron-dr-agent; then
            run_process neutron-dr-agent "$agent_process"
        fi
    fi
}

#############################
# Unstack Section           #
#############################

#This API will be called for unstack
function stop_dr_agent {
    if is_neutron_legacy_enabled; then
        stop_process q-dr-agent
    else
        stop_process neutron-dr-agent
    fi
}