use of org.platformlayer.core.model.InstanceBase in project platformlayer by platformlayer.
the class OwnedEndpoint method buildItemTemplate.
@Override
protected PublicEndpointBase buildItemTemplate() throws OpsException {
InstanceBase instance = OpsContext.get().getInstance(InstanceBase.class);
PlatformLayerKey instanceKey = instance.getKey();
PublicEndpointBase publicEndpoint = platformLayerCloudHelpers.createPublicEndpoint(instance, parentItem);
// publicEndpoint.network = network;
publicEndpoint.publicPort = publicPort;
publicEndpoint.publicPortCluster = publicPortCluster;
publicEndpoint.backendPort = backendPort;
publicEndpoint.instance = instanceKey;
publicEndpoint.key = PlatformLayerKey.fromId(instance.getId() + "_" + publicPort);
if (transport != null) {
publicEndpoint.transport = transport.toString();
}
// publicEndpoint.getTags().add(OpsSystem.get().createParentTag(instance));
Tag uniqueTag = UniqueTag.build(instance, String.valueOf(publicPort));
publicEndpoint.getTags().add(uniqueTag);
return publicEndpoint;
}
use of org.platformlayer.core.model.InstanceBase in project platformlayer by platformlayer.
the class PlatformLayerCloudHelpers method buildInstanceTemplate.
InstanceBase buildInstanceTemplate(MachineCreationRequest request, PlatformLayerKey parent) throws OpsException {
MachineProvider targetCloud = scheduler.pickCloud(request);
InstanceBase machine = targetCloud.buildInstanceTemplate(request);
machine.sshPublicKey = SshKeys.serialize(request.sshPublicKey);
machine.recipeId = request.recipeId;
if (request.publicPorts != null) {
if (machine.publicPorts == null) {
machine.publicPorts = Lists.newArrayList();
}
machine.publicPorts.addAll(request.publicPorts);
}
machine.getTags().addAll(request.tags);
if (parent != null) {
machine.getTags().add(Tag.buildParentTag(parent));
}
machine.cloud = targetCloud.getModel().getKey();
machine.hostPolicy = request.hostPolicy;
String id = request.hostname;
if (Strings.isNullOrEmpty(id)) {
id = UUID.randomUUID().toString();
}
machine.setKey(PlatformLayerKey.fromId(id));
return machine;
}
use of org.platformlayer.core.model.InstanceBase in project platformlayer by platformlayer.
the class PlatformLayerCloudHelpers method findMachines.
public List<InstanceBase> findMachines(Tag tag) throws OpsException {
if (!Objects.equal(tag.getKey(), Tag.PARENT.getKey())) {
throw new IllegalArgumentException();
}
List<InstanceBase> machines = Lists.newArrayList();
boolean showDeleted = false;
PlatformLayerKey parent = PlatformLayerKey.parse(tag.getValue());
for (ItemBase item : platformLayer.listChildrenTyped(parent, showDeleted)) {
if (item instanceof InstanceBase) {
machines.add((InstanceBase) item);
}
}
return machines;
}
use of org.platformlayer.core.model.InstanceBase in project platformlayer by platformlayer.
the class PlatformLayerCloudHelpers method putInstanceByTag.
public Machine putInstanceByTag(MachineCreationRequest request, PlatformLayerKey parent, Tag uniqueTag) throws OpsException {
InstanceBase machine = buildInstanceTemplate(request, parent);
machine = platformLayer.putItemByTag(machine, uniqueTag);
return toMachine(machine);
}
use of org.platformlayer.core.model.InstanceBase in project platformlayer by platformlayer.
the class InstanceFinder method foundItem.
@Override
protected void foundItem(ItemBase child) throws OpsException {
super.foundItem(child);
if (child instanceof InstanceBase) {
instances.add((InstanceBase) child);
}
PlatformLayerKey assignedTo = Tag.ASSIGNED_TO.findUnique(child.getTags());
if (assignedTo != null) {
scheduleVisit(assignedTo);
}
}
Aggregations