diff options
author | chenshuai@huawei.com <chenshuai@huawei.com> | 2016-01-18 10:05:58 +0800 |
---|---|---|
committer | shuai chen <chenshuai@huawei.com> | 2016-01-21 14:49:30 +0000 |
commit | d81783305d2837eb2d76f8f3098bd06f2b58a5d2 (patch) | |
tree | fec57a0b7b505066229eb2aca706b0eb36929cd6 | |
parent | 9e1a57ca0b97e49813ae6c19dab7e12c21721717 (diff) |
bugfix: opencontrail automation deployment scripts
JIRA: COMPASS-277
Change-Id: Ia1f52c6e8e3de520cf06de99550c17879aaed2d7
Signed-off-by: chenshuai@huawei.com <chenshuai@huawei.com>
(cherry picked from commit 77944ac2791a631cfa785d16cc32dae8082b2719)
21 files changed, 393 insertions, 112 deletions
diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/install/install-config.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/install/install-config.yml index 17163fca..f2940215 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/install/install-config.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/install/install-config.yml @@ -19,20 +19,20 @@ ############################################### ################ workaround ################# ############################################### -#- name: "backup keepalived conf" -# shell: mv /etc/keepalived/keepalived.conf /home/keepalived.conf +- name: "backup keepalived conf" + shell: mv /etc/keepalived/keepalived.conf /home/keepalived.conf -#- name: "uninstall keepalived" -# action: "{{ ansible_pkg_mgr }} name=keepalived state=absent" +- name: "uninstall keepalived" + action: "{{ ansible_pkg_mgr }} name=keepalived state=absent" -#- name: "install iproute" -# action: "{{ ansible_pkg_mgr }} name=iproute state=present" +- name: "install iproute" + action: "{{ ansible_pkg_mgr }} name=iproute state=present" -#- name: "install iproute" -# action: "{{ ansible_pkg_mgr }} name=keepalived state=present" +- name: "install iproute" + action: "{{ ansible_pkg_mgr }} name=keepalived state=present" -#- name: "restore keepalived conf" -# shell: mv /home/keepalived.conf /etc/keepalived/keepalived.conf +- name: "restore keepalived conf" + shell: mv /home/keepalived.conf /etc/keepalived/keepalived.conf ############################################### - name: "install contrail openstack config package" diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/install/install-interface.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/install/install-interface.yml index 4f21d50a..bf313e52 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/install/install-interface.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/install/install-interface.yml @@ -2,20 +2,24 @@ #- hosts: all # sudo: yes # tasks: -- name: "configure interface" -# sudo: True - lineinfile: - dest: "/etc/network/interfaces" - line: "{{ item }}" - with_items: - - "auto {{ contrail_vhost_device }}" - - "iface {{ contrail_vhost_device }} inet static" - - "\taddress {{ contrail_vhost_address }}" - - "\tnetmask {{ contrail_vhost_netmask }}" +- name: get last ip address + shell: expr substr `cat /etc/hostname` 5 1 + register: lastip + +#- name: "configure interface" +## sudo: True +# lineinfile: +# dest: "/etc/network/interfaces" +# line: "{{ item }}" +# with_items: +# - "auto {{ contrail_vhost_device }}" +# - "iface {{ contrail_vhost_device }} inet static" +# - "\taddress {{ contrail_vhost_address }}{{ lastip.stdout_lines[0] }}" +# - "\tnetmask {{ contrail_vhost_netmask }}" - name: "set interface address" # sudo: True - shell: "ifconfig {{ contrail_vhost_device }} {{ contrail_vhost_address }} netmask {{ contrail_vhost_netmask }}" + shell: "ifconfig {{ contrail_vhost_device }} {{ contrail_vhost_address }}{{ lastip.stdout_lines[0] }} netmask {{ contrail_vhost_netmask }}" - name: "up interface" # sudo: True diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/main.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/main.yml index 2544b0ff..d7b9ceb3 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/main.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/main.yml @@ -2,14 +2,16 @@ - include_vars: "{{ ansible_os_family }}.yml" +- name: backup rabbitmq-server + shell: cp /etc/init.d/rabbitmq-server /home/rabbitmq-server + when: inventory_hostname in groups['controller'] + - name: Disable Service Daemon - template: - src: "/opt/service" - dest: "/opt/service.backup" + shell: if [ -f “\/opt\/service” ] ; then mv /opt/service /opt/service.bak ; fi - name: Install common on all hosts for Open Contrail include: install/install-common.yml - when: groups['opencontrail_control']|length !=0 + when: groups['controller']|length !=0 # Compass install OpenStack with not only OpenContrail but also ODL or ONOS, and sometimes user just installs OpenStack, so item 'opencontrail_control' is kind of a mark that whether Compass install OpenContrail or not. #- name: Install kernal on all hosts for Open Contrail @@ -18,33 +20,33 @@ - name: Install database for Open Contrail include: install/install-database.yml - when: inventory_hostname in groups['opencontrail_database'] + when: inventory_hostname in groups['controller'] - name: Install config for Open Contrail include: install/install-config.yml - when: inventory_hostname in groups['opencontrail_config'] + when: inventory_hostname in groups['controller'] - name: Install config for Open Contrail include: install/install-control.yml - when: inventory_hostname in groups['opencontrail_control'] + when: inventory_hostname in groups['controller'] - name: Install collector for Open Contrail include: install/install-collector.yml - when: inventory_hostname in groups['opencontrail_collector'] + when: inventory_hostname in groups['controller'] - name: Install webui for Open Contrail include: install/install-webui.yml - when: inventory_hostname in groups['opencontrail_webui'] + when: inventory_hostname in groups['controller'] - name: Install compute for Open Contrail include: install/install-compute.yml - when: inventory_hostname in groups['opencontrail_compute'] + when: inventory_hostname in groups['compute'] # or inventory_hostname in groups['opencontrail_tsn'] - name: Install interface on all hosts for Open Contrail include: install/install-interface.yml - when: groups['opencontrail_control']|length !=0 + when: groups['controller']|length !=0 #- include: install/install-common.yml #- include: install/install-kernel.yml @@ -65,47 +67,45 @@ - name: Provision increase limits for Open Contrail include: provision/provision-increase-limits.yml - when: inventory_hostname in groups['opencontrail_control'] + when: inventory_hostname in groups['controller'] #or inventory_hostname in groups['opencontrail_config'] or inventory_hostname in groups['opencontrail_collector'] or inventory_hostname in groups['opencontrail_database'] - name: Provision database for Open Contrail include: provision/provision-database.yml - when: inventory_hostname in groups['opencontrail_database'] + when: inventory_hostname in groups['controller'] - name: Provision config for Open Contrail include: provision/provision-config.yml - when: inventory_hostname in groups['opencontrail_config'] + when: inventory_hostname in groups['controller'] - name: Provision control for Open Contrail include: provision/provision-control.yml - when: inventory_hostname in groups['opencontrail_control'] + when: inventory_hostname in groups['controller'] - name: Provision collector for Open Contrail include: provision/provision-collector.yml - when: inventory_hostname in groups['opencontrail_collector'] + when: inventory_hostname in groups['controller'] - name: Provision add nodes for Open Contrail include: provision/provision-add-nodes.yml - when: groups['opencontrail_control']|length !=0 + when: inventory_hostname in groups['controller'] - name: Provision webui for Open Contrail include: provision/provision-webui.yml - when: inventory_hostname in groups['opencontrail_webui'] + when: inventory_hostname in groups['controller'] - name: Provision compute for Open Contrail include: provision/provision-compute.yml - when: inventory_hostname in groups['opencontrail_compute'] + when: inventory_hostname in groups['compute'] - name: Enable Service Daemon - template: - src: "/opt/service.backup" - dest: "/opt/service" + shell: if [ -f “\/opt\/service.bak” ] ; then mv /opt/service.bak /opt/service ; fi #- name: Provision tsn for Open Contrail # include: provision/provision-tsn.yml diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/.provision-compute.yml.swp b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/.provision-compute.yml.swp Binary files differdeleted file mode 100644 index 41980448..00000000 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/.provision-compute.yml.swp +++ /dev/null diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml index a9f34ed6..f1706700 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml @@ -4,23 +4,45 @@ # tasks: - name: "recover rabbitmq-server service script" - shell: if [ ! -f "\/etc\/init.d\/rabbitmq-server.initd.supervisord" ] ; then mv /etc/init.d/rabbitmq-server.initd.supervisord /home/rabbitmq-server.initd.supervisord; mv /etc/init.d/rabbitmq-server /home/rabbit-server; mv /etc/init.d/rabbitmq-server.backup /etc/init.d/rabbitmq-server; fi + shell: cp /home/rabbitmq-server /etc/init.d/rabbitmq-server - name: "restart rabbitmq-server" service: name: "rabbitmq-server" - state: "restarted" + state: "restarted" + +- name: "wait rabbitmq-server start" + shell: sleep 5 + +- name: "restart contrail-discovery" + service: + name: "contrail-discovery" + state: "restarted" + +- name: "wait contrail-discovery" + shell: sleep 5 + +- name: "restart contrail-api" + service: + name: "contrail-api" + state: "restarted" + +- name: "check contrail-api" + shell: lsof -ni :8082 ; while [ $? -ne 0 ]; do sleep 10; lsof -ni :8082; done; sleep 20; + +- name: "wait contrail-api" + shell: sleep 20 - name: "provision config node" shell: "python /opt/contrail/utils/provision_config_node.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --oper add --host_name {{ ansible_hostname }} --host_ip {{ contrail_address }}" - when: inventory_hostname in groups['opencontrail_config'] +# when: inventory_hostname in groups['opencontrail_config'] #- hosts: database # sudo: yes # tasks: - name: "provision database node" shell: "python /opt/contrail/utils/provision_database_node.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --oper add --host_name {{ ansible_hostname }} --host_ip {{ contrail_address }}" - when: inventory_hostname in groups['opencontrail_database'] +# when: inventory_hostname in groups['opencontrail_database'] #- hosts: collector @@ -28,14 +50,14 @@ # tasks: - name: "provision collector node" shell: "python /opt/contrail/utils/provision_analytics_node.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --oper add --host_name {{ ansible_hostname }} --host_ip {{ contrail_address }}" - when: inventory_hostname in groups['opencontrail_collector'] +# when: inventory_hostname in groups['opencontrail_collector'] #- hosts: control # sudo: yes # tasks: - name: "provision control node" shell: "python /opt/contrail/utils/provision_control.py --api_server_ip {{ contrail_haproxy_address }} --api_server_port 8082 --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --oper add --host_name {{ ansible_hostname }} --host_ip {{ contrail_address }} --router_asn {{ contrail_router_asn }}" - when: inventory_hostname in groups['opencontrail_control'] +# when: inventory_hostname in groups['opencontrail_control'] #- hosts: config # sudo: yes @@ -43,7 +65,7 @@ - name: "provision metadata services" shell: "python /opt/contrail/utils/provision_linklocal.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --oper add --ipfabric_service_ip 10.84.50.1 --ipfabric_service_port 8775 --linklocal_service_name metadata --linklocal_service_ip 169.254.169.254 --linklocal_service_port 80" run_once: yes - when: inventory_hostname in groups['opencontrail_config'] +# when: inventory_hostname in groups['opencontrail_config'] #- hosts: config @@ -52,5 +74,5 @@ - name: "provision encap" shell: "python /opt/contrail/utils/provision_encap.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --oper add --encap_priority MPLSoUDP,MPLSoGRE,VXLAN" run_once: yes - when: inventory_hostname in groups['opencontrail_config'] +# when: inventory_hostname in groups['opencontrail_config'] diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-compute.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-compute.yml index c8db15b6..30d836d9 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-compute.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-compute.yml @@ -77,6 +77,10 @@ - "sed -i -n -e '/auto .*/,$p' /tmp/contrail-interfaces-bottom" - "cat /tmp/contrail-interfaces-top /tmp/contrail-interfaces-bottom > /etc/network/interfaces" +- name: get last ip address + shell: expr substr `cat /etc/hostname` 5 1 + register: lastip + - name: "configure interface" lineinfile: dest: "/etc/network/interfaces" @@ -91,14 +95,25 @@ - "iface vhost0 inet static" - "\tpre-up /opt/contrail/bin/if-vhost0" - "\tnetwork_name application" - - "\taddress {{ contrail_vhost_address }}" + - "\taddress {{ contrail_vhost_address }}{{ lastip.stdout_lines[0] }}" - "\tnetmask {{ contrail_vhost_netmask }}" +################################################################################## + +- name: "copy vrouter script to compute" + template: + src: "../../templates/vrouter-functions.sh" + dest: "/opt/contrail/bin/vrouter-functions.sh" + - name: "load vrouter driver" command: su -s /bin/sh -c "insmod /var/lib/dkms/vrouter/2.21/build/vrouter.ko" + ignore_errors: true - name: "run vhost0 script" command: su -s /bin/sh -c "/opt/contrail/bin/if-vhost0" + ignore_errors: true + +################################################################################## - name: "delete temporary files" file: @@ -108,6 +123,8 @@ - "/tmp/contrail-interfaces-top" - "/tmp/contrail-interfaces-bottom" +################################################################################## + - name: "fix up contrail vrouter nodemgr config" ini_file: dest: "/etc/contrail/contrail-vrouter-nodemgr.conf" @@ -115,6 +132,27 @@ option: "server" value: "{{ contrail_haproxy_address }}" + +################################################################################## +########################### restart vrouter services ########################### + +- name: "restart supervisor service" + service: + name: "supervisor" + state: "restarted" + +- name: "restart vrouter nodemgr" + shell: ps aux | grep contrail-nodemgr | grep -v grep | awk '{print $2}' | xargs kill -9; + +- name: "restart vrouter agent" + service: + name: "contrail-vrouter-agent" + state: "restarted" + + +################################################################################## + + - name: "restart libvirt bin" service: name: "libvirt-bin" @@ -167,14 +205,14 @@ -################################################# -########### nova plugin workaround ############ -################################################# +####################################################################### +###################### nova plugin workaround ####################### +####################################################################### - name: "copy nova plugs on compute" - template: - src: "nova_contrail_vif.tar.gz" - dest: "/opt/nova_contrail_vif.tar.gz" + copy: + src: "../../templates/nova_contrail_vif.tar.gz" + dest: "/opt/nova_contrail_vif.tar.gz" - name: "unzip nova plugs" command: su -s /bin/sh -c "tar xzf /opt/nova_contrail_vif.tar.gz -C /opt/" @@ -182,15 +220,11 @@ - name: "remove original nova plugs" shell: rm -rf /usr/lib/python2.7/dist-packages/nova_contrail_vif/ -- name: "use new neutron plugs" +- name: "use new nova plugs" shell: mv /opt/nova_contrail_vif/ /usr/lib/python2.7/dist-packages/nova_contrail_vif/ ################################################# - - - - - name: "restart nova compute" service: name: "nova-compute" diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-config.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-config.yml index 99a18dba..ecbf3a44 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-config.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-config.yml @@ -30,27 +30,32 @@ # - { regexp: "^\\s*tune.bufsize", line: "\ttune.bufsize 16384" } # - { regexp: "^\\s*tune.maxrewrite", line: "\ttune.maxrewrite 1024" } -- name: "delete haproxy configuration for contrail" - shell: "sed -i -e '/^#contrail-marker-start/,/^#contrail-marker-end/d' /etc/haproxy/haproxy.cfg" +#chenshuai, add later +#- name: "delete haproxy configuration for contrail" +# shell: "sed -i -e '/^#contrail-marker-start/,/^#contrail-marker-end/d' /etc/haproxy/haproxy.cfg" -- name: "create haproxy configuration for contrail" - template: +#chenshuai, add later +#- name: "create haproxy configuration for contrail" +# template: # src: "provision/haproxy-contrail-cfg.j2" - src: "../../templates/provision/haproxy-contrail-cfg.j2" - dest: "/tmp/haproxy-contrail.cfg" +# src: "../../templates/provision/haproxy-contrail-cfg.j2" +# dest: "/tmp/haproxy-contrail.cfg" -- name: "combination of the haproxy configuration" - shell: "cat /tmp/haproxy-contrail.cfg >> /etc/haproxy/haproxy.cfg" +#chenshuai, add later +#- name: "combination of the haproxy configuration" +# shell: "cat /tmp/haproxy-contrail.cfg >> /etc/haproxy/haproxy.cfg" -- name: "delete temporary configuration file" - file: - dest: "/tmp/haproxy-contrail.cfg" - state: "absent" +#chenshuai, add later +#- name: "delete temporary configuration file" +# file: +# dest: "/tmp/haproxy-contrail.cfg" +# state: "absent" -- name: "restart haproxy" - service: - name: "haproxy" - state: "restarted" +#chenshuai, add later +#- name: "restart haproxy" +# service: +# name: "haproxy" +# state: "restarted" # Compass is using this #- name: "create keepalived configuration" @@ -235,9 +240,9 @@ ########################################################### - name: "copy neutron plugs on controller" - template: - src: "neutron_plugin_contrail.tar.gz" - dest: "/opt/neutron_plugin_contrail.tar.gz" + copy: + src: "../../templates/neutron_plugin_contrail.tar.gz" + dest: "/opt/neutron_plugin_contrail.tar.gz" - name: "unzip neutron plugs" command: su -s /bin/sh -c "tar xzf /opt/neutron_plugin_contrail.tar.gz -C /opt/" diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-control.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-control.yml index 3da783e1..67b72c7e 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-control.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-control.yml @@ -17,14 +17,14 @@ dest: "/etc/ifmap-server/basicauthusers.properties" # line: "{{ hostvars[item]['contrail_address' ] }}:{{ hostvars[item]['contrail_address' ] }}" line: "{{ haproxy_hosts[item] }}:{{ haproxy_hosts[item] }}" - with_items: groups['opencontrail_control'] + with_items: groups['controller'] - name: "modify ifmap server basicauthusers properties for dns" lineinfile: dest: "/etc/ifmap-server/basicauthusers.properties" # line: "{{ hostvars[item]['contrail_address' ] }}.dns:{{ hostvars[item]['contrail_address' ] }}.dns" line: "{{ haproxy_hosts[item] }}.dns:{{ haproxy_hosts[item] }}.dns" - with_items: groups['opencontrail_control'] + with_items: groups['controller'] - name: "node-common" include: -node-common.yml diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-database.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-database.yml index b20491b5..7ccb5af1 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-database.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-database.yml @@ -54,7 +54,7 @@ set_fact: # dbseeds: "{{ hostvars[item.1][ contrail_address ] }}" dbseeds: "{{ haproxy_hosts[item.1] }}" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 == 0 @@ -66,7 +66,7 @@ set_fact: # dbseeds: "{{ dbseeds }},{{ hostvars[item.1]['contrail_address'] }}" dbseeds: "{{ dbseeds }},{{ haproxy_hosts[item.1] }}" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 == 1 @@ -122,7 +122,7 @@ regexp: "server.{{ item.0 + 1 }}=" # line: "server.{{ item.0 + 1 }}={{ hostvars[item.1]['contrail_address'] }}:2888:3888" line: "server.{{ item.0 + 1 }}={{ haproxy_hosts[item.1] }}:2888:3888" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] - name: "set zookeeper unique id" @@ -130,7 +130,7 @@ template: src: "../../templates/provision/zookeeper-unique-id.j2" dest: "/var/lib/zookeeper/myid" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.1 == inventory_hostname @@ -146,7 +146,7 @@ set_fact: # zkaddrs: "{{ hostvars[item.1]['contrail_address'] }}:2181" zkaddrs: "{{ haproxy_hosts[item.1] }}:2181" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 == 0 @@ -155,7 +155,7 @@ set_fact: # zkaddrs: "{{ zkaddrs }},{{ hostvars[item.1]['contrail_address'] }}:2181" zkaddrs: "{{ zkaddrs }},{{ haproxy_hosts[item.1] }}:2181" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 > 0 diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-webui.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-webui.yml index 6758b8e7..e50f6a63 100755 --- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-webui.yml +++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-webui.yml @@ -18,14 +18,14 @@ set_fact: # cassandra_addrs: "'{{ hostvars[item.1]['contrail_address'] }}'" cassandra_addrs: "'{{ haproxy_hosts[item.1] }}'" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 == 0 - name: "set second or more cassandra host addresses" set_fact: # cassandra_addrs: "{{ cassandra_addrs }}, '{{ hostvars[item.1]['contrail_address'] }}'" cassandra_addrs: "{{ cassandra_addrs }}, '{{ haproxy_hosts[item.1] }}'" - with_indexed_items: groups['opencontrail_database'] + with_indexed_items: groups['controller'] when: item.0 > 0 - name: "modify webui global js" diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-analytics-api-conf.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-analytics-api-conf.j2 index 3ac84c33..dd5e121e 100755 --- a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-analytics-api-conf.j2 +++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-analytics-api-conf.j2 @@ -2,9 +2,9 @@ host_ip = {{ contrail_address }} rest_api_ip = {{ contrail_haproxy_address }} rest_api_port = 8081 -#cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ ip_settings[cur_host]['mgmt']['ip'] }}:9160{% if not loop.last %} {% endif %}{% endfor %} +#cassandra_server_list = {% for cur_host in groups['controller'] %}{{ ip_settings[cur_host]['mgmt']['ip'] }}:9160{% if not loop.last %} {% endif %}{% endfor %} #chenshuai: This kind of written is also correct, but the following is better, this as record -cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} +cassandra_server_list = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} collectors = {{ contrail_haproxy_address }}:8086 http_server_port = 8090 diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-api-conf.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-api-conf.j2 index 79ba9479..65584138 100755 --- a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-api-conf.j2 +++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-api-conf.j2 @@ -5,9 +5,9 @@ ifmap_server_ip = {{ contrail_haproxy_address }} ifmap_server_port = 8443 ifmap_username = api-server ifmap_password = api-server -zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:2181{% if not loop.last %}, {% endif %}{% endfor %} +zk_server_ip = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:2181{% if not loop.last %}, {% endif %}{% endfor %} -cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} +cassandra_server_list = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} disc_server_ip = {{ contrail_haproxy_address }} disc_server_port = 5998 diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-collector-conf.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-collector-conf.j2 index da5cf2ab..d4cf2cf6 100755 --- a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-collector-conf.j2 +++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-collector-conf.j2 @@ -13,7 +13,7 @@ analytics_flow_ttl = -1 # IP address and port to be used to connect to cassandra. # Multiple IP:port strings separated by space can be provided -cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} +cassandra_server_list = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} # IP address and port to be used to connect to kafka. diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-device-manager-conf.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-device-manager-conf.j2 index 2c45d21a..b2b90a50 100755 --- a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-device-manager-conf.j2 +++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-device-manager-conf.j2 @@ -1,9 +1,9 @@ [DEFAULTS] api_server_ip = {{ contrail_haproxy_address }} api_server_port = 8082 -zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:2181{% if not loop.last %}, {% endif %}{% endfor %} +zk_server_ip = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:2181{% if not loop.last %}, {% endif %}{% endfor %} -cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} +cassandra_server_list = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} disc_server_ip = {{ contrail_haproxy_address }} disc_server_port = 5998 diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-discovery-conf.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-discovery-conf.j2 index 509b3569..d8dbb2c7 100755 --- a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-discovery-conf.j2 +++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-discovery-conf.j2 @@ -1,10 +1,10 @@ [DEFAULTS] listen_ip_addr = {{ contrail_haproxy_address }} listen_port = 5998 -zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}{% if not loop.last %}, {% endif %}{% endfor %} +zk_server_ip = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}{% if not loop.last %}, {% endif %}{% endfor %} zk_server_port = 2181 -cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} +cassandra_server_list = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} log_file = /var/log/contrail/contrail-discovery.log log_level = SYS_NOTICE diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-query-engine-conf.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-query-engine-conf.j2 index 7564d26d..3eb20443 100755 --- a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-query-engine-conf.j2 +++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-query-engine-conf.j2 @@ -1,7 +1,7 @@ [DEFAULT] hostip = {{ contrail_address }} -#cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ ip_settings[cur_host]['mgmt']['ip'] }}:9160{% if not loop.last %} {% endif %}{% endfor %} -cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} +#cassandra_server_list = {% for cur_host in groups['controller'] %}{{ ip_settings[cur_host]['mgmt']['ip'] }}:9160{% if not loop.last %} {% endif %}{% endfor %} +cassandra_server_list = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} collectors = {{ contrail_haproxy_address }}:8086 http_server_port = 8091 diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-schema-conf.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-schema-conf.j2 index 46995f75..f65ab129 100755 --- a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-schema-conf.j2 +++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-schema-conf.j2 @@ -7,9 +7,9 @@ ifmap_password = schema-transformer #api_server_ip = {{ ip_settings[haproxy_hosts.keys()[0]]['mgmt']['ip'] }} api_server_ip = {{ contrail_haproxy_address }} api_server_port = 8082 -zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:2181{% if not loop.last %}, {% endif %}{% endfor %} +zk_server_ip = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:2181{% if not loop.last %}, {% endif %}{% endfor %} -cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} +cassandra_server_list = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} disc_server_ip = {{ contrail_haproxy_address }} disc_server_port = 5998 diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-svc-monitor-conf.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-svc-monitor-conf.j2 index 51740de9..0f612360 100755 --- a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-svc-monitor-conf.j2 +++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-svc-monitor-conf.j2 @@ -5,9 +5,9 @@ ifmap_username = svc-monitor ifmap_password = svc-monitor api_server_ip = {{ contrail_haproxy_address }} api_server_port = 8082 -zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:2181{% if not loop.last %}, {% endif %}{% endfor %} +zk_server_ip = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:2181{% if not loop.last %}, {% endif %}{% endfor %} -cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} +cassandra_server_list = {% for cur_host in groups['controller'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %} disc_server_ip = {{ contrail_haproxy_address }} disc_server_port = 5998 diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-vrouter-agent-conf.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-vrouter-agent-conf.j2 index d0d6b966..61a517c9 100755 --- a/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-vrouter-agent-conf.j2 +++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-vrouter-agent-conf.j2 @@ -66,7 +66,7 @@ platform = default physical_interface_address = # MAC address of device used by dpdk -physical_interface_mac = {{ hostvars[inventory_hostname][contrail_vhost_device]['macaddress'] }} +physical_interface_mac = {{ hostvars[inventory_hostname]['ansible_'+contrail_vhost_device]['macaddress'] }} [DISCOVERY] # If COLLECTOR and/or CONTROL-NODE and/or DNS is not specified this section is @@ -77,7 +77,7 @@ server = {{ contrail_haproxy_address }} # Number of control-nodes info to be provided by Discovery service. Possible # values are 1 and 2 -max_control_nodes = {{ groups['opencontrail_control'] | length }} +max_control_nodes = {{ groups['controller'] | length }} [DNS] # IP address and port to be used to connect to dns-node. Maximum of 2 IP @@ -127,7 +127,7 @@ control_network_ip = {{ contrail_haproxy_address }} name = vhost0 # IP address and prefix in ip/prefix_len format -ip = {{ contraili_vhost_address }}/{{ contrail_prefixlen }} +ip = {{ contrail_vhost_address }}/{{ contrail_prefixlen }} # Gateway IP address for virtual host gateway = {{ contrail_vhost_gateway }} diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/vrouter-functions.sh b/deploy/adapters/ansible/roles/open-contrail/templates/vrouter-functions.sh new file mode 100755 index 00000000..a6208660 --- /dev/null +++ b/deploy/adapters/ansible/roles/open-contrail/templates/vrouter-functions.sh @@ -0,0 +1,215 @@ +#!/bin/bash + +source /etc/contrail/agent_param + +function pkt_setup () { + for f in /sys/class/net/$1/queues/rx-* + do + q="$(echo $f | cut -d '-' -f2)" + r=$(($q%32)) + s=$(($q/32)) + ((mask=1<<$r)) + str=(`printf "%x" $mask`) + if [ $s -gt 0 ]; then + for ((i=0; i < $s; i++)) + do + str+=,00000000 + done + fi + echo $str > $f/rps_cpus + done +} + +function insert_vrouter() { + if cat $CONFIG | grep '^\s*platform\s*=\s*dpdk\b' &>/dev/null; then + vrouter_dpdk_start + return $? + fi + + grep $kmod /proc/modules 1>/dev/null 2>&1 + if [ $? != 0 ]; then + insmod /var/lib/dkms/vrouter/2.21/build/vrouter.ko + if [ $? != 0 ] + then + echo "$(date) : Error inserting vrouter module" + return 1 + fi + + if [ -f /sys/class/net/pkt1/queues/rx-0/rps_cpus ]; then + pkt_setup pkt1 + fi + if [ -f /sys/class/net/pkt2/queues/rx-0/rps_cpus ]; then + pkt_setup pkt2 + fi + if [ -f /sys/class/net/pkt3/queues/rx-0/rps_cpus ]; then + pkt_setup pkt3 + fi + fi + + # check if vhost0 is not present, then create vhost0 and $dev + if [ ! -L /sys/class/net/vhost0 ]; then + echo "$(date): Creating vhost interface: $DEVICE." + # for bonding interfaces + loops=0 + while [ ! -f /sys/class/net/$dev/address ] + do + sleep 1 + loops=$(($loops + 1)) + if [ $loops -ge 60 ]; then + echo "Unable to look at /sys/class/net/$dev/address" + return 1 + fi + done + + DEV_MAC=$(cat /sys/class/net/$dev/address) + vif --create $DEVICE --mac $DEV_MAC + if [ $? != 0 ]; then + echo "$(date): Error creating interface: $DEVICE" + fi + + + echo "$(date): Adding $dev to vrouter" + DEV_MAC=$(cat /sys/class/net/$dev/address) + vif --add $dev --mac $DEV_MAC --vrf 0 --vhost-phys --type physical + if [ $? != 0 ]; then + echo "$(date): Error adding $dev to vrouter" + fi + + vif --add $DEVICE --mac $DEV_MAC --vrf 0 --type vhost --xconnect $dev + if [ $? != 0 ]; then + echo "$(date): Error adding $DEVICE to vrouter" + fi + fi + return 0 +} + +function vrouter_dpdk_start() { + # wait for vRouter/DPDK to start + echo "$(date): Waiting for vRouter/DPDK to start..." + service ${VROUTER_SERVICE} start + loops=0 + while ! is_vrouter_dpdk_running + do + sleep 1 + loops=$(($loops + 1)) + if [ $loops -ge 60 ]; then + echo "No vRouter/DPDK running." + echo "Please check if ${VROUTER_SERVICE} service is up and running." + return 1 + fi + done + + # TODO: at the moment we have no interface deletion, so this loop might + # be unnecessary in the future + echo "$(date): Waiting for Agent to configure $DEVICE..." + loops=0 + while [ ! -L /sys/class/net/vhost0 ] + do + sleep 1 + loops=$(($loops + 1)) + if [ $loops -ge 10 ]; then + break + fi + done + + # check if vhost0 is not present, then create vhost0 and $dev + if [ ! -L /sys/class/net/vhost0 ]; then + echo "$(date): Creating vhost interface: $DEVICE." + agent_conf_read + + DEV_MAC=${physical_interface_mac} + DEV_PCI=${physical_interface_address} + + if [ -z "${DEV_MAC}" -o -z "${DEV_PCI}" ]; then + echo "No device configuration found in ${CONFIG}" + return 1 + fi + + # TODO: the vhost creation is happening later in vif --add +# vif --create $DEVICE --mac $DEV_MAC +# if [ $? != 0 ]; then +# echo "$(date): Error creating interface: $DEVICE" +# fi + + echo "$(date): Adding $dev to vrouter" + # add DPDK ethdev 0 as a physical interface + vif --add 0 --mac $DEV_MAC --vrf 0 --vhost-phys --type physical --pmd --id 0 + if [ $? != 0 ]; then + echo "$(date): Error adding $dev to vrouter" + fi + + # TODO: vif --xconnect seems does not work without --id parameter? + vif --add $DEVICE --mac $DEV_MAC --vrf 0 --type vhost --xconnect 0 --pmd --id 1 + if [ $? != 0 ]; then + echo "$(date): Error adding $DEVICE to vrouter" + fi + fi + return 0 +} + +DPDK_BIND=/opt/contrail/bin/dpdk_nic_bind.py +VROUTER_SERVICE="supervisor-vrouter" + +function is_vrouter_dpdk_running() { + # check for NetLink TCP socket + lsof -ni:20914 -sTCP:LISTEN > /dev/null + + return $? +} + +function agent_conf_read() { + eval `cat ${CONFIG} | grep -E '^\s*physical_\w+\s*='` +} + +function vrouter_dpdk_if_bind() { + if [ ! -s /sys/class/net/${dev}/address ]; then + echo "No ${dev} device found." + ${DPDK_BIND} --status + return 1 + fi + + modprobe igb_uio + # multiple kthreads for port monitoring + modprobe rte_kni kthread_mode=multiple + + ${DPDK_BIND} --force --bind=igb_uio $dev + ${DPDK_BIND} --status +} + +function vrouter_dpdk_if_unbind() { + if [ -s /sys/class/net/${dev}/address ]; then + echo "Device ${dev} is already unbinded." + ${DPDK_BIND} --status + return 1 + fi + + agent_conf_read + + DEV_PCI=${physical_interface_address} + DEV_DRIVER=`lspci -vmmks ${DEV_PCI} | grep 'Module:' | cut -d $'\t' -f 2` + + if [ -z "${DEV_DRIVER}" -o -z "${DEV_PCI}" ]; then + echo "No device ${dev} configuration found in ${AGENT_DPDK_PARAMS_FILE}" + return 1 + fi + + # wait for vRouter/DPDK to stop + echo "$(date): Waiting for vRouter/DPDK to stop..." + loops=0 + while is_vrouter_dpdk_running + do + sleep 1 + loops=$(($loops + 1)) + if [ $loops -ge 60 ]; then + echo "vRouter/DPDK is still running." + echo "Please try to stop ${VROUTER_SERVICE} service." + return 1 + fi + done + + ${DPDK_BIND} --force --bind=${DEV_DRIVER} ${DEV_PCI} + ${DPDK_BIND} --status + + rmmod rte_kni + rmmod igb_uio +} diff --git a/deploy/adapters/ansible/roles/open-contrail/vars/main.yml b/deploy/adapters/ansible/roles/open-contrail/vars/main.yml index c281f5a5..88a7e620 100755 --- a/deploy/adapters/ansible/roles/open-contrail/vars/main.yml +++ b/deploy/adapters/ansible/roles/open-contrail/vars/main.yml @@ -23,8 +23,9 @@ contrail_gateway: ### we make an independent NIC for OpenContrail vRouter ### ########################################################### contrail_vhost_device: "eth2" -contrail_vhost_address: -contrail_vhost_gateway: +contrail_vhost_address: "10.18.1." +contrail_vhost_gateway: "10.18.1.254" +contrail_vhost_netmask: "255.255.255.0" ########################################################### ########################################################### ########################################################### |