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
9 changes: 6 additions & 3 deletions extensions/business/container_apps/container_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ def _container_run(self):

# TODO: check if this is a potential security issue (host is a container itself but we need to make sure)
host_ip = self._setup_dynamic_env_var_host_ip()
cmd += ["-e", f"EE_HOST_ID={host_ip}"]
cmd += ["-e", f"EE_CHAINSTORE_API_URL={self._setup_dynamic_env_var_host_ip()}:31234"]
cmd += ["-e", f"EE_R1FS_API_URL={self._setup_dynamic_env_var_host_ip()}:31235"]
cmd += ["-e", f"EE_HOST_IP={host_ip}"]
cmd += ["-e", f"EE_CHAINSTORE_API_URL=http://{self._setup_dynamic_env_var_host_ip()}:31234"]
cmd += ["-e", f"EE_R1FS_API_URL=http://{self._setup_dynamic_env_var_host_ip()}:31235"]

chainstore_peers = getattr(self, 'cfg_chainstore_peers', [])
cmd += ["-e", f"EE_CHAINSTORE_PEERS={chainstore_peers}"]


# Volume mounts
Expand Down
37 changes: 24 additions & 13 deletions extensions/business/cstore/cstore_manager_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

__VER__ = '0.2.2'

CHAINSTORE_MANAGER_API_PLUGIN_DEBUG = True

_CONFIG = {
**BasePlugin.CONFIG,
Expand All @@ -12,7 +11,8 @@
'ASSETS' : 'nothing', # TODO: this should not be required in future

'CSTORE_VERBOSE' : 11,


'DEBUG': True,

'VALIDATION_RULES': {
**BasePlugin.CONFIG['VALIDATION_RULES'],
Expand Down Expand Up @@ -79,28 +79,33 @@ def get_status(self): # /get_status
return data

@BasePlugin.endpoint(method="post", require_token=False)
def set(self, key: str, value: str):
def set(self, key: str, value: str, chainstore_peers: list = None):
"""
Set a key-value pair in the chainstore.

Args:
key (str): The key to store the value under
value (str): The value to store

chainstore_peers (list): Extra chainstore peers

Returns:
boolean: The result of the write operation
"""
# Log request
if chainstore_peers is None:
chainstore_peers = []
request_data = {
'key': key,
'value': value
'value': value,
'chainstore_peers': chainstore_peers
}
self._log_request_response("SET", request_data=request_data)

write_result = self.chainstore_set(
key=key,
value=value,
debug=CHAINSTORE_MANAGER_API_PLUGIN_DEBUG
debug=self.cfg_debug,
extra_peers=chainstore_peers,
)

# Log response
Expand All @@ -125,7 +130,7 @@ def get(self, key: str):
}
self._log_request_response("GET", request_data=request_data)

value = self.chainstore_get(key=key, debug=CHAINSTORE_MANAGER_API_PLUGIN_DEBUG)
value = self.chainstore_get(key=key, debug=self.cfg_debug)

# Log response
self._log_request_response("GET", response_data=value)
Expand All @@ -134,31 +139,37 @@ def get(self, key: str):


@BasePlugin.endpoint(method="post", require_token=False)
def hset(self, hkey: str, key: str, value: str):
def hset(self, hkey: str, key: str, value: str, chainstore_peers: list = None):
"""
Set a field-value pair within a hash in the chainstore.

Args:
hkey (str): The hash key (outer key)
key (str): The field key within the hash
value (str): The value to store for the field

chainstore_peers (list): Extra chainstore peers

Returns:
boolean: The result of the write operation
"""
# Log request
if chainstore_peers is None:
chainstore_peers = []

request_data = {
'hkey': hkey,
'key': key,
'value': value
'value': value,
'chainstore_peers': chainstore_peers
}
self._log_request_response("HSET", request_data=request_data)

write_result = self.chainstore_hset(
hkey=hkey,
key=key,
value=value,
debug=CHAINSTORE_MANAGER_API_PLUGIN_DEBUG
debug=self.cfg_debug,
extra_peers=chainstore_peers,
)

# Log response
Expand Down Expand Up @@ -186,7 +197,7 @@ def hget(self, hkey: str, key: str):
}
self._log_request_response("HGET", request_data=request_data)

value = self.chainstore_hget(hkey=hkey, key=key, debug=CHAINSTORE_MANAGER_API_PLUGIN_DEBUG)
value = self.chainstore_hget(hkey=hkey, key=key, debug=self.cfg_debug)

# Log response
self._log_request_response("HGET", response_data=value)
Expand All @@ -211,7 +222,7 @@ def hgetall(self, hkey: str):
}
self._log_request_response("HGETALL", request_data=request_data)

value = self.chainstore_hgetall(hkey=hkey, debug=CHAINSTORE_MANAGER_API_PLUGIN_DEBUG)
value = self.chainstore_hgetall(hkey=hkey, debug=self.cfg_debug)

# Log response
self._log_request_response("HGETALL", response_data=value)
Expand Down
2 changes: 1 addition & 1 deletion ver.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__VER__ = '2.9.260'
__VER__ = '2.9.270'