Moved functionality of K8sEmsClientDeploymentPostTranslationPlugin to K8sEmsClientDeploymentPostProcessingPlugin. Left K8sEmsClientDeploymentPostTranslationPlugin as a skeleton for future use.
Change-Id: I2b65926a0f693a76fb9643fab12ee3397c71a385
This commit is contained in:
parent
82379b5013
commit
2d426cbd95
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023-2025 Institute of Communication and Computer Systems (imu.iccs.gr)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v2.0.
|
||||||
|
* If a copy of the MPL was not distributed with this file, you can obtain one at
|
||||||
|
* https://www.mozilla.org/en-US/MPL/2.0/
|
||||||
|
*/
|
||||||
|
|
||||||
|
package eu.nebulous.ems.k8s;
|
||||||
|
|
||||||
|
import eu.nebulous.ems.EmsNebulousProperties;
|
||||||
|
import gr.iccs.imu.ems.control.controller.ControlServiceRequestInfo;
|
||||||
|
import gr.iccs.imu.ems.control.controller.NodeRegistrationCoordinator;
|
||||||
|
import gr.iccs.imu.ems.control.plugin.AppModelPlugin;
|
||||||
|
import gr.iccs.imu.ems.control.plugin.PostTranslationPlugin;
|
||||||
|
import gr.iccs.imu.ems.control.util.TopicBeacon;
|
||||||
|
import gr.iccs.imu.ems.translate.TranslationContext;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class K8sEmsClientDeploymentPostProcessingPlugin implements AppModelPlugin, InitializingBean {
|
||||||
|
private final K8sServiceProperties properties;
|
||||||
|
private final ApplicationContext applicationContext;
|
||||||
|
private final EmsNebulousProperties emsNebulousProperties;
|
||||||
|
|
||||||
|
private String applicationId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
applicationId = emsNebulousProperties.getApplicationId();
|
||||||
|
log.info("K8sEmsClientDeploymentPostProcessingPlugin: Application Id (from Env.): {}", applicationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postProcessingNewAppModel(String appModelId, ControlServiceRequestInfo requestInfo, TranslationContext translationContext) {
|
||||||
|
String oldAppId = this.applicationId;
|
||||||
|
this.applicationId = translationContext.getAppId();
|
||||||
|
log.info("K8sEmsClientDeploymentPostProcessingPlugin: Set applicationId to: {} -- was: {}", applicationId, oldAppId);
|
||||||
|
|
||||||
|
// Call control-service to deploy EMS clients
|
||||||
|
if (properties.isDeployEmsClientsOnKubernetesEnabled()) {
|
||||||
|
try {
|
||||||
|
log.info("K8sEmsClientDeploymentPostProcessingPlugin: Start deploying EMS clients...");
|
||||||
|
String id = "dummy-" + System.currentTimeMillis();
|
||||||
|
Map<String, Object> nodeInfo = new HashMap<>(Map.of(
|
||||||
|
"id", id,
|
||||||
|
"name", id,
|
||||||
|
"type", "K8S",
|
||||||
|
"provider", "Kubernetes",
|
||||||
|
"zone-id", ""
|
||||||
|
));
|
||||||
|
applicationContext.getBean(NodeRegistrationCoordinator.class)
|
||||||
|
.registerNode("", nodeInfo, translationContext);
|
||||||
|
log.debug("K8sEmsClientDeploymentPostProcessingPlugin: EMS clients deployment started");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("K8sEmsClientDeploymentPostProcessingPlugin: EXCEPTION while starting EMS client deployment: ", e);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
log.info("K8sEmsClientDeploymentPostProcessingPlugin: EMS clients deployment is disabled");
|
||||||
|
}
|
||||||
|
}
|
@ -8,39 +8,33 @@
|
|||||||
|
|
||||||
package eu.nebulous.ems.k8s;
|
package eu.nebulous.ems.k8s;
|
||||||
|
|
||||||
import eu.nebulous.ems.EmsNebulousProperties;
|
|
||||||
import gr.iccs.imu.ems.control.controller.NodeRegistrationCoordinator;
|
|
||||||
import gr.iccs.imu.ems.control.plugin.PostTranslationPlugin;
|
import gr.iccs.imu.ems.control.plugin.PostTranslationPlugin;
|
||||||
import gr.iccs.imu.ems.control.util.TopicBeacon;
|
import gr.iccs.imu.ems.control.util.TopicBeacon;
|
||||||
import gr.iccs.imu.ems.translate.TranslationContext;
|
import gr.iccs.imu.ems.translate.TranslationContext;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class K8sEmsClientDeploymentPostTranslationPlugin implements PostTranslationPlugin, InitializingBean {
|
public class K8sEmsClientDeploymentPostTranslationPlugin implements PostTranslationPlugin, InitializingBean {
|
||||||
private final K8sServiceProperties properties;
|
// private final K8sServiceProperties properties;
|
||||||
private final ApplicationContext applicationContext;
|
// private final ApplicationContext applicationContext;
|
||||||
private final EmsNebulousProperties emsNebulousProperties;
|
// private final EmsNebulousProperties emsNebulousProperties;
|
||||||
|
//
|
||||||
private String applicationId;
|
// private String applicationId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
applicationId = emsNebulousProperties.getApplicationId();
|
/*applicationId = emsNebulousProperties.getApplicationId();
|
||||||
log.info("K8sEmsClientDeploymentPostTranslationPlugin: Application Id (from Env.): {}", applicationId);
|
log.info("K8sEmsClientDeploymentPostTranslationPlugin: Application Id (from Env.): {}", applicationId);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processTranslationResults(TranslationContext translationContext, TopicBeacon topicBeacon) {
|
public void processTranslationResults(TranslationContext translationContext, TopicBeacon topicBeacon) {
|
||||||
String oldAppId = this.applicationId;
|
/*String oldAppId = this.applicationId;
|
||||||
this.applicationId = translationContext.getAppId();
|
this.applicationId = translationContext.getAppId();
|
||||||
log.info("K8sEmsClientDeploymentPostTranslationPlugin: Set applicationId to: {} -- was: {}", applicationId, oldAppId);
|
log.info("K8sEmsClientDeploymentPostTranslationPlugin: Set applicationId to: {} -- was: {}", applicationId, oldAppId);
|
||||||
|
|
||||||
@ -63,6 +57,6 @@ public class K8sEmsClientDeploymentPostTranslationPlugin implements PostTranslat
|
|||||||
log.warn("K8sEmsClientDeploymentPostTranslationPlugin: EXCEPTION while starting EMS client deployment: ", e);
|
log.warn("K8sEmsClientDeploymentPostTranslationPlugin: EXCEPTION while starting EMS client deployment: ", e);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
log.info("K8sEmsClientDeploymentPostTranslationPlugin: EMS clients deployment is disabled");
|
log.info("K8sEmsClientDeploymentPostTranslationPlugin: EMS clients deployment is disabled");*/
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user