# 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")
@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")
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")
"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
WaitingStatus,
)
--from glob import glob
--from pathlib import Path
--from string import Template
++
++sys.path.append("lib")
++
logger = logging.getLogger(__name__)
},
}
)
+
+ 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
WaitingStatus,
)
--from glob import glob
--from pathlib import Path
--from string import Template
++
++sys.path.append("lib")
++
logger = logging.getLogger(__name__)
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()
--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
# 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"
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"
ng-ui:
options:
image: opensourcemano/ng-ui:$TAG
+ keystone:
+ options:
+ image: opensourcemano/keystone:$TAG
EOF
mv /tmp/images-overlay.yaml $IMAGES_OVERLAY_FILE
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"