Skip to content

Commit

Permalink
upgrade to support libjuju-2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
matuskosut committed Aug 24, 2022
1 parent 56b5e5d commit c75b801
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions jujuna/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import argcomplete
import async_timeout

from juju import loop
from juju import jasyncio

from jujuna.helper import log_traceback

Expand Down Expand Up @@ -201,7 +201,7 @@ def main():
action, timeout, args = parse_args(sys.argv[1:])

try:
ret = loop.run(
ret = jasyncio.run(
run_action(action, timeout, args)
)
except Exception as e:
Expand Down
5 changes: 4 additions & 1 deletion jujuna/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from jujuna.helper import connect_juju, log_traceback
from juju.errors import JujuError
from juju.client import client
from juju import jasyncio


# create logger
Expand All @@ -18,6 +19,9 @@ async def wait_until(model, *conditions, log_time=5, timeout=None, wait_period=0
"""
log_count = 0

if not loop:
loop = jasyncio.get_running_loop()

def _disconnected():
return not (model.is_connected() and model.connection().is_open)

Expand Down Expand Up @@ -110,7 +114,6 @@ async def clean(
await wait_until(
model,
lambda: model.applications == {} and model.machines == {},
loop=model.loop
)

except JujuError as e:
Expand Down
3 changes: 1 addition & 2 deletions jujuna/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def deploy(
"""
ret = 0
log.info('Reading bundle: {}'.format(bundle_file.name))
entity_url = 'local:' + bundle_file.name.replace('/bundle.yaml', '')
entity_url = 'local:{}'.format(bundle_file.name.replace('/bundle.yaml', ''))

controller, model = await connect_juju(
ctrl_name,
Expand All @@ -65,7 +65,6 @@ async def deploy(
model,
deployed_apps,
log,
loop=model.loop,
error_timeout=error_timeout
)
else:
Expand Down
4 changes: 4 additions & 0 deletions jujuna/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from juju.controller import Controller
from juju.model import Model
from juju import jasyncio

from theblues.charmstore import CharmStore

Expand Down Expand Up @@ -102,6 +103,9 @@ async def wait_until(model, apps, logger, log_time=5, timeout=None, wait_period=
"""
log_count = 0

if not loop:
loop = jasyncio.get_running_loop()

def _disconnected():
return not (model.is_connected() and model.connection().is_open)

Expand Down
7 changes: 4 additions & 3 deletions jujuna/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from jujuna.settings import ORIGIN_KEYS, SERVICES

from juju.errors import JujuError
from juju import jasyncio


# create logger
Expand Down Expand Up @@ -145,7 +146,6 @@ async def ocata_relation_patch(model, dry_run, cinder_ceph):
model,
model.applications.values(),
timeout=1800,
loop=model.loop
)
log.info('Completed addition of relation')
except Exception as e:
Expand Down Expand Up @@ -207,7 +207,6 @@ async def upgrade_services(model, upgraded, origin, origin_keys, upgrade_action,
model,
model.applications.values(),
timeout=1800,
loop=model.loop
)

sl_after = get_service_list(model, upgraded)
Expand Down Expand Up @@ -296,7 +295,6 @@ async def upgrade_charms(model, apps, dry_run, ignore_errors):
model,
list(model.applications.values()),
timeout=1800,
loop=model.loop
)

log.info('Collecting final workload status')
Expand Down Expand Up @@ -333,6 +331,9 @@ async def wait_until(model, apps, log_time=10, timeout=None, wait_period=0.5, lo
"""
log_count = 0

if not loop:
loop = jasyncio.get_running_loop()

def _disconnected():
return not (model.is_connected() and model.connection().is_open)

Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pip>=19
pyyaml<6.0.0,>=5.1.2
pyyaml>=5.1.2,<=6.0.0
async-timeout<4.0.0,>=2.0.1
tox>=3.14.1
juju<2.9.0,>=2.8.4
argcomplete==1.10.0
theblues<1.0,>=0.5.2
juju>=2.9.7,<2.10.0
argcomplete>=1.10.0,<2.0.0
theblues>=0.5.2,<1.0
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,20 @@
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
"Environment :: Console"
],
'install_requires': [
'async-timeout<4.0.0,>=2.0.1',
'argcomplete==1.10.0',
'theblues<1.0.0,>=0.5.2'
'async-timeout>=2.0.1,<4.0.0',
'argcomplete>=1.10.0,<2.0.0',
'theblues>=0.5.2,<1.0'
],
'extras_require': {
":python_version>'3.5.2'": [
'juju<2.9.0,>=2.8.0',
'pyyaml<6.0,>=3.0',
'juju>=2.9.7,<2.10.0',
'pyyaml>=5.1.2,<=6.0.0',
],
":python_version<='3.5.2'": [
'juju<1.0.0,>=0.11.7',
Expand Down

0 comments on commit c75b801

Please sign in to comment.