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

uaclient to ubuntupro #2703

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 3 additions & 3 deletions apport/source_ubuntu-advantage-tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import tempfile

from apport.hookutils import attach_file_if_exists
from uaclient import defaults
from uaclient.actions import collect_logs
from uaclient.config import UAConfig
from ubuntupro import defaults
from ubuntupro.actions import collect_logs
from ubuntupro.config import UAConfig


def add_info(report, ui=None):
Expand Down
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ifeq (LTS,$(findstring LTS,$(VERSION)))
make -C apt-hook test
endif
python3 -m pytest
python3 -m flake8 uaclient
python3 -m flake8 ubuntupro
endif

override_dh_gencontrol:
Expand Down
15 changes: 13 additions & 2 deletions debian/ubuntu-advantage-tools.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ check_service_is_enabled() {
_RET=$(/usr/bin/python3 -c "
import os
import json
from uaclient.config import UAConfig
from ubuntupro.config import UAConfig
cfg = UAConfig()
status = cfg.read_cache('status-cache')
if status:
Expand Down Expand Up @@ -284,7 +284,7 @@ create_public_machine_token_file() {
# version of the machine-token file with all the
# sensitive data removed.
/usr/bin/python3 -c "
from uaclient.files import MachineTokenFile
from ubuntupro.files import MachineTokenFile
machine_token_file = MachineTokenFile()
content = machine_token_file.read()
machine_token_file.write(content)
Expand Down Expand Up @@ -493,6 +493,17 @@ case "$1" in
rename_gpg_keys
fi

if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "30~"; then
if [ "$VERSION_ID" = "16.04" ] \
|| [ "$VERSION_ID" = "18.04" ] \
|| [ "$VERSION_ID" = "20.04" ] \
|| [ "$VERSION_ID" = "22.04" ] \
|| [ "$VERSION_ID" = "23.04" ] \
|| [ "$VERSION_ID" = "23.10" ]; then
ln -s ubuntupro /usr/lib/python3/dist-packages/uaclient
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should do this in a pythonic way isntead like import *

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shuold test reverse deps agains this shim

fi
fi

if grep -q "^ua_config:" /etc/ubuntu-advantage/uaclient.conf; then
echo "Warning: uaclient.conf contains old ua_config field." >&2
echo " Please do the following:" >&2
Expand Down
2 changes: 1 addition & 1 deletion debian/ubuntu-advantage-tools.prerm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

remove_apt_files() {
/usr/bin/python3 -c '
from uaclient.apt import clean_apt_files
from ubuntupro.apt import clean_apt_files

clean_apt_files()
'
Expand Down
2 changes: 1 addition & 1 deletion features/api_full_auto_attach.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Feature: Full Auto-Attach Endpoint
"""
When I create the file `/tmp/full_auto_attach.py` with the following:
"""
from uaclient.api.u.pro.attach.auto.full_auto_attach.v1 import full_auto_attach, FullAutoAttachOptions
from ubuntupro.api.u.pro.attach.auto.full_auto_attach.v1 import full_auto_attach, FullAutoAttachOptions

full_auto_attach(FullAutoAttachOptions(enable=["esm-infra"]))
"""
Expand Down
8 changes: 4 additions & 4 deletions features/install_uninstall.feature
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ Feature: Pro Install and Uninstall related tests
When I run `apt update` with sudo
And I run `apt install python3-venv -y` with sudo
And I run `python3 -m venv env` with sudo
Then I verify that running `bash -c ". env/bin/activate && python3 -c 'import uaclient'"` `with sudo` exits `1`
Then I verify that running `bash -c ". env/bin/activate && python3 -c 'import ubuntupro'"` `with sudo` exits `1`
Then stderr matches regexp:
"""
No module named 'uaclient'
No module named 'ubuntupro'
"""
Then I verify that running `bash -c ". env/bin/activate && dpkg-reconfigure ubuntu-advantage-tools"` `with sudo` exits `0`

Expand All @@ -76,10 +76,10 @@ Feature: Pro Install and Uninstall related tests
"""
Python 3.10.0
"""
Then I verify that running `python3 -c "import uaclient"` `with sudo` exits `1`
Then I verify that running `python3 -c "import ubuntupro"` `with sudo` exits `1`
Then stderr matches regexp:
"""
No module named 'uaclient'
No module named 'ubuntupro'
"""
Then I verify that running `dpkg-reconfigure ubuntu-advantage-tools` `with sudo` exits `0`

Expand Down
4 changes: 2 additions & 2 deletions features/steps/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
)
from features.steps.shell import when_i_run_command
from features.util import SUT, process_template_vars
from uaclient import util
from uaclient.defaults import (
from ubuntupro import util
from ubuntupro.defaults import (
DEFAULT_CONFIG_FILE,
DEFAULT_PRIVATE_MACHINE_TOKEN_PATH,
)
Expand Down
2 changes: 1 addition & 1 deletion features/steps/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from features.steps.shell import when_i_run_command
from features.util import SUT, process_template_vars
from uaclient.defaults import DEFAULT_CONFIG_FILE
from ubuntupro.defaults import DEFAULT_CONFIG_FILE


def _get_file_contents(
Expand Down
2 changes: 1 addition & 1 deletion features/steps/magic_attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from behave import when

from features.steps.shell import when_i_run_command
from uaclient.util import DatetimeAwareJSONDecoder
from ubuntupro.util import DatetimeAwareJSONDecoder


@when("I initiate the magic attach flow")
Expand Down
4 changes: 2 additions & 2 deletions features/steps/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from features.steps.files import when_i_create_file_with_content
from features.steps.packages import when_i_apt_install
from features.steps.shell import when_i_run_command, when_i_run_shell_command
from uaclient.defaults import DEFAULT_CONFIG_FILE
from uaclient.util import DatetimeAwareJSONDecoder
from ubuntupro.defaults import DEFAULT_CONFIG_FILE
from ubuntupro.util import DatetimeAwareJSONDecoder

AUTOCOMPLETE_TEST_FILE = """\
#!/usr/bin/expect -f
Expand Down
2 changes: 1 addition & 1 deletion features/steps/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def then_stream_not_contains_substring(context, stream):

@then("I will see the uaclient version on stdout")
def then_i_will_see_the_uaclient_version_on_stdout(context):
python_import = "from uaclient.version import get_version"
python_import = "from ubuntupro.version import get_version"

cmd = "python3 -c '{}; print(get_version())'".format(python_import)

Expand Down
2 changes: 1 addition & 1 deletion features/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import yaml

from uaclient.system import get_dpkg_arch
from ubuntupro.system import get_dpkg_arch

SUT = "system-under-test"
LXC_PROPERTY_MAP = {
Expand Down
8 changes: 4 additions & 4 deletions lib/apt_news.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import logging
from datetime import datetime, timedelta, timezone

from uaclient import apt, defaults
from uaclient.apt_news import update_apt_news
from uaclient.config import UAConfig
from uaclient.daemon import setup_logging
from ubuntupro import apt, defaults
from ubuntupro.apt_news import update_apt_news
from ubuntupro.config import UAConfig
from ubuntupro.daemon import setup_logging


def main(cfg: UAConfig):
Expand Down
12 changes: 6 additions & 6 deletions lib/auto_attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
import logging
import sys

from uaclient import defaults, http, messages, system
from uaclient.api.exceptions import (
from ubuntupro import defaults, http, messages, system
from ubuntupro.api.exceptions import (
AlreadyAttachedError,
AutoAttachDisabledError,
EntitlementsNotEnabledError,
)
from uaclient.api.u.pro.attach.auto.full_auto_attach.v1 import (
from ubuntupro.api.u.pro.attach.auto.full_auto_attach.v1 import (
FullAutoAttachOptions,
full_auto_attach,
)
from uaclient.config import UAConfig
from uaclient.daemon import (
from ubuntupro.config import UAConfig
from ubuntupro.daemon import (
AUTO_ATTACH_STATUS_MOTD_FILE,
retry_auto_attach,
setup_logging,
)
from uaclient.files import state_files
from ubuntupro.files import state_files

LOG = logging.getLogger("ubuntupro.lib.auto_attach")

Expand Down
8 changes: 4 additions & 4 deletions lib/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from systemd.daemon import notify # type: ignore

from uaclient import defaults, http
from uaclient.config import UAConfig
from uaclient.daemon import (
from ubuntupro import defaults, http
from ubuntupro.config import UAConfig
from ubuntupro.daemon import (
poll_for_pro_license,
retry_auto_attach,
setup_logging,
Expand All @@ -26,7 +26,7 @@ def main() -> int:
setup_logging(
logging.INFO, logging.DEBUG, log_file=cfg.daemon_log_file, logger=LOG
)
# used with loggers in uaclient.daemon
# used with loggers in ubuntupro.daemon
daemon_logger = logging.getLogger("ubuntupro.daemon")
setup_logging(
logging.INFO,
Expand Down
8 changes: 4 additions & 4 deletions lib/esm_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import logging

from uaclient import defaults
from uaclient.apt import update_esm_caches
from uaclient.config import UAConfig
from uaclient.daemon import setup_logging
from ubuntupro import defaults
from ubuntupro.apt import update_esm_caches
from ubuntupro.config import UAConfig
from ubuntupro.daemon import setup_logging

LOG = logging.getLogger("ubuntupro.lib.esm_cache")

Expand Down
4 changes: 2 additions & 2 deletions lib/migrate_user_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import os
import sys

from uaclient import defaults, messages
from uaclient.yaml import safe_dump, safe_load
from ubuntupro import defaults, messages
from ubuntupro.yaml import safe_dump, safe_load

UACLIENT_CONF_BACKUP_PATH = (
"/etc/ubuntu-advantage/uaclient.conf.preinst-backup"
Expand Down
4 changes: 2 additions & 2 deletions lib/patch_status_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import json
import logging

from uaclient import system, util
from uaclient.cli import setup_logging
from ubuntupro import system, util
from ubuntupro.cli import setup_logging

LOG = logging.getLogger("ubuntupro.lib.patch_status_json")

Expand Down
14 changes: 7 additions & 7 deletions lib/reboot_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"""
Run configuration operations during system boot.

Some uaclient operations cannot be fully completed by running a single
command. For example, when upgrading uaclient from trusty to xenial,
Some ubuntupro operations cannot be fully completed by running a single
command. For example, when upgrading ubuntupro from trusty to xenial,
we may have a livepatch change in the contract, allowing livepatch to be
enabled on xenial. However, during the upgrade we cannot install livepatch on
the system because the running kernel version will not be updated until reboot.
Expand All @@ -17,7 +17,7 @@
import logging
import sys

from uaclient import (
from ubuntupro import (
config,
contract,
defaults,
Expand All @@ -27,10 +27,10 @@
messages,
upgrade_lts_contract,
)
from uaclient.api.u.pro.status.is_attached.v1 import _is_attached
from uaclient.cli import setup_logging
from uaclient.entitlements.fips import FIPSEntitlement
from uaclient.files import notices, state_files
from ubuntupro.api.u.pro.status.is_attached.v1 import _is_attached
from ubuntupro.cli import setup_logging
from ubuntupro.entitlements.fips import FIPSEntitlement
from ubuntupro.files import notices, state_files

LOG = logging.getLogger("ubuntupro.lib.reboot_cmds")

Expand Down
16 changes: 8 additions & 8 deletions lib/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
from datetime import datetime, timedelta, timezone
from typing import Callable, Optional

from uaclient import defaults, http
from uaclient.cli import setup_logging
from uaclient.config import UAConfig
from uaclient.exceptions import InvalidFileFormatError
from uaclient.files.state_files import (
from ubuntupro import defaults, http
from ubuntupro.cli import setup_logging
from ubuntupro.config import UAConfig
from ubuntupro.exceptions import InvalidFileFormatError
from ubuntupro.files.state_files import (
AllTimerJobsState,
TimerJobState,
timer_jobs_state_file,
)
from uaclient.timer.metering import metering_enabled_resources
from uaclient.timer.update_contract_info import update_contract_info
from uaclient.timer.update_messaging import update_motd_messages
from ubuntupro.timer.metering import metering_enabled_resources
from ubuntupro.timer.update_contract_info import update_contract_info
from ubuntupro.timer.update_messaging import update_motd_messages

LOG = logging.getLogger("ubuntupro.lib.timer")
UPDATE_MESSAGING_INTERVAL = 21600 # 6 hours
Expand Down
8 changes: 4 additions & 4 deletions lib/upgrade_lts_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

"""
This script is called after running do-release-upgrade in a machine.
See uaclient/upgrade_lts_contract.py for more details.
See ubuntupro/upgrade_lts_contract.py for more details.
"""

import logging

from uaclient import http, upgrade_lts_contract
from uaclient.cli import setup_logging
from uaclient.config import UAConfig
from ubuntupro import http, upgrade_lts_contract
from ubuntupro.cli import setup_logging
from ubuntupro.config import UAConfig

if __name__ == "__main__":
setup_logging(logging.INFO, logging.DEBUG)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ explicit_package_bases = "true"
[[tool.mypy.overrides]]
module = [
"*.tests.*",
"uaclient.conftest",
"uaclient.testing.*",
"ubuntupro.conftest",
"ubuntupro.testing.*",
]
ignore_errors = "true"

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import setuptools

from uaclient import defaults
from ubuntupro import defaults

NAME = "ubuntu-advantage-tools"

Expand Down Expand Up @@ -76,8 +76,8 @@ def _get_data_files():
url="https://ubuntu.com/support",
entry_points={
"console_scripts": [
"ubuntu-advantage=uaclient.cli:main",
"ua=uaclient.cli:main",
"ubuntu-advantage=ubuntupro.cli:main",
"ua=ubuntupro.cli:main",
]
},
)
2 changes: 1 addition & 1 deletion tools/check-versions-are-consistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

sys.path.insert(0, ".")

from uaclient.version import __VERSION__
from ubuntupro.version import __VERSION__

python_version = __VERSION__
changelog_version = (
Expand Down
Loading
Loading