Merge branch 'v8.0' 15/9915/2
authorbeierlm <mark.beierl@canonical.com>
Fri, 23 Oct 2020 18:54:56 +0000 (14:54 -0400)
committerbeierlm <mark.beierl@canonical.com>
Fri, 23 Oct 2020 19:01:05 +0000 (15:01 -0400)
Change-Id: I96d3bae3abca7b2a5f66bca591b4358d6c921f3d
Signed-off-by: beierlm <mark.beierl@canonical.com>
1  2 
installers/charm/lcm-k8s/reactive/lcm.py
installers/charm/ng-ui/src/charm.py
installers/charm/pla/src/charm.py
installers/charmed_install.sh

  #     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #     See the License for the specific language governing permissions and
  #     limitations under the License.
--from charms.layer.caas_base import pod_spec_set
--from charms.reactive import endpoint_from_flag
--from charms.reactive import when, when_not, hook
--from charms.reactive.flags import set_flag, clear_flag
++import logging
++import yaml
++
  from charmhelpers.core.hookenv import (
      log,
      metadata,
      config,
  )
  from charms import layer
--import yaml
- import logging
++from charms.layer.caas_base import pod_spec_set
++from charms.reactive import endpoint_from_flag
++from charms.reactive import when, when_not, hook
++from charms.reactive.flags import set_flag, clear_flag
++
 +
 +logger = logging.getLogger(__name__)
 +
  
  @hook("upgrade-charm")
  @when("leadership.is_leader")
@@@ -41,21 -37,18 +43,21 @@@ def restart()
  
  @when_not("kafka.ready")
  @when_not("lcm-k8s.configured")
 +@when("leadership.is_leader")
  def waiting_for_kafka():
      layer.status.waiting("Waiting for kafka to be ready")
  
  
  @when_not("mongo.ready")
  @when_not("lcm-k8s.configured")
 +@when("leadership.is_leader")
  def waiting_for_mongo():
      layer.status.waiting("Waiting for mongo to be ready")
  
  
  @when_not("ro.ready")
  @when_not("lcm-k8s.configured")
 +@when("leadership.is_leader")
  def waiting_for_ro():
      layer.status.waiting("Waiting for ro to be ready")
  
@@@ -103,14 -96,7 +105,14 @@@ def configure()
          layer.status.blocked("k8s spec failed to deploy: {}".format(e))
  
  
 +@when("kafka.ready", "mongo.ready", "ro.ready")
 +@when_not("leadership.is_leader")
 +def non_leaders_active():
 +    layer.status.active("ready")
 +
 +
  @when("lcm-k8s.configured")
 +@when("leadership.is_leader")
  def set_lcm_active():
      layer.status.active("ready")
  
@@@ -144,8 -130,8 +146,8 @@@ def make_pod_spec(ro_host, ro_port, kaf
          "mongo_uri": mongo_uri,
      }
      data.update(cfg)
 -
 -    spec = yaml.safe_dump(pod_spec_template % data)
 +    logs = pod_spec_template % data
 +    spec = yaml.safe_load(pod_spec_template % data)
      if "vca_apiproxy" in cfg and cfg["vca_apiproxy"] != "":
          spec["containers"][0]["config"]["OSMLCM_VCA_APIPROXY"] = cfg["vca_apiproxy"]
 -    return spec
 +    return spec
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
--import sys
--import logging
  import base64
--
--sys.path.append("lib")
++from glob import glob
++import logging
++from pathlib import Path
++from string import Template
++import sys
  
  from ops.charm import CharmBase
  from ops.framework import StoredState, Object
@@@ -30,9 -30,9 +31,9 @@@ from ops.model import 
      WaitingStatus,
  )
  
--from glob import glob
--from pathlib import Path
--from string import Template
++
++sys.path.append("lib")
++
  
  logger = logging.getLogger(__name__)
  
@@@ -157,7 -157,7 +158,9 @@@ class NGUICharm(CharmBase)
                      },
                  }
              )
 +
+         logger.debug(files)
++
          spec = {
              "version": 2,
              "containers": [
          self.on_start(event)
  
      def on_nbi_relation_changed(self, event):
 -        unit = self.model.unit
 -        if not unit.is_leader():
 -            return
 -        self.state.nbi_host = event.relation.data[event.unit].get("host")
 -        self.state.nbi_port = event.relation.data[event.unit].get("port")
 +        nbi_host = event.relation.data[event.unit].get("host")
 +        nbi_port = event.relation.data[event.unit].get("port")
 +        if nbi_host and self.state.nbi_host != nbi_host:
 +            self.state.nbi_host = nbi_host
 +        if nbi_port and self.state.nbi_port != nbi_port:
 +            self.state.nbi_port = nbi_port
          self._apply_spec()
  
  
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
--import sys
++from glob import glob
  import logging
--
--sys.path.append("lib")
++from pathlib import Path
++from string import Template
++import sys
  
  from ops.charm import CharmBase
  from ops.framework import StoredState, Object
@@@ -27,9 -27,9 +28,9 @@@ from ops.model import 
      WaitingStatus,
  )
  
--from glob import glob
--from pathlib import Path
--from string import Template
++
++sys.path.append("lib")
++
  
  logger = logging.getLogger(__name__)
  
@@@ -84,7 -84,7 +85,7 @@@ class PLACharm(CharmBase)
          config = self.framework.model.config
  
          ports = [
-             {"name": "port", "containerPort": config["port"], "protocol": "TCP",},
+             {"name": "port", "containerPort": config["port"], "protocol": "TCP", },
          ]
  
          config_spec = {
          """Upgrade the charm."""
          unit = self.model.unit
          unit.status = MaintenanceStatus("Upgrading charm")
 -        self.on_start(event)
 +        self._apply_spec()
  
      def on_kafka_relation_changed(self, event):
 -        unit = self.model.unit
 -        if not unit.is_leader():
 -            return
 -        self.state.kafka_host = event.relation.data[event.unit].get("host")
 -        self.state.kafka_port = event.relation.data[event.unit].get("port")
 +        kafka_host = event.relation.data[event.unit].get("host")
 +        kafka_port = event.relation.data[event.unit].get("port")
 +        if kafka_host and self.state.kafka_host != kafka_host:
 +            self.state.kafka_host = kafka_host
 +        if kafka_port and self.state.kafka_port != kafka_port:
 +            self.state.kafka_port = kafka_port
          self._apply_spec()
  
      def on_mongo_relation_changed(self, event):
 -        unit = self.model.unit
 -        if not unit.is_leader():
 -            return
 -        self.state.mongodb_uri = event.relation.data[event.unit].get(
 +        mongodb_uri = event.relation.data[event.unit].get(
              "connection_string"
          )
 +        if mongodb_uri and self.state.mongodb_uri != mongodb_uri:
 +            self.state.mongodb_uri = mongodb_uri
          self._apply_spec()
  
  
@@@ -27,7 -27,7 +27,7 @@@ function check_arguments()
              --lxd) LXD_CLOUD="$2" ;;
              --lxd-cred) LXD_CREDENTIALS="$2" ;;
              --microstack) MICROSTACK=y ;;
 -            --ha) BUNDLE="cs:osm-ha-39" ;;
 +            --ha) BUNDLE="cs:osm-ha" ;;
              --tag) TAG="$2" ;;
          esac
          shift
@@@ -131,6 -131,7 +131,6 @@@ EO
          # Install LXD snap
          sudo apt-get remove --purge -y liblxc1 lxc-common lxcfs lxd lxd-client
          sudo snap install lxd
 -        sudo apt-get install zfsutils-linux -y
          # Configure LXD
          sudo usermod -a -G lxd `whoami`
          cat /usr/share/osm-devops/installers/lxd-preseed.conf | sed 's/^config: {}/config:\n  core.https_address: '$LXDENDPOINT':8443/' | sg lxd -c "lxd init --preseed"
@@@ -208,7 -209,7 +208,7 @@@ function deploy_charmed_osm()
      if [ -v BUNDLE ]; then
          juju deploy $BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay
      else
 -        juju deploy cs:osm-49 --overlay ~/.osm/vca-overlay.yaml $images_overlay
 +        juju deploy cs:osm --overlay ~/.osm/vca-overlay.yaml $images_overlay
      fi
  
      echo "Waiting for deployment to finish..."
  function check_osm_deployed() {
      TIME_TO_WAIT=600
      start_time="$(date -u +%s)"
-     total_service_count=14
+     total_service_count=15
+     previous_count=0
      while true
      do
          service_count=$(juju status | grep kubernetes | grep active | wc -l)
          if [ $service_count -eq $total_service_count ]; then
              break
          fi
+         if [ $service_count -ne $previous_count ]; then
+             previous_count=$service_count
+             start_time="$(date -u +%s)"
+         fi
          now="$(date -u +%s)"
          if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
              echo "Timed out waiting for OSM services to become ready"
@@@ -347,9 -353,6 +352,9 @@@ applications
    ng-ui:
      options:
        image: opensourcemano/ng-ui:$TAG
 +  keystone:
 +    options:
 +      image: opensourcemano/keystone:$TAG
  
  EOF
      mv /tmp/images-overlay.yaml $IMAGES_OVERLAY_FILE
@@@ -403,14 -406,16 +408,16 @@@ if [ -v MICROSTACK ]; the
      install_microstack
  fi
  
+ OSM_HOSTNAME=$(juju config nbi-k8s juju-external-hostname):443
  echo "Your installation is now complete, follow these steps for configuring the osmclient:"
  echo
  echo "1. Create the OSM_HOSTNAME environment variable with the NBI IP"
  echo
- echo "export OSM_HOSTNAME=nbi.$API_SERVER.xip.io:443"
+ echo "export OSM_HOSTNAME=$OSM_HOSTNAME"
  echo
  echo "2. Add the previous command to your .bashrc for other Shell sessions"
  echo
- echo "echo \"export OSM_HOSTNAME=nbi.$API_SERVER.xip.io:443\" >> ~/.bashrc"
+ echo "echo \"export OSM_HOSTNAME=$OSM_HOSTNAME\" >> ~/.bashrc"
  echo
  echo "DONE"