Skip to content

Commit

Permalink
Merge pull request #186 from openvstorage/configuration_create_keys
Browse files Browse the repository at this point in the history
Registration keys can be generated for all storagerouters during the update
  • Loading branch information
JeffreyDevloo authored Sep 14, 2018
2 parents c8ee004 + 80814ae commit 436f63a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions src/generic/configuration/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,18 +512,20 @@ def safely_store(cls, callback, max_retries=20):
return return_value

@classmethod
def register_usage(cls, component_identifier):
# type: (str) -> List[str]
def register_usage(cls, component_identifier, registration_key=None):
# type: (str, str) -> List[str]
"""
Registers that the component is using configuration management
When sharing the same configuration management for multiple processes, these registrations can be used to determine
if the configuration access can be wiped on the node
:param component_identifier: Identifier of the component
:type component_identifier: str
:param registration_key: Key to register the component under
:type registration_key: str
:return: The currently registered users
:rtype: List[str]
"""
registration_key = cls.get_registration_key()
registration_key = registration_key or cls.get_registration_key()

def _register_user_callback():
registered_applications = cls.get(registration_key, default=None)
Expand All @@ -539,7 +541,18 @@ def get_registration_key(cls):
:return: The registration key
:rtype: str
"""
return COMPONENTS_KEY.format(System.get_my_machine_id())
return cls.generate_registration_key(System.get_my_machine_id())

@classmethod
def generate_registration_key(cls, identifier):
# type: (str) -> str
"""
Generate a registration key with a given identifier
:param identifier: Identifier for the config key
:type identifier: str
:return:
"""
return COMPONENTS_KEY.format(identifier)

@classmethod
def unregister_usage(cls, component_identifier):
Expand Down
2 changes: 1 addition & 1 deletion src/services/servicefactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def get_service_update_versions(cls, client, service_name, binary_versions, pack
continue
pkg_name = version.strip().split('=')[0]
running_version = version.strip().split('=')[1]
if (package_name is None or pkg_name == package_name) and running_version is not None:
if (package_name is None or pkg_name == package_name) and running_version:
if LooseVersion(running_version) < binary_versions[pkg_name]:
return {'installed': running_version,
'candidate': str(binary_versions[pkg_name])}
Expand Down

0 comments on commit 436f63a

Please sign in to comment.