use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.
the class KubevirtListNodesCommand method json.
private String json(List<KubevirtNode> nodes) {
ObjectMapper mapper = new ObjectMapper();
ArrayNode result = mapper.createArrayNode();
for (KubevirtNode node : nodes) {
result.add(jsonForEntity(node, KubevirtNode.class));
}
return prettyJson(mapper, result.toString());
}
use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.
the class KubevirtSyncStateCommand method bootstrapKubevirtNodes.
private void bootstrapKubevirtNodes(KubevirtApiConfig config) {
KubevirtNodeAdminService nodeAdminService = get(KubevirtNodeAdminService.class);
Set<KubevirtNode> completeNodeSet = nodeAdminService.completeNodes();
KubernetesClient k8sClient = k8sClient(config);
if (k8sClient == null) {
log.warn("Failed to connect to kubernetes API server");
return;
}
for (Node node : k8sClient.nodes().list().getItems()) {
KubevirtNode kubevirtNode = buildKubevirtNode(node);
// flow rules in worker nodes
if (kubevirtNode.type() == WORKER) {
if (completeNodeSet.stream().map(KubevirtNode::hostname).filter(name -> name.equals(kubevirtNode.hostname())).findAny().isPresent()) {
print("Initializing %s because the node was COMPLETE state.", kubevirtNode.hostname());
KubevirtNode updated = kubevirtNode.updateState(INIT);
nodeAdminService.updateNode(updated);
} else {
nodeAdminService.updateNode(kubevirtNode);
}
}
}
}
use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.
the class KubevirtNodeManager method createNode.
@Override
public void createNode(KubevirtNode node) {
checkNotNull(node, ERR_NULL_NODE);
KubevirtNode intNode;
KubevirtNode tunNode;
if (node.intgBridge() == null) {
String deviceIdStr = genDpidFromName(INTEGRATION_BRIDGE + "-" + node.hostname());
checkNotNull(deviceIdStr, ERR_NULL_DEVICE_ID);
intNode = node.updateIntgBridge(DeviceId.deviceId(deviceIdStr));
checkArgument(!hasIntgBridge(intNode.intgBridge(), intNode.hostname()), NOT_DUPLICATED_MSG, intNode.intgBridge());
} else {
intNode = node;
checkArgument(!hasIntgBridge(intNode.intgBridge(), intNode.hostname()), NOT_DUPLICATED_MSG, intNode.intgBridge());
}
if (node.tunBridge() == null) {
String deviceIdStr = genDpidFromName(TUNNEL_BRIDGE + "-" + node.hostname());
checkNotNull(deviceIdStr, ERR_NULL_DEVICE_ID);
tunNode = intNode.updateTunBridge(DeviceId.deviceId(deviceIdStr));
checkArgument(!hasTunBridge(tunNode.tunBridge(), tunNode.hostname()), NOT_DUPLICATED_MSG, tunNode.tunBridge());
} else {
tunNode = intNode;
checkArgument(!hasTunBridge(tunNode.tunBridge(), tunNode.hostname()), NOT_DUPLICATED_MSG, tunNode.tunBridge());
}
nodeStore.createNode(tunNode);
log.info(String.format(MSG_NODE, tunNode.hostname(), MSG_CREATED));
}
use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.
the class KubevirtNodeManager method removeNode.
@Override
public KubevirtNode removeNode(String hostname) {
checkArgument(!Strings.isNullOrEmpty(hostname), ERR_NULL_HOSTNAME);
KubevirtNode node = nodeStore.removeNode(hostname);
log.info(String.format(MSG_NODE, hostname, MSG_REMOVED));
return node;
}
use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.
the class KubevirtNodeManager method updateNode.
@Override
public void updateNode(KubevirtNode node) {
checkNotNull(node, ERR_NULL_NODE);
KubevirtNode intNode;
KubevirtNode tunNode;
KubevirtNode existingNode = nodeStore.node(node.hostname());
checkNotNull(existingNode, ERR_NULL_NODE);
DeviceId existIntgBridge = nodeStore.node(node.hostname()).intgBridge();
if (node.intgBridge() == null) {
intNode = node.updateIntgBridge(existIntgBridge);
checkArgument(!hasIntgBridge(intNode.intgBridge(), intNode.hostname()), NOT_DUPLICATED_MSG, intNode.intgBridge());
} else {
intNode = node;
checkArgument(!hasIntgBridge(intNode.intgBridge(), intNode.hostname()), NOT_DUPLICATED_MSG, intNode.intgBridge());
}
DeviceId existTunBridge = nodeStore.node(node.hostname()).tunBridge();
if (intNode.tunBridge() == null) {
tunNode = intNode.updateTunBridge(existTunBridge);
checkArgument(!hasTunBridge(tunNode.tunBridge(), tunNode.hostname()), NOT_DUPLICATED_MSG, tunNode.tunBridge());
} else {
tunNode = intNode;
checkArgument(!hasTunBridge(tunNode.tunBridge(), tunNode.hostname()), NOT_DUPLICATED_MSG, tunNode.tunBridge());
}
nodeStore.updateNode(tunNode);
log.info(String.format(MSG_NODE, tunNode.hostname(), MSG_UPDATED));
}
Aggregations