Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit f74fc4b

Browse files
Stefan WitschelStefan Witschel
authored andcommitted
Fix for RAL Bug + Device.id not recognized
1 parent 4106d79 commit f74fc4b

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

c8ydm/agentmodules/remote_access_listener.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def handleOperation(self, message):
5252
Exception: Error when handling the operation
5353
"""
5454
try:
55-
#self.logger.debug(
56-
# f'Handling Cloud Remote Access operation: listener={__name__}, message={message}')
55+
self.logger.debug(
56+
f'Handling Cloud Remote Access operation: listener={__name__}, message={message}')
5757

5858
if message.messageId == self.remote_access_default_template or message.messageId == self.remote_access_op_template:
5959
self._set_executing()
@@ -72,14 +72,19 @@ def _proxy_connect(self, message):
7272
tcp_host = message.values[1]
7373
tcp_port = int(message.values[2])
7474
connection_key = message.values[3]
75-
7675
config = self.agent.configuration
77-
credentials = config.getCredentials()
78-
79-
token = self.agent.token
80-
tenantuser = credentials[0]+'/'+ credentials[1]
81-
password = credentials[2]
82-
76+
tenantuser = None
77+
password = None
78+
token = None
79+
80+
if self.agent.token:
81+
token = self.agent.token
82+
self.logger.info(f'RAL Token received: {token}')
83+
else:
84+
credentials = config.getCredentials()
85+
tenantuser = credentials[0]+'/'+ credentials[1]
86+
password = credentials[2]
87+
8388
if token is None and tenantuser is None and password is None:
8489
raise WebSocketFailureException(
8590
'OAuth Token or tenantuser and password must be provided!')

c8ydm/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def start():
107107

108108
containerId = None
109109
serial = None
110-
110+
111111
if serial == None:
112112
logging.debug(f'Serial not proviced. Fetching from system...')
113113
try:
@@ -134,8 +134,8 @@ def start():
134134
logging.info(f'Serial: {serial}')
135135

136136
credentials = config.getCredentials()
137-
logging.debug('Credentials:')
138-
logging.debug(credentials)
137+
#logging.debug('Credentials:')
138+
#logging.debug(credentials)
139139
agent = Agent(serial, path, config, str(path) + '/agent.pid', simulated)
140140
cert_auth = config.getBooleanValue('mqtt','cert_auth')
141141
logging.debug(f'cert_auth: {cert_auth}')

scripts/start_docker.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ CA_NAME="iot-ca"
66
CERT_NAME="device-cert"
77

88
if [ -n "${C8YDM_MQTT_CERT_AUTH:-}" ] && [ $C8YDM_MQTT_CERT_AUTH = "true" ]; then
9-
# use container id as serial
9+
# use container id as serial if not manual provided
10+
if [[ -z "${C8YDM_AGENT_DEVICE__ID}" ]]; then
11+
C8YDM_AGENT_DEVICE__ID=$HOSTNAME
12+
export C8YDM_AGENT_DEVICE__ID=$HOSTNAME
13+
fi
14+
1015
./scripts/generate_cert.sh \
11-
--serial $HOSTNAME \
16+
--serial $C8YDM_AGENT_DEVICE__ID \
1217
--root-name $CA_NAME \
1318
--cert-name $CERT_NAME \
1419
--cert-dir "/root/.cumulocity/certs"
@@ -20,8 +25,6 @@ if [ -n "${C8YDM_MQTT_CERT_AUTH:-}" ] && [ $C8YDM_MQTT_CERT_AUTH = "true" ]; the
2025
--password $CERT_PASSWORD \
2126
--cert-path "/root/.cumulocity/certs/$CA_NAME.pem" \
2227
--cert-name $CA_NAME
23-
24-
export C8YDM_AGENT_DEVICE__ID=$HOSTNAME
2528
fi
2629

2730
if which vncserver; then

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
name='c8ydm',
2828
long_description=long_description,
2929
long_description_content_type="text/markdown",
30-
version='1.2.0',
30+
version='1.2.1',
3131
description='Cumulocity Device Management Agent',
3232
author='Tobias Sommer, Stefan Witschel, Marco Stoffel, Murat Bayram',
3333
author_email="Stefan.Witschel@softwareag.com",

0 commit comments

Comments
 (0)