//
//  Licensed to the Apache Software Foundation (ASF) under one or more
//  contributor license agreements.  See the NOTICE file distributed with
//  this work for additional information regarding copyright ownership.
//  The ASF licenses this file to You under the Apache License, Version 2.0
//  (the "License"); you may not use this file except in compliance with
//  the License.  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//

== The PLC4X Project VM

As, especially for the raw socket functionality of PLC4X, our project had higher demands on the infrastructure as other projects.
Apache Infra kindly provided us with a dedicated VM.

This is included as build agent into Apache's Jenkins with the label `plc4x1` and is marked for exclusive usage by our project.

The host name of this machine is: `plc4x-vm.apache.org`

On this machine we can even `sudo` to perform operations only available to `root`.

Project members can request access to the machine.

=== Requesting access

In order to be able to login, users need to add their SSH public key to their Apache ID first.

This is done under the following url: https://id.apache.org/

Here just add the content in the follwoing format to one of the `SSH Key (authorized_keys line)` fields:

    ssh-rsa   my@email-address.com

(I just had to copy this line from my `~/.ssh/id_rsa.pub` file)

TIP: Note, the Email Address in the end doesn't seem to matter, I simply added it for the sake of completeness. So if this doesn't match your Apache email, this is not a problem.

As soon as that's done, access needs to be requested from Apache Infra.

This is done using the Infra Jira at: https://issues.apache.org/jira

Here make sure to select the Project `Infrastructure (INFRA)`.

As soon as that's handled by the Infra team, you should be ready to log-in on the machine.

=== Login to the machine

Using SSH we should now be able to login to the VM.

   ssh apacheId@plc4x-vm.apache.org

Be sure to use the username matching your Apache ID or the login will fail.

If all wen't well you should now be able to login to the machine using your apache user.

=== Doing things as `root`

Apache Infra is great at keeping things safe.
Providing a sudo password directly would increase the danger of having this intercepted, therefore they are using a tool called `opiepasswd`.

Instead of now entering a password, a challenge is displayed:

    myid@plc4x-vm:~$ sudo apt-get update
    otp-md5 496 pl8230
    Password:

If you now enter your normal password, you'll simply get `permission denied` errors.

In order to execute operations as root on the machine, you need to get a client.
Everything needed is documented here: https://reference.apache.org/pdf.lua?/committer/opie

As soon as you have your OPIE client installed and running, you need to copy the first line of the response:

   otp-md5 496 pl8230

into your OPIE client's `challenge` field (In case of SkeyCalc).

In the `password` field you provide your Apache LDAP password.
When hitting enter or clicking on `Calc & Copy` the tool should automatically copy the response.

Now all you need to do is paste that as password into your SSH client session.

=== Required software

For being able to build the charts and graphics as part of the site generation, we need to add some additional packages:

   sudo apt-get install python-seqdiag
   sudo apt-get install python-nwdiag
