use of org.platformlayer.ops.ssh.SshAuthorizedKey in project platformlayer by platformlayer.
the class GoogleCloudInstanceController method addChildren.
@Override
protected void addChildren() throws OpsException {
final GoogleCloudInstance model = OpsContext.get().getInstance(GoogleCloudInstance.class);
PublicKey rootPublicKey;
try {
rootPublicKey = OpenSshUtils.readSshPublicKey(model.sshPublicKey);
} catch (IOException e) {
throw new OpsException("Cannot read SSH key");
}
CloudInstanceMapper instance;
{
instance = injected(CloudInstanceMapper.class);
instance.instance = model;
addChild(instance);
}
{
SshAuthorizedKey authorizeRoot = instance.addChild(SshAuthorizedKey.class);
authorizeRoot.user = "root";
authorizeRoot.publicKey = rootPublicKey;
}
{
instance.addChild(ConfigureSshd.class);
}
{
OpsProvider<TagChanges> tagChanges = new OpsProvider<TagChanges>() {
@Override
public TagChanges get() {
GoogleComputeMachine machine = OpsContext.get().getInstance(GoogleComputeMachine.class);
TagChanges tagChanges = new TagChanges();
tagChanges.addTags.add(Tag.INSTANCE_KEY.build(model.getKey()));
tagChanges.addTags.addAll(machine.buildAddressTags());
return tagChanges;
}
};
instance.addChild(Tagger.build(model, tagChanges));
}
// Note: We can't bootstrap an instance, because we can't log in to it,
// because the public key is not our service's public key
// if (model.publicPorts != null) {
// for (int publicPort : model.publicPorts) {
// PublicPorts publicPortForward = injected(PublicPorts.class);
// publicPortForward.port = publicPort;
// publicPortForward.backendItem = model;
// kvm.addChild(publicPortForward);
// }
// }
}
Aggregations