Skip to content

Commit

Permalink
Merge pull request #765 from mulkieran/develop-2.4.0-2.4.1
Browse files Browse the repository at this point in the history
Develop 2.4.0 2.4.1
  • Loading branch information
mulkieran authored May 15, 2021
2 parents 50871ff + 4dfca6c commit 672734a
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
push:
branches:
- master
- develop-2.3.0
- develop-2.4.0
pull_request:
branches:
- master
- develop-2.3.0
- develop-2.4.0

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
23 changes: 23 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
stratis-cli 2.4.1
=================

- In blockdev listing, expose physical path if different from metadata path:
https://github.com/stratis-storage/stratis-cli/issues/754
https://github.com/stratis-storage/stratis-cli/pull/755

- Add new report key, managed_objects_report,
remove script introduced by PR#756:
https://github.com/stratis-storage/stratis-cli/issues/761
https://github.com/stratis-storage/stratis-cli/pull/762

- Add a small script to output GetManagedObjects() result in JSON format:
https://github.com/stratis-storage/stratis-cli/pull/756

- Tidies and Maintenance:
https://github.com/stratis-storage/stratis-cli/pull/760
https://github.com/stratis-storage/stratis-cli/pull/757
https://github.com/stratis-storage/stratis-cli/pull/753


stratis-cli 2.4.0
=================
Required stratisd version: 2.4.0
Expand Down Expand Up @@ -50,6 +71,8 @@ YAML linter: yamllint (1.26.0)
https://github.com/stratis-storage/stratis-cli/pull/714

- Tidies and Maintenance:
https://github.com/stratis-storage/stratis-cli/pull/752
https://github.com/stratis-storage/stratis-cli/pull/751
https://github.com/stratis-storage/stratis-cli/pull/742
https://github.com/stratis-storage/stratis-cli/pull/740
https://github.com/stratis-storage/stratis-cli/pull/739
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ UNITTEST_OPTS = --verbose
lint:
./check.py check.py
./check.py setup.py
./check.py developer_tools
./check.py developer_tools/update_introspection_data
./check.py bin/stratis
./check.py src/stratis_cli
./check.py tests/whitebox
Expand All @@ -16,7 +16,7 @@ fmt:

.PHONY: fmt-travis
fmt-travis:
isort --recursive --diff --check-only check.py setup.py bin/stratis src tests
isort --recursive --diff --check-only check.py setup.py bin/stratis developer_tools src tests
black ./bin/stratis ./developer_tools/update_introspection_data . --check

PYREVERSE_OPTS = --output=pdf
Expand Down
2 changes: 1 addition & 1 deletion check.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"--disable=I",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
],
"developer_tools": [
"developer_tools/update_introspection_data": [
"--reports=no",
"--disable=I",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
Expand Down
6 changes: 4 additions & 2 deletions developer_tools/update_introspection_data
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Update Stratis introspection data.
"""

# isort: STDLIB
import sys
import xml.etree.ElementTree as ET

# isort: THIRDPARTY
Expand Down Expand Up @@ -71,6 +72,7 @@ _MANAGER_IFACE = "org.storage.stratis2.Manager.r1"
_POOL_IFACE = "org.storage.stratis2.pool.r1"
_TIMEOUT = 120000

# pylint: disable=invalid-name
Introspectable = make_class(
"Introspectable", ET.fromstring(SPECS[_INTROSPECTABLE_IFACE]), _TIMEOUT
)
Expand Down Expand Up @@ -141,7 +143,7 @@ def setup_minimal_object_set(bus):
)

if return_code != 0:
exit(return_msg)
sys.exit(return_msg)

pool_proxy = bus.get_object(_SERVICE, pool_object_path, introspect=False)

Expand All @@ -155,7 +157,7 @@ def setup_minimal_object_set(bus):
)

if return_code != 0:
exit(return_msg)
sys.exit(return_msg)

filesystem_object_path = filesystems[0][0]
filesystem_proxy = bus.get_object(
Expand Down
9 changes: 7 additions & 2 deletions docs/stratis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,14 @@ FIELDS for stratis blockdev list
Pool Name::
The name of the pool using the block device.
Device Node::
The device node of the block device.
The device node of the block device. A second device node will
be displayed in parentheses if the block device is encrypted. This
device node is the device node of the associated dm-crypt device.
Physical Size::
The size of the device.
The total size of the device on which stratisd places Stratis
metadata. If the device is encrypted, this size will be slightly
smaller than the total size of the device specified by the user; it
will be the size of the associated dm-crypt device.
Tier::
The data tier type ("Data" or "Cache")

Expand Down
23 changes: 22 additions & 1 deletion src/stratis_cli/_actions/_physical.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,31 @@ def total_physical_size(props):
TABLE_FAILURE_STRING,
)

def paths(modev):
"""
Return <physical_path> (<metadata_path>) if they are different,
otherwise, just <metadata_path>.
physical_path D-Bus Property key is PhysicalPath
metadata_path D-Bus Property key is Devnode
:param modev: object containing D-Bus properties
:returns: the string to print
:rtype: str
"""
metadata_path = modev.Devnode()
physical_path = modev.PhysicalPath()

return (
metadata_path
if metadata_path == physical_path
else "%s (%s)" % (physical_path, metadata_path)
)

tables = [
[
path_to_name[modev.Pool()],
modev.Devnode(),
paths(modev),
total_physical_size(props),
BLOCK_DEV_TIER_TO_NAME(modev.Tier(), True),
]
Expand Down
46 changes: 31 additions & 15 deletions src/stratis_cli/_actions/_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# isort: STDLIB
import json
import os
import sys
from getpass import getpass

from .._errors import (
Expand All @@ -34,6 +35,7 @@
CLEVIS_KEY_URL,
CLEVIS_PIN_TANG,
CLEVIS_PIN_TPM2,
ReportKey,
StratisdErrors,
)
from ._connection import get_object
Expand Down Expand Up @@ -113,32 +115,46 @@ def get_report(namespace):
:raises StratisCliEngineError:
"""

# pylint: disable=import-outside-toplevel
if namespace.report_name == "engine_state_report":
if namespace.report_name == str(ReportKey.MANAGED_OBJECTS):

from ._data import Manager
from ._data import ObjectManager

(report, return_code, message) = Manager.Methods.EngineStateReport(
json_report = ObjectManager.Methods.GetManagedObjects(
get_object(TOP_OBJECT), {}
)

else:

from ._data import Report
if namespace.report_name == str(ReportKey.ENGINE_STATE):

(report, return_code, message) = Report.Methods.GetReport(
get_object(TOP_OBJECT), {"name": namespace.report_name}
)
from ._data import Manager

# The only reason that stratisd has for returning an error code is
# if the report name is unrecognizes. However, the parser restricts
# the list # of names to only the ones that stratisd recognizes, so
# this branch can only be taken due to an unexpected bug in stratisd.
if return_code != StratisdErrors.OK: # pragma: no cover
raise StratisCliEngineError(return_code, message)
(report, return_code, message) = Manager.Methods.EngineStateReport(
get_object(TOP_OBJECT), {}
)

else:

from ._data import Report

(report, return_code, message) = Report.Methods.GetReport(
get_object(TOP_OBJECT), {"name": namespace.report_name}
)

# The only reason that stratisd has for returning an error code is
# if the report name is unrecognized. However, the parser restricts
# the list of names to only the ones that stratisd recognizes, so
# this branch can only be taken due to an unexpected bug in
# stratisd.
if return_code != StratisdErrors.OK: # pragma: no cover
raise StratisCliEngineError(return_code, message)

json_report = json.loads(report)

json_report = json.loads(report)
print(json.dumps(json_report, indent=4, sort_keys=True))
json.dump(json_report, sys.stdout, indent=4, sort_keys=True)
print(file=sys.stdout)

@staticmethod
def set_key(namespace):
Expand Down
3 changes: 2 additions & 1 deletion src/stratis_cli/_parser/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
TopActions,
check_stratisd_version,
)
from .._stratisd_constants import ReportKey
from .._version import __version__
from ._key import KEY_SUBCMDS
from ._logical import LOGICAL_SUBCMDS
Expand Down Expand Up @@ -147,7 +148,7 @@ def wrapped_func(*args):
type=str,
help=("Name of the report to display"),
nargs="?",
choices=["engine_state_report", "errored_pool_report"],
choices=[str(x) for x in list(ReportKey)],
),
)
],
Expand Down
17 changes: 17 additions & 0 deletions src/stratis_cli/_stratisd_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,20 @@ def __str__(self):
CLEVIS_PIN_TPM2 = "tpm2"
CLEVIS_KEY_THP = "thp"
CLEVIS_KEY_URL = "url"


class ReportKey(Enum):
"""
Report identifiers.
Note: "managed_objects_report" is not a key recognized by stratisd.
However, since the other constants are, and they are all used together,
this type is defined with the other stratisd constants.
"""

ENGINE_STATE = "engine_state_report"
ERRORED_POOL = "errored_pool_report"
MANAGED_OBJECTS = "managed_objects_report"

def __str__(self):
return self.value
2 changes: 1 addition & 1 deletion src/stratis_cli/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
.. moduleauthor:: mulhern <[email protected]>
"""

__version_info__ = (2, 3, 0)
__version_info__ = (2, 4, 1)
__version__ = ".".join(str(x) for x in __version_info__)
11 changes: 9 additions & 2 deletions tests/whitebox/integration/report/test_get_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# isort: LOCAL
from stratis_cli import StratisCliErrorCodes
from stratis_cli._stratisd_constants import ReportKey

from .._misc import TEST_RUNNER, SimTestCase

Expand All @@ -34,7 +35,7 @@ def test_report(self):
"""
Test getting errored pool report.
"""
TEST_RUNNER(self._MENU + ["errored_pool_report"])
TEST_RUNNER(self._MENU + [str(ReportKey.ERRORED_POOL)])

def test_report_no_name(self):
"""
Expand All @@ -46,4 +47,10 @@ def test_engine_state_report(self):
"""
Test getting engine state report.
"""
TEST_RUNNER(self._MENU + ["engine_state_report"])
TEST_RUNNER(self._MENU + [str(ReportKey.ENGINE_STATE)])

def test_managed_objects_report(self):
"""
Test getting managed_objects report.
"""
TEST_RUNNER(self._MENU + [str(ReportKey.MANAGED_OBJECTS)])

0 comments on commit 672734a

Please sign in to comment.