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

fix(automation): bind ztpAdd with return statement

parent 7838f031
No related branches found
No related tags found
No related merge requests found
...@@ -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,15 @@ public class AutomationGatewayImpl implements AutomationGateway { ...@@ -70,4 +67,15 @@ 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());
} }
}
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,8 +3,8 @@ apiVersion: v1 ...@@ -3,8 +3,8 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
annotations: annotations:
app.quarkus.io/commit-id: 74c131c1ab16a4a8b243c27ae34b4d26487c9e05 app.quarkus.io/commit-id: 7838f031e97cf30ca2eaf4d5f3428e32173ece12
app.quarkus.io/build-timestamp: 2022-02-10 - 13:53:38 +0000 app.quarkus.io/build-timestamp: 2022-02-10 - 13:58:28 +0000
labels: labels:
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
app.kubernetes.io/version: 0.1.0 app.kubernetes.io/version: 0.1.0
...@@ -12,12 +12,12 @@ metadata: ...@@ -12,12 +12,12 @@ metadata:
name: automationservice name: automationservice
spec: spec:
ports: ports:
- name: http
port: 8080
targetPort: 8080
- name: grpc-server - name: grpc-server
port: 9999 port: 9999
targetPort: 9999 targetPort: 9999
- name: http
port: 8080
targetPort: 8080
selector: selector:
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
app.kubernetes.io/version: 0.1.0 app.kubernetes.io/version: 0.1.0
...@@ -27,28 +27,28 @@ apiVersion: apps/v1 ...@@ -27,28 +27,28 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
annotations: annotations:
app.quarkus.io/commit-id: 74c131c1ab16a4a8b243c27ae34b4d26487c9e05 app.quarkus.io/commit-id: 7838f031e97cf30ca2eaf4d5f3428e32173ece12
app.quarkus.io/build-timestamp: 2022-02-10 - 13:53:38 +0000 app.quarkus.io/build-timestamp: 2022-02-10 - 13:58:28 +0000
labels: labels:
app: automationservice app: automationservice
app.kubernetes.io/version: 0.1.0
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
app.kubernetes.io/version: 0.1.0
name: automationservice name: automationservice
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/version: 0.1.0
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
app.kubernetes.io/version: 0.1.0
template: template:
metadata: metadata:
annotations: annotations:
app.quarkus.io/commit-id: 74c131c1ab16a4a8b243c27ae34b4d26487c9e05 app.quarkus.io/commit-id: 7838f031e97cf30ca2eaf4d5f3428e32173ece12
app.quarkus.io/build-timestamp: 2022-02-10 - 13:53:38 +0000 app.quarkus.io/build-timestamp: 2022-02-10 - 13:58:28 +0000
labels: labels:
app: automationservice app: automationservice
app.kubernetes.io/version: 0.1.0
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
app.kubernetes.io/version: 0.1.0
spec: spec:
containers: containers:
- env: - env:
...@@ -74,12 +74,12 @@ spec: ...@@ -74,12 +74,12 @@ spec:
timeoutSeconds: 10 timeoutSeconds: 10
name: automationservice name: automationservice
ports: ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 9999 - containerPort: 9999
name: grpc-server name: grpc-server
protocol: TCP protocol: TCP
- containerPort: 8080
name: http
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