Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 1 | # Ryu OpenFlow Controller |
| 2 | # ----------------------- |
| 3 | |
| 4 | # Save trace setting |
Dean Troyer | 8d55be3 | 2013-02-07 17:16:35 -0600 | [diff] [blame] | 5 | MY_XTRACE=$(set +o | grep xtrace) |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 6 | set +o xtrace |
| 7 | |
| 8 | |
| 9 | RYU_DIR=$DEST/ryu |
| 10 | # Ryu API Host |
| 11 | RYU_API_HOST=${RYU_API_HOST:-127.0.0.1} |
| 12 | # Ryu API Port |
| 13 | RYU_API_PORT=${RYU_API_PORT:-8080} |
| 14 | # Ryu OFP Host |
| 15 | RYU_OFP_HOST=${RYU_OFP_HOST:-127.0.0.1} |
| 16 | # Ryu OFP Port |
| 17 | RYU_OFP_PORT=${RYU_OFP_PORT:-6633} |
| 18 | # Ryu Applications |
| 19 | RYU_APPS=${RYU_APPS:-ryu.app.simple_isolation,ryu.app.rest} |
| 20 | |
Isaku Yamahata | 2cef6fb | 2013-02-12 23:05:40 +0900 | [diff] [blame] | 21 | # configure_ryu can be called multiple times as quantum_pluing/ryu may call |
| 22 | # this function for quantum-ryu-agent |
| 23 | _RYU_CONFIGURED=${_RYU_CONFIGURED:-False} |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 24 | function configure_ryu() { |
Isaku Yamahata | 2cef6fb | 2013-02-12 23:05:40 +0900 | [diff] [blame] | 25 | if [[ "$_RYU_CONFIGURED" == "False" ]]; then |
| 26 | setup_develop $RYU_DIR |
| 27 | _RYU_CONFIGURED=True |
| 28 | fi |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | function init_ryu() { |
| 32 | RYU_CONF_DIR=/etc/ryu |
| 33 | if [[ ! -d $RYU_CONF_DIR ]]; then |
| 34 | sudo mkdir -p $RYU_CONF_DIR |
| 35 | fi |
Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 36 | sudo chown $STACK_USER $RYU_CONF_DIR |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 37 | RYU_CONF=$RYU_CONF_DIR/ryu.conf |
| 38 | sudo rm -rf $RYU_CONF |
| 39 | |
Isaku Yamahata | 2cef6fb | 2013-02-12 23:05:40 +0900 | [diff] [blame] | 40 | # Ryu configuration |
| 41 | RYU_CONF_CONTENTS=${RYU_CONF_CONTENTS:-"[DEFAULT] |
| 42 | app_lists=$RYU_APPS |
| 43 | wsapi_host=$RYU_API_HOST |
| 44 | wsapi_port=$RYU_API_PORT |
| 45 | ofp_listen_host=$RYU_OFP_HOST |
| 46 | ofp_tcp_listen_port=$RYU_OFP_PORT |
| 47 | quantum_url=http://$Q_HOST:$Q_PORT |
| 48 | quantum_admin_username=$Q_ADMIN_USERNAME |
| 49 | quantum_admin_password=$SERVICE_PASSWORD |
| 50 | quantum_admin_tenant_name=$SERVICE_TENANT_NAME |
| 51 | quantum_admin_auth_url=$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0 |
| 52 | quantum_auth_strategy=$Q_AUTH_STRATEGY |
| 53 | quantum_controller_addr=tcp:$RYU_OFP_HOST:$RYU_OFP_PORT |
| 54 | "} |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 55 | echo "${RYU_CONF_CONTENTS}" > $RYU_CONF |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 56 | } |
| 57 | |
Isaku Yamahata | 429b39d | 2013-01-09 18:35:55 +0900 | [diff] [blame] | 58 | # install_ryu can be called multiple times as quantum_pluing/ryu may call |
| 59 | # this function for quantum-ryu-agent |
| 60 | # Make this function idempotent and avoid cloning same repo many times |
| 61 | # with RECLONE=yes |
| 62 | _RYU_INSTALLED=${_RYU_INSTALLED:-False} |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 63 | function install_ryu() { |
Isaku Yamahata | 429b39d | 2013-01-09 18:35:55 +0900 | [diff] [blame] | 64 | if [[ "$_RYU_INSTALLED" == "False" ]]; then |
| 65 | git_clone $RYU_REPO $RYU_DIR $RYU_BRANCH |
| 66 | _RYU_INSTALLED=True |
| 67 | fi |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 68 | } |
| 69 | |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 70 | function start_ryu() { |
Isaku Yamahata | 2cef6fb | 2013-02-12 23:05:40 +0900 | [diff] [blame] | 71 | screen_it ryu "cd $RYU_DIR && $RYU_DIR/bin/ryu-manager --config-file $RYU_CONF" |
Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | function stop_ryu() { |
| 75 | : |
| 76 | } |
| 77 | |
| 78 | # Restore xtrace |
Dean Troyer | 8d55be3 | 2013-02-07 17:16:35 -0600 | [diff] [blame] | 79 | $MY_XTRACE |