Skip to content
Merged
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
2 changes: 2 additions & 0 deletions ovs/extensions/generic/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ovs_extensions.caching.decorators import cache_file
from ovs_extensions.generic.configuration import Configuration as _Configuration, ConnectionException, NotFoundException
from ovs_extensions.constants.config import CONFIG_STORE_LOCATION
from ovs.extensions.generic.system import System


class Configuration(_Configuration):
Expand Down Expand Up @@ -122,6 +123,7 @@ def initialize(cls, external_config=None, logging_target=None):
base_cfg['messagequeue'][key] = value
for key, value in base_cfg.iteritems():
cls.set('/ovs/framework/{0}'.format(key), value, raw=False)
cls.register_usage(System.get_component_identifier())

@classmethod
@cache_file(CONFIG_STORE_LOCATION)
Expand Down
30 changes: 10 additions & 20 deletions ovs/extensions/generic/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import os
from ovs_extensions.caching.decorators import cache_file
from ovs_extensions.generic.system import System as _System
from ovs.extensions.packages.packagefactory import PackageFactory


class System(_System):
Expand All @@ -30,7 +29,6 @@ class System(_System):
"""

OVS_ID_FILE = '/etc/openvstorage_id'
RELEASE_NAME_FILE = '/opt/OpenvStorage/config/release_name'
_machine_id = {}

def __init__(self):
Expand Down Expand Up @@ -60,24 +58,6 @@ def read_my_machine_id(cls):
with open(cls.OVS_ID_FILE, 'r') as the_file:
return the_file.read().strip()

@classmethod
def get_release_name(cls, client=None):
"""
Retrieve the release name
:param client: Client on which to retrieve the release name
:type client: ovs_extensions.generic.sshclient.SSHClient
:return: The name of the release
:rtype: str
"""
try:
if client is not None:
return client.run(['cat', cls.RELEASE_NAME_FILE]).strip()
with open(cls.RELEASE_NAME_FILE, 'r') as the_file:
return the_file.read().strip()
except:
manager = PackageFactory.get_manager()
return manager.get_release_name()

@classmethod
def get_my_storagerouter(cls):
"""
Expand All @@ -90,3 +70,13 @@ def get_my_storagerouter(cls):
if storagerouter is None:
raise RuntimeError('Could not find the local StorageRouter')
return storagerouter

@staticmethod
def get_component_identifier():
# type: () -> str
"""
Retrieve the identifier of the component
:return: The ID of the component
:rtype: str
"""
return 'framework'
20 changes: 20 additions & 0 deletions ovs/extensions/packages/packagefactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class PackageFactory(_PackageFactory):
"""
Factory class returning specialized classes
"""
# Allow the user to add a custom release name
RELEASE_NAME_FILE = '/opt/OpenvStorage/config/release_name'
_logger = Logger('extensions-packages')

def __init__(self):
Expand Down Expand Up @@ -91,3 +93,21 @@ def get_package_info(cls):
'mutually_exclusive': {cls.PKG_VOLDRV_BASE, cls.PKG_VOLDRV_SERVER}}
else:
raise ValueError('Unsupported edition found: "{0}"'.format(edition))

@classmethod
def get_release_name(cls, client=None):
"""
Retrieve the release name
:param client: Client on which to retrieve the release name
:type client: ovs_extensions.generic.sshclient.SSHClient
:return: The name of the release
:rtype: str
"""
try:
if client is not None:
return client.run(['cat', cls.RELEASE_NAME_FILE]).strip()
with open(cls.RELEASE_NAME_FILE, 'r') as the_file:
return the_file.read().strip()
except:
manager = cls.get_manager()
return manager.get_release_name()
3 changes: 2 additions & 1 deletion webapps/api/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from ovs.extensions.generic.configuration import Configuration
from ovs.extensions.generic.logger import Logger
from ovs.extensions.generic.system import System
from ovs.extensions.packages.packagefactory import PackageFactory
from ovs.extensions.storage.volatilefactory import VolatileFactory


Expand Down Expand Up @@ -65,7 +66,7 @@ def get(self, request, *args, **kwargs):
try:
# Gather release name
try:
data['release']['name'] = System.get_release_name()
data['release']['name'] = PackageFactory.get_release_name()
except:
MetadataView._logger.exception('Could not load release name')

Expand Down