Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Anja Strunk <[email protected]>
  • Loading branch information
anjastrunk committed Apr 26, 2024
1 parent c03e680 commit a216f09
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __pycache__/
devops/logs/
devops/plugins/
node_modules
.gx-credentials/
*.tar.gz
# Make sure credentials not push to the repo
os_secret
Expand Down
2 changes: 1 addition & 1 deletion config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ wallet:
path: /etc/gaia-x/wallet/

Gaia-X:
# DO NOT change, unless you will override default settings for Gaia-X mandatory attributes
# DO NOT change these values, unless you want to override default settings for Gaia-X mandatory attributes
software resources:
Alpine Linux:
copyright owner: "Alpine Linux"
Expand Down
2 changes: 1 addition & 1 deletion cli.py → generator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def openstack(cloud, timeout, config):
os_cloud = OsCloud(conn, Config(config_dict))

# init wallet
if config_dict["wallet"] == const.CONFIG_WALLETS:
if config_dict["wallet"] == const.CONFIG_WALLET:
wallet = FileSystemWallet(config_dict["wallet"])

# run discovery
Expand Down
25 changes: 13 additions & 12 deletions generator/common/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,31 @@
Constants used by SCS GX Credential Generator.
"""

# general configuration keys
DEFAULT_RESOURCE_POLICY = "default: allow intent"
DEFAULT_FIRMWARE_TYPE = "other"
#DEFAULT_FIRMWARE_TYPE = "other"
DEFAULT_WATCHDOG_ACTION = "none"
CONFIG_FILE = "config/config.yaml"
CONFIG_WALLET = "wallet"

# Wallet keys
CONFIG_FILESYSTEM_WALLET = "filesystem"
CONFIG_XFSC_WALLET = "xfsc"

# Metrics
UNIT_MB = "https://qudt.org/vocab/unit/MegaBYTE"
UNIT_GB = "https://qudt.org/vocab/unit/GigaBYTE"
UNIT_GHZ = "https://qudt.org/vocab/unit/GigaHZ"

# Config keys for DID management
CONFIG_DID = "DIDs"
CONFIG_CPS_DID = "csp_did"
CONFIG_IAAS_DID = "iaas_did"
CONFIG_KAAS_DID = "k8s_did"
CONFIG_GAX = "Gaia-X"
CONFIG_SOFTWARE = "software resources"


CONFIG_VM_IMAGE = "vm image"
CONFIG_RESOURCE_POLICY = "resource policy"
CONFIG_LICENSE = "license"
Expand All @@ -28,10 +38,9 @@
CONFIG_DEFAULT = "default"
CONFIG_CLOUD_RESOURCES = "cloud resources:"

CONFIG_FILESYSTEM_WALLET = "filesystem"
CONFIG_XFSC_WALLET = "xfsc"


# Operating System types offered by Gaia-X
CONFIG_OS_ALP = "Alpine Linux"
CONFIG_OS_ARCH = "Arch Linux"
CONFIG_OS_CENTOS = "CentOS Linux"
Expand All @@ -57,6 +66,7 @@
CONFIG_OS_CIRROS = "CirrOS"
CONFIG_OS_ALMA_LINUX = "AlmaLinux"

# Hypervisor types offered by Gaia-X
CONFIG_HV_KVM = "KVM"
CONFIG_HV_QUEMU = "quemu"
CONFIG_HV_XEN = "Xen"
Expand All @@ -65,12 +75,3 @@
CONFIG_HV_VMW = "vmware"
CONFIG_HV_HYV = "hyper-v"

CONFIG_HV_KVM = "KVM"
CONFIG_HV_QUEMU = "quemu"
CONFIG_HV_XEN = "Xen"
CONFIG_HV_ESXI = "ESXi"
CONFIG_HV_CH = "Cloud Hypervisor"
CONFIG_HV_VMW = "vmware"
CONFIG_HV_HYV = "hyper-v"

CONFIG_FILE = "config/config.yaml"
28 changes: 14 additions & 14 deletions generator/discovery/openstack/vm_images_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _get_operation_system(self, os_image: OS_Image) -> OperatingSystem:
resourcePolicy=self.conf.get_resource_policy(const.CONFIG_OS_ARCH),
copyrightOwnedBy=self.conf.get_copyright_owner(const.CONFIG_OS_ARCH),
license=self._get_license_list(
self.self.conf.get_license(const.CONFIG_OS_ARCH)
self.conf.get_license(const.CONFIG_OS_ARCH)
),
)
elif os_image.os_distro.lower() == "centos":
Expand Down Expand Up @@ -430,7 +430,7 @@ def _get_operation_system(self, os_image: OS_Image) -> OperatingSystem:
const.CONFIG_OS_NETBSD
),
license=self._get_license_list(
self.self.conf.get_license(const.CONFIG_OS_NETBSD)
self.conf.get_license(const.CONFIG_OS_NETBSD)
),
)
elif os_image.os_distro.lower() == "netware":
Expand Down Expand Up @@ -491,13 +491,12 @@ def _get_operation_system(self, os_image: OS_Image) -> OperatingSystem:
return OperatingSystem(
version=os_image.os_version,
osDistribution=const.CONFIG_OS_SUSE,
resourcePolicy=self._get_resource_policy_for_os(const.CONFIG_OS_SUSE),
copyrightOwnedBy=self._get_copyright_owner_for_os(
resourcePolicy=self.conf.get_resource_policy(const.CONFIG_OS_SUSE),
copyrightOwnedBy=self.conf.get_copyright_owner(
const.CONFIG_OS_OPEN_SUSE
),
license=self._get_license_list(
self._get_license_for_os(const.CONFIG_OS_SUSE)
),
license=self._get_license_list( self.conf.get_license(const.CONFIG_OS_SUSE)
)
)
elif os_image.os_distro.lower() == "rocky":
return OperatingSystem(
Expand Down Expand Up @@ -573,23 +572,24 @@ def _get_operation_system(self, os_image: OS_Image) -> OperatingSystem:
elif os_image.os_distro.lower() == "almalinux":
return OperatingSystem(
version=os_image.os_version,
osDistribution=const.CONFIG_OS_ALMALINUX,
resourcePolicy=self.conf.get_resource_policy(const.CONFIG_OS_ALMALINUX
osDistribution=const.CONFIG_OS_ALMA_LINUX,
resourcePolicy=self.conf.get_resource_policy(const.CONFIG_OS_ALMA_LINUX
),
copyrightOwnedBy=self.conf.get_copyright_owner(
const.CONFIG_OS_ALMALINUX
const.CONFIG_OS_ALMA_LINUX
),
license=self._get_license_list(
self.conf.get_license(const.CONFIG_OS_ALMA_LINUX)
),
)
)
elif os_image.os_distro.lower() == "alpinelinux":
return OperatingSystem(
version=os_image.os_version,
osDistribution=const.CONFIG_OS_ALP,
resourcePolicy=self._get_resource_policy_for_os(const.CONFIG_OS_ALP),
copyrightOwnedBy=self._get_copyright_owner_for_os(const.CONFIG_OS_ALP),
resourcePolicy=self.conf.get_resource_policy(const.CONFIG_OS_ALP),
copyrightOwnedBy=self.conf.get_copyright_owner(const.CONFIG_OS_ALP),
license=self._get_license_list(
self.conf.get_license(const.CONFIG_OS_ALMALINUX)
self.conf.get_license(const.CONFIG_OS_ALP)
),
)
else:
Expand Down
1 change: 1 addition & 0 deletions generator/wallet/filesystem_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def _filter_graph_by_subject(self, graph: Graph, subject: str) -> Graph:
for s, p, o in graph:
if s == subject:
# geht das auch mit einer Sparql Anfrage
pass



Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from openstack.compute.v2.flavor import Flavor as OS_Flavor
from openstack.image.v2.image import Image as OS_Image

import cli
from generator import cli
from generator.common import const
from tests.common import MockConnection, get_absolute_path

Expand Down

0 comments on commit a216f09

Please sign in to comment.