Avoid killing create_number.py 86/67286/1
authorCédric Ollivier <cedric.ollivier@orange.com>
Mon, 18 Mar 2019 17:04:40 +0000 (18:04 +0100)
committerCédric Ollivier <cedric.ollivier@orange.com>
Mon, 18 Mar 2019 17:09:19 +0000 (18:09 +0100)
create_numbers.py has been killed by other services as described in [1].
It's now called when ellis is up and running.

It adds few sleeps to ensure the right boot orders (signals must be send
before switching DNS).

[1] http://www.projectclearwater.org/using-start-stop-daemon-with-the-python-interpreter/

Change-Id: I87ad3828c10d3ccbc707ed8f4ab99987c6968f09
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit 45708eda7ba8e4ddac85930dbb5defb14b9af88b)

docker/vnf/clearwater-heat-singlenet-deps.patch
functest/opnfv_tests/vnf/ims/heat_ims.py

index 8d0433f..15ff3e2 100644 (file)
@@ -1,5 +1,5 @@
 diff --git a/bono.yaml b/bono.yaml
-index f0189cd..42bfecb 100644
+index f0189cd..0a39057 100644
 --- a/bono.yaml
 +++ b/bono.yaml
 @@ -23,26 +23,6 @@ parameters:
@@ -84,7 +84,7 @@ index f0189cd..42bfecb 100644
        user_data_format: RAW
        user_data:
          str_replace:
-@@ -143,15 +112,11 @@ resources:
+@@ -143,48 +112,18 @@ resources:
              __zone__: { get_param: zone }
              __public_mgmt_ip__: { get_attr: [ mgmt_floating_ip, floating_ip_address ] }
              __private_mgmt_ip__: { get_attr: [ mgmt_port, fixed_ips, 0, ip_address ] }
@@ -101,10 +101,10 @@ index f0189cd..42bfecb 100644
            template: |
              #!/bin/bash
  
-@@ -159,33 +124,6 @@ resources:
+             # Log all output to file.
              exec > >(tee -a /var/log/clearwater-heat-bono.log) 2>&1
              set -x
+-
 -            # Set up the signaling network namespace on each boot by creating an init file and
 -            # linking to it from runlevel 2 and 3
 -            cat >/etc/init.d/signaling_namespace <<EOF
@@ -131,11 +131,11 @@ index f0189cd..42bfecb 100644
 -
 -            # Also set up the signaling namespace now.
 -            /etc/init.d/signaling_namespace
--
++            sleep 180
              # Configure the APT software source.
              echo 'deb __repo_url__ binary/' > /etc/apt/sources.list.d/clearwater.list
-             curl -L http://repo.cw-ngv.com/repo_key | apt-key add -
-@@ -196,11 +134,8 @@ resources:
+@@ -196,11 +135,8 @@ resources:
              etcd_ip=__etcd_ip__
              [ -n "$etcd_ip" ] || etcd_ip=__private_mgmt_ip__
              cat > /etc/clearwater/local_config << EOF
@@ -149,7 +149,7 @@ index f0189cd..42bfecb 100644
              public_hostname=__index__.bono.__zone__
              etcd_cluster=$etcd_ip
              EOF
-@@ -223,8 +158,8 @@ resources:
+@@ -223,8 +159,8 @@ resources:
              while ! { nsupdate -y "__zone__:__dnssec_key__" -v << EOF
              server __dns_mgmt_ip__
              update add bono-__index__.__zone__. 30 $(ip2rr __public_mgmt_ip__)
@@ -160,7 +160,7 @@ index f0189cd..42bfecb 100644
              update add __zone__. 30 NAPTR 0 0 "s" "SIP+D2T" "" _sip._tcp.__zone__.
              update add __zone__. 30 NAPTR 0 0 "s" "SIP+D2U" "" _sip._udp.__zone__.
              update add _sip._tcp.__zone__. 30 SRV 0 0 5060 __index__.bono.__zone__.
-@@ -238,13 +173,20 @@ resources:
+@@ -238,13 +174,20 @@ resources:
                sleep 5
              done
  
@@ -183,7 +183,7 @@ index f0189cd..42bfecb 100644
  outputs:
    public_mgmt_ip:
      description: IP address in public management network
-@@ -252,9 +194,3 @@ outputs:
+@@ -252,9 +195,3 @@ outputs:
    private_mgmt_ip:
      description: IP address in private management network
      value: { get_attr: [ mgmt_port, fixed_ips, 0, ip_address ] }
@@ -428,7 +428,7 @@ index a155c60..1bfe257 100644
            etcd_ip: { get_attr: [ ellis, private_mgmt_ip ] }
            index: __index__
 diff --git a/dime.yaml b/dime.yaml
-index 642f19d..b6f115a 100644
+index 642f19d..214a985 100644
 --- a/dime.yaml
 +++ b/dime.yaml
 @@ -23,26 +23,6 @@ parameters:
@@ -519,7 +519,7 @@ index 642f19d..b6f115a 100644
        user_data_format: RAW
        user_data:
          str_replace:
-@@ -141,14 +112,11 @@ resources:
+@@ -141,47 +112,18 @@ resources:
              __zone__: { get_param: zone }
              __public_mgmt_ip__: { get_attr: [ mgmt_floating_ip, floating_ip_address ] }
              __private_mgmt_ip__: { get_attr: [ mgmt_port, fixed_ips, 0, ip_address ] }
@@ -535,10 +535,10 @@ index 642f19d..b6f115a 100644
            template: |
              #!/bin/bash
  
-@@ -156,33 +124,6 @@ resources:
+             # Log all output to file.
              exec > >(tee -a /var/log/clearwater-heat-dime.log) 2>&1
              set -x
+-
 -            # Set up the signaling network namespace on each boot by creating an init file and
 -            # linking to it from runlevel 2 and 3
 -            cat >/etc/init.d/signaling_namespace <<EOF
@@ -565,11 +565,11 @@ index 642f19d..b6f115a 100644
 -
 -            # Also set up the signaling namespace now.
 -            /etc/init.d/signaling_namespace
--
++            sleep 180
              # Configure the APT software source.
              echo 'deb __repo_url__ binary/' > /etc/apt/sources.list.d/clearwater.list
-             curl -L http://repo.cw-ngv.com/repo_key | apt-key add -
-@@ -193,11 +134,8 @@ resources:
+@@ -193,11 +135,8 @@ resources:
              etcd_ip=__etcd_ip__
              [ -n "$etcd_ip" ] || etcd_ip=__private_mgmt_ip__
              cat > /etc/clearwater/local_config << EOF
@@ -583,7 +583,7 @@ index 642f19d..b6f115a 100644
              public_hostname=dime-__index__.__zone__
              etcd_cluster=$etcd_ip
              EOF
-@@ -220,9 +158,9 @@ resources:
+@@ -220,9 +159,9 @@ resources:
              while ! { nsupdate -y "__zone__:__dnssec_key__" -v << EOF
              server __dns_mgmt_ip__
              update add dime-__index__.__zone__. 30 $(ip2rr __public_mgmt_ip__)
@@ -596,7 +596,7 @@ index 642f19d..b6f115a 100644
              send
              EOF
              } && [ $retries -lt 10 ]
-@@ -232,20 +170,23 @@ resources:
+@@ -232,20 +171,23 @@ resources:
                sleep 5
              done
  
@@ -742,7 +742,7 @@ index 825ede1..11a833b 100644
      description: DNS zone
      value: { get_param: zone }
 diff --git a/ellis.yaml b/ellis.yaml
-index 963352d..ee7e505 100644
+index 963352d..c9fbb46 100644
 --- a/ellis.yaml
 +++ b/ellis.yaml
 @@ -44,9 +44,6 @@ parameters:
@@ -806,7 +806,15 @@ index 963352d..ee7e505 100644
              EOF
              /usr/share/clearwater/clearwater-config-manager/scripts/cw-config upload shared_config --autoconfirm --dir /tmp
  
-@@ -223,11 +232,19 @@ resources:
+@@ -197,7 +206,6 @@ resources:
+             # local_settings.py runs to pick up the configuration changes.
+             service clearwater-infrastructure restart
+             service ellis stop
+-            /usr/share/clearwater/ellis/env/bin/python /usr/share/clearwater/ellis/src/metaswitch/ellis/tools/create_numbers.py --start __dn_range_start__ --count __dn_range_length__ --realm __zone__
+             # Function to give DNS record type and IP address for specified IP address
+             ip2rr() {
+@@ -223,11 +231,21 @@ resources:
                sleep 5
              done
  
@@ -822,12 +830,14 @@ index 963352d..ee7e505 100644
 +            clearwater-etcdctl cluster-health
 +            clearwater-etcdctl member list
 +            cw-check_config_sync
++
++            /usr/share/clearwater/ellis/env/bin/python /usr/share/clearwater/ellis/src/metaswitch/ellis/tools/create_numbers.py --start __dn_range_start__ --count __dn_range_length__ --realm __zone__
 +
  outputs:
    public_mgmt_ip:
      description: IP address in public management network
 diff --git a/homer.yaml b/homer.yaml
-index 4337984..f6bedde 100644
+index 4337984..0640d4b 100644
 --- a/homer.yaml
 +++ b/homer.yaml
 @@ -23,26 +23,6 @@ parameters:
@@ -923,7 +933,7 @@ index 4337984..f6bedde 100644
        user_data_format: RAW
        user_data:
          str_replace:
-@@ -147,15 +112,11 @@ resources:
+@@ -147,48 +112,18 @@ resources:
              __zone__: { get_param: zone }
              __public_mgmt_ip__: { get_attr: [ mgmt_floating_ip, floating_ip_address ] }
              __private_mgmt_ip__: { get_attr: [ mgmt_port, fixed_ips, 0, ip_address ] }
@@ -940,10 +950,10 @@ index 4337984..f6bedde 100644
            template: |
              #!/bin/bash
  
-@@ -163,33 +124,6 @@ resources:
+             # Log all output to file.
              exec > >(tee -a /var/log/clearwater-heat-homer.log) 2>&1
              set -x
+-
 -            # Set up the signaling network namespace on each boot by creating an init file and
 -            # linking to it from runlevel 2 and 3
 -            cat >/etc/init.d/signaling_namespace <<EOF
@@ -970,11 +980,11 @@ index 4337984..f6bedde 100644
 -
 -            # Also set up the signaling namespace now.
 -            /etc/init.d/signaling_namespace
--
++            sleep 180
              # Configure the APT software source.
              echo 'deb __repo_url__ binary/' > /etc/apt/sources.list.d/clearwater.list
-             curl -L http://repo.cw-ngv.com/repo_key | apt-key add -
-@@ -200,11 +134,8 @@ resources:
+@@ -200,11 +135,8 @@ resources:
              etcd_ip=__etcd_ip__
              [ -n "$etcd_ip" ] || etcd_ip=__private_mgmt_ip__
              cat > /etc/clearwater/local_config << EOF
@@ -988,7 +998,7 @@ index 4337984..f6bedde 100644
              public_hostname=homer-__index__.__zone__
              etcd_cluster=$etcd_ip
              EOF
-@@ -227,7 +158,7 @@ resources:
+@@ -227,7 +159,7 @@ resources:
              while ! { nsupdate -y "__zone__:__dnssec_key__" -v << EOF
              server __dns_mgmt_ip__
              update add homer-__index__.__zone__. 30 $(ip2rr __public_mgmt_ip__)
@@ -997,7 +1007,7 @@ index 4337984..f6bedde 100644
              send
              EOF
              } && [ $retries -lt 10 ]
-@@ -237,14 +168,20 @@ resources:
+@@ -237,14 +169,20 @@ resources:
                sleep 5
              done
  
@@ -1021,7 +1031,7 @@ index 4337984..f6bedde 100644
  outputs:
    public_mgmt_ip:
      description: IP address in public management network
-@@ -252,9 +189,3 @@ outputs:
+@@ -252,9 +190,3 @@ outputs:
    private_mgmt_ip:
      description: IP address in private management network
      value: { get_attr: [ mgmt_port, fixed_ips, 0, ip_address ] }
@@ -1381,7 +1391,7 @@ index 5921d32..c73fe2b 100644
 -    value: { get_resource: vellum_sig_inbound }
 +    value: { get_resource: base_mgmt }
 diff --git a/sprout.yaml b/sprout.yaml
-index 9c533b7..f84915a 100644
+index 9c533b7..4a5d4b6 100644
 --- a/sprout.yaml
 +++ b/sprout.yaml
 @@ -23,26 +23,6 @@ parameters:
@@ -1465,7 +1475,7 @@ index 9c533b7..f84915a 100644
        user_data_format: RAW
        user_data:
          str_replace:
-@@ -141,14 +112,11 @@ resources:
+@@ -141,47 +112,18 @@ resources:
              __zone__: { get_param: zone }
              __public_mgmt_ip__: { get_attr: [ mgmt_floating_ip, floating_ip_address ] }
              __private_mgmt_ip__: { get_attr: [ mgmt_port, fixed_ips, 0, ip_address ] }
@@ -1481,10 +1491,10 @@ index 9c533b7..f84915a 100644
            template: |
              #!/bin/bash
  
-@@ -156,33 +124,6 @@ resources:
+             # Log all output to file.
              exec > >(tee -a /var/log/clearwater-heat-sprout.log) 2>&1
              set -x
+-
 -            # Set up the signaling network namespace on each boot by creating an init file and
 -            # linking to it from runlevel 2 and 3
 -            cat >/etc/init.d/signaling_namespace <<EOF
@@ -1511,11 +1521,11 @@ index 9c533b7..f84915a 100644
 -
 -            # Also set up the signaling namespace now.
 -            /etc/init.d/signaling_namespace
--
++            sleep 300
              # Configure the APT software source.
              echo 'deb __repo_url__ binary/' > /etc/apt/sources.list.d/clearwater.list
-             curl -L http://repo.cw-ngv.com/repo_key | apt-key add -
-@@ -193,11 +134,8 @@ resources:
+@@ -193,11 +135,8 @@ resources:
              etcd_ip=__etcd_ip__
              [ -n "$etcd_ip" ] || etcd_ip=__private_mgmt_ip__
              cat > /etc/clearwater/local_config << EOF
@@ -1529,7 +1539,7 @@ index 9c533b7..f84915a 100644
              public_hostname=__index__.sprout.__zone__
              etcd_cluster=$etcd_ip
              EOF
-@@ -220,10 +158,10 @@ resources:
+@@ -220,10 +159,10 @@ resources:
              while ! { nsupdate -y "__zone__:__dnssec_key__" -v << EOF
              server __dns_mgmt_ip__
              update add sprout-__index__.__zone__. 30 $(ip2rr __public_mgmt_ip__)
@@ -1544,7 +1554,7 @@ index 9c533b7..f84915a 100644
              update add sprout.__zone__. 30 NAPTR 0 0 "s" "SIP+D2T" "" _sip._tcp.sprout.__zone__.
              update add _sip._tcp.sprout.__zone__. 30 SRV 0 0 5054 __index__.sprout.__zone__.
              update add icscf.sprout.__zone__. 30 NAPTR 0 0 "s" "SIP+D2T" "" _sip._tcp.icscf.sprout.__zone__.
-@@ -239,20 +177,24 @@ resources:
+@@ -239,20 +178,24 @@ resources:
                sleep 5
              done
  
@@ -1576,7 +1586,7 @@ index 9c533b7..f84915a 100644
 -    description: IP address in private signaling network
 -    value: { get_attr: [ sig_port, fixed_ips, 0, ip_address ] }
 diff --git a/vellum.yaml b/vellum.yaml
-index aab71f9..8f63557 100644
+index aab71f9..c2ca279 100644
 --- a/vellum.yaml
 +++ b/vellum.yaml
 @@ -23,26 +23,6 @@ parameters:
@@ -1660,7 +1670,7 @@ index aab71f9..8f63557 100644
        user_data_format: RAW
        user_data:
          str_replace:
-@@ -141,47 +112,18 @@ resources:
+@@ -141,47 +112,19 @@ resources:
              __zone__: { get_param: zone }
              __public_mgmt_ip__: { get_attr: [ mgmt_floating_ip, floating_ip_address ] }
              __private_mgmt_ip__: { get_attr: [ mgmt_port, fixed_ips, 0, ip_address ] }
@@ -1706,11 +1716,12 @@ index aab71f9..8f63557 100644
 -
 -            # Also set up the signaling namespace now.
 -            /etc/init.d/signaling_namespace
++            sleep 180
 +            sysctl -w net.ipv6.conf.lo.disable_ipv6=0
  
              # Configure the APT software source.
              echo 'deb __repo_url__ binary/' > /etc/apt/sources.list.d/clearwater.list
-@@ -193,11 +135,8 @@ resources:
+@@ -193,11 +136,8 @@ resources:
              etcd_ip=__etcd_ip__
              [ -n "$etcd_ip" ] || etcd_ip=__private_mgmt_ip__
              cat > /etc/clearwater/local_config << EOF
@@ -1724,7 +1735,7 @@ index aab71f9..8f63557 100644
              public_hostname=__index__.vellum.__zone__
              etcd_cluster=$etcd_ip
              EOF
-@@ -206,7 +145,7 @@ resources:
+@@ -206,7 +146,7 @@ resources:
              mkdir -p /etc/chronos
              cat > /etc/chronos/chronos.conf << EOF
              [http]
@@ -1733,7 +1744,7 @@ index aab71f9..8f63557 100644
              bind-port = 7253
              threads = 50
  
-@@ -218,7 +157,7 @@ resources:
+@@ -218,7 +158,7 @@ resources:
              enabled = true
  
              [dns]
@@ -1742,7 +1753,7 @@ index aab71f9..8f63557 100644
              EOF
  
              # Now install the software.
-@@ -239,7 +178,7 @@ resources:
+@@ -239,7 +179,7 @@ resources:
              while ! { nsupdate -y "__zone__:__dnssec_key__" -v << EOF
              server __dns_mgmt_ip__
              update add vellum-__index__.__zone__. 30 $(ip2rr __public_mgmt_ip__)
@@ -1751,7 +1762,7 @@ index aab71f9..8f63557 100644
              send
              EOF
              } && [ $retries -lt 10 ]
-@@ -249,13 +188,20 @@ resources:
+@@ -249,13 +189,20 @@ resources:
                sleep 5
              done
  
@@ -1774,7 +1785,7 @@ index aab71f9..8f63557 100644
  outputs:
    public_mgmt_ip:
      description: IP address in public management network
-@@ -263,6 +209,3 @@ outputs:
+@@ -263,6 +210,3 @@ outputs:
    private_mgmt_ip:
      description: IP address in private management network
      value: { get_attr: [ mgmt_port, fixed_ips, 0, ip_address ] }
index ff93e98..5608268 100644 (file)
@@ -185,11 +185,14 @@ class HeatIms(singlevm.VmReady2):
             wait=True, **parameters)
         self.__logger.debug("stack: %s", self.stack)
 
+        time.sleep(300)
+        self._monit()
+
         servers = self.cloud.list_servers(detailed=True)
         self.__logger.debug("servers: %s", servers)
         for server in servers:
             if not self.check_regex_in_console(
-                    server.name, regex='Cloud-init .* finished at ', loop=60):
+                    server.name, regex='Cloud-init .* finished at ', loop=1):
                 return False
             if 'ellis' in server.name:
                 self.__logger.debug("server: %s", server)
@@ -222,8 +225,6 @@ class HeatIms(singlevm.VmReady2):
         if not dns_ip:
             return False
 
-        self._monit()
-
         short_result = self.clearwater.run_clearwater_live_test(
             dns_ip=dns_ip,
             public_domain=self.vnf['parameters']["zone"])
@@ -244,6 +245,7 @@ class HeatIms(singlevm.VmReady2):
             self.__logger.exception("Cannot calculate results")
             self.details['test_vnf'].update(status='FAIL')
             return False
+        self._monit()
         return True if vnf_test_rate > 0 else False
 
     def clean(self):