Skip to content
Snippets Groups Projects
Commit bff8692a authored by Fotis Soldatos's avatar Fotis Soldatos
Browse files

fix(automation): bind ztpAdd with return statement

parent 19ec3808
No related branches found
No related tags found
1 merge request!54Release 2.0.0
...@@ -2,6 +2,8 @@ package eu.teraflow.automation; ...@@ -2,6 +2,8 @@ package eu.teraflow.automation;
import automation.Automation; import automation.Automation;
import context.ContextOuterClass; import context.ContextOuterClass;
import eu.teraflow.automation.device.model.Device;
import eu.teraflow.automation.model.DeviceRoleId;
import io.quarkus.grpc.GrpcService; import io.quarkus.grpc.GrpcService;
import io.smallrye.mutiny.Uni; import io.smallrye.mutiny.Uni;
import javax.inject.Inject; import javax.inject.Inject;
...@@ -32,18 +34,13 @@ public class AutomationGatewayImpl implements AutomationGateway { ...@@ -32,18 +34,13 @@ public class AutomationGatewayImpl implements AutomationGateway {
@Override @Override
public Uni<Automation.DeviceRoleState> ztpAdd(Automation.DeviceRole request) { public Uni<Automation.DeviceRoleState> ztpAdd(Automation.DeviceRole request) {
final var devRoleId = request.getDevRoleId().getDevRoleId().getUuid();
final var deviceId = serializer.deserialize(request.getDevRoleId().getDevId()); final var deviceId = serializer.deserialize(request.getDevRoleId().getDevId());
// TODO tie this with return return automationService
automationService.addDevice(deviceId); .addDevice(deviceId)
.onItem()
// TODO Set all fields of device role state (create models, serializer) .transform( device -> transformToDeviceRoleState(device, devRoleId));
return Uni.createFrom()
.item(
() ->
Automation.DeviceRoleState.newBuilder()
.setDevRoleId(request.getDevRoleId())
.build());
} }
@Override @Override
...@@ -70,4 +67,16 @@ public class AutomationGatewayImpl implements AutomationGateway { ...@@ -70,4 +67,16 @@ public class AutomationGatewayImpl implements AutomationGateway {
public Uni<Automation.DeviceDeletionResult> ztpDeleteAll(Automation.Empty empty) { public Uni<Automation.DeviceDeletionResult> ztpDeleteAll(Automation.Empty empty) {
return Uni.createFrom().item(() -> Automation.DeviceDeletionResult.newBuilder().build()); return Uni.createFrom().item(() -> Automation.DeviceDeletionResult.newBuilder().build());
} }
}
// TODO When `DeviceRoleState` domain object will be created, move this method to Serializer class and create related tests
private Automation.DeviceRoleState transformToDeviceRoleState(Device device, String devRoleId){
final var deviceRoleId = new DeviceRoleId(devRoleId, device.getDeviceId());
final var serializeDeviceRoleId = serializer.serialize(deviceRoleId);
return Automation.DeviceRoleState.newBuilder()
.setDevRoleId(serializeDeviceRoleId)
.setDevRoleState(Automation.ZtpDeviceState.ZTP_DEV_STATE_CREATED)
.build();
}
}
\ No newline at end of file
...@@ -3,20 +3,20 @@ apiVersion: v1 ...@@ -3,20 +3,20 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
annotations: annotations:
app.quarkus.io/commit-id: 500a0a232ec361b669b48cc432e9bd9c332eae8b app.quarkus.io/commit-id: 10192a8dd76072b7c1026824117157d672385e29
app.quarkus.io/build-timestamp: 2022-02-11 - 10:27:21 +0000 app.quarkus.io/build-timestamp: 2022-02-11 - 16:52:33 +0000
labels: labels:
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
app: automationservice app: automationservice
name: automationservice name: automationservice
spec: spec:
ports: ports:
- name: grpc-server
port: 9999
targetPort: 9999
- name: http - name: http
port: 8080 port: 8080
targetPort: 8080 targetPort: 8080
- name: grpc-server
port: 9999
targetPort: 9999
selector: selector:
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
type: ClusterIP type: ClusterIP
...@@ -25,8 +25,8 @@ apiVersion: apps/v1 ...@@ -25,8 +25,8 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
annotations: annotations:
app.quarkus.io/commit-id: 500a0a232ec361b669b48cc432e9bd9c332eae8b app.quarkus.io/commit-id: 10192a8dd76072b7c1026824117157d672385e29
app.quarkus.io/build-timestamp: 2022-02-11 - 10:27:21 +0000 app.quarkus.io/build-timestamp: 2022-02-11 - 16:52:33 +0000
labels: labels:
app: automationservice app: automationservice
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
...@@ -39,8 +39,8 @@ spec: ...@@ -39,8 +39,8 @@ spec:
template: template:
metadata: metadata:
annotations: annotations:
app.quarkus.io/commit-id: 500a0a232ec361b669b48cc432e9bd9c332eae8b app.quarkus.io/commit-id: 10192a8dd76072b7c1026824117157d672385e29
app.quarkus.io/build-timestamp: 2022-02-11 - 10:27:21 +0000 app.quarkus.io/build-timestamp: 2022-02-11 - 16:52:33 +0000
labels: labels:
app: automationservice app: automationservice
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
...@@ -69,12 +69,12 @@ spec: ...@@ -69,12 +69,12 @@ spec:
timeoutSeconds: 10 timeoutSeconds: 10
name: automationservice name: automationservice
ports: ports:
- containerPort: 9999
name: grpc-server
protocol: TCP
- containerPort: 8080 - containerPort: 8080
name: http name: http
protocol: TCP protocol: TCP
- containerPort: 9999
name: grpc-server
protocol: TCP
readinessProbe: readinessProbe:
failureThreshold: 3 failureThreshold: 3
httpGet: httpGet:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment