Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set discoveryserver public ip address #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
type: "charm"
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
- name: ubuntu
channel: "20.04"
architectures:
- amd64
run-on:
- name: "ubuntu"
channel: "20.04"
- name: ubuntu
channel: "20.04"
architectures: [amd64, s390x, ppc64el, arm64]
12 changes: 10 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""

import logging
import subprocess

from ops.charm import CharmBase
from ops.framework import StoredState
Expand Down Expand Up @@ -45,12 +46,19 @@ def _on_install(self, event):
snap_names='discoveryserver',
channel='latest/edge',
)
logger.debug('Successfully install discoveryserver')
logger.info('Successfully install discoveryserver')
ingress_address = subprocess.check_output(['unit-get',
'public-address'])
ingress_address = ingress_address.decode('utf-8').strip()
logger.info('Setting discovery.host=%s', ingress_address)
discovery_server.set({'discovery.host': ingress_address})
except snap.SnapError as e:
logger.exception('Error occurred installing discoveryserver snap.')
raise
raise e

# Learn more about statuses in the SDK docs:
# https://juju.is/docs/sdk/constructs#heading--statuses
self.unit.open_port('tcp', 8087)
self.unit.status = ActiveStatus()


Expand Down