Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce web administration #1425

Closed
wants to merge 9 commits into from
Closed

Introduce web administration #1425

wants to merge 9 commits into from

Conversation

flo-mic
Copy link

@flo-mic flo-mic commented Jan 17, 2021

As discussed with @mstormi in this topic I'm currently working on a web administration for openHABian to allow users the control of their system from any web browser.

The baseline for this web application dashboard is the cockpit-project. It is a web administration platform for linux systems. It offers great features like network administration, update management, system overview and a web-based terminal.

I build an application that is integrated in the cockpit-project web application and extends it for openHABian related features. At the moment the application can not provide the full functionality of the CLI. But this ist just a first starting point. I playn to integrate all features of the CLI from time to time.

The following features are included for the beginning:

  • Branch management ("release", "testing" and "snapshot" of openHAB
  • openHAB service management
  • openHAB console management (ip and port of karaf console)
  • a LogViewer which is integrated in the application
  • the apply improvments section from the openHABian cli
  • openHAB config backup and restore with a possibility to download the backups
  • openHABian update check with user notification
  • security warning if running with default password

I added this application to the openhabian-cli menu under "optional components". A new point 2C was added.
I also updated the openhabian_update() function. It will now call a function openhabian_dashboard_update(). This function will copy the related html files if the dashboard application is installed.

I was not adding this to the default installation routine called by openhabian-setup.sh. I'm not sure if this should be included in the default setup or not?

For now I was not creating any test files du to my inexperience. I defeinitely need some information where test files are needed and how to make them. I have no experience here but I'm willing to learn ;)

If there is anything I did wrong in relation to code styling please let me know and I will fix it.

Signed-off-by: Florian Michel florianmichel@hotmail.de

@ecdye ecdye linked an issue Jan 17, 2021 that may be closed by this pull request
@ecdye ecdye added new openHAB related Must be important optional component Not part of the base system labels Jan 17, 2021
@mstormi
Copy link
Contributor

mstormi commented Jan 17, 2021

I was not adding this to the default installation routine called by openhabian-setup.sh. I'm not sure if this should be included in the default setup or not?

We'll review first then when done decide on this.

For now I was not creating any test files du to my inexperience. I defeinitely need some information where test files are needed and how to make them.

We want you to provide BATS test cases for all major functions but as you're not really providing the functionality itself (but just the interface on top) I'd say in the first place all we need is a test case that installs your extension and does some basic verification it is working properly. This could run e.g. a web request to install (but not run) a specific OH version.
It's not that hard to write such a test case. Check out *.bats in the openhabian repo for examples.
You can install BATS locally for your testing run purposes. Once we should merge your code it'll be run on every build on a docker machine in the Github cloud.

@flo-mic
Copy link
Author

flo-mic commented Jan 19, 2021

@mstormi thanks for the feedback. I was able to create a bats file. Unfortunately I can’t run a full test. First I wrote a bats file which made some web calls to ensure that the services are up and responding. But this is not possible inside the docker container. The problem is caused by the cockpit service. This can not start inside the docker due to the following error:

# ERROR:systemctl: cockpit.service: Exec is not an absolute path:  ExecStartPre=+/usr/sbin/remotectl certificate --ensure --user=root --group=cockpit-ws --selinux-type=
# ERROR:systemctl: cockpit.service: Exec command does not exist: (ExecStartPre) +/usr/sbin/remotectl
# ERROR:systemctl: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# ERROR:systemctl: The SystemD ExecXY commands must always be absolute paths by definition.
# ERROR:systemctl: Oops, 1 executable paths were not found in the current environment. Refusing.
# ERROR:systemctl: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# ERROR:systemctl:the ExecStartPre control process exited with error code

I made some research and found out that the cockpit can not run inside a container. If you want this to run as container you can download a special designed container from cockpit-project. But you can run the normal service inside the container. So I think a full functionality test can not be performed.

However I managed to create a bats file which checks if the cockpit.socks and cockpit.service are at least loaded by systemctl (not active). So I can ensure that the apt package installation was successfully. Then I check if the html files in the web folder are all there. And I verify if the scripts that are called by the webservice have the required executable permission.

I'm not happy with this test because I would like to make some wget calls to the webservice but due to the described issue this can not be done on the docker test system. A normal installation with openhabian-cli and also by calling the function directly is possible. I tested this on 3 systems.

Maybe you know this issues from other tests and have some hint how to handle this on tests?

There is some other point I noticed during my tests. If you install the FIND 3 application with openhabian-config it will call a function go_setup(). This function adds the debian backports repository to /etc/apt/sources.list.d/golang.list. I'm using the same repository for cockpit. At the moment I add this under /etc/apt/sources.list.d/backports.list because I was not aware about the go_setup function. This causes warnings for duplicated source entries during apt update. For compatibility reason I would suggest that I also write the repo to /etc/apt/sources.list.d/golang.list but this is somehow confusing because this has nothing to do with go from my perspective.

@ecdye
Copy link
Contributor

ecdye commented Jan 19, 2021

@mstormi @flo-mic

Another thought on the style of this project, would we want all the cockpit source files here, or in another git repository? That way it could be installed in /opt like other optional components.

Perhaps I am way out on a limb here but just a thought.

@flo-mic
Copy link
Author

flo-mic commented Jan 19, 2021

@ecdye this is a good question. I'm not sure what would be the best way and I'm totally open for ideas here.

At the beginning I had this in my own repository but as mstormi and also rkoshak mentioned in the community topic it should be included in openhabian.

Just for clarification I only added the openhabian addon for cockpit to this repository. The main application is installed via apt install from debian backports repository in any case so the size of this repo should not grow dramatically ;)

@ecdye
Copy link
Contributor

ecdye commented Jan 20, 2021

@flo-mic I am sorry to ask this, but can you rebase this on the main branch. We have just switched away from using master and it will only be used for legacy updates.

@mstormi
Copy link
Contributor

mstormi commented Jan 20, 2021

This can not start inside the docker due to the following error:

Did you run another Docker container or reused any of those openHABian runs at build time ?
They actually have a modified systemctl installed that does not require systemd to run with PID 1.
Check if if works with Cockpit.

@mstormi
Copy link
Contributor

mstormi commented Feb 18, 2021

@ecdye are you (still) reviewing this ?

FWIW I've just stumbled across the "Blame" feature of GitHub: it's a button at the top when you display a file in a repo and tells you per-line who changed it last i.e. who to blame for it :)

@ecdye
Copy link
Contributor

ecdye commented Feb 18, 2021

Not really, as I was hoping that @flo-mic would be able to rebase on main because we aren't really making feature changes to OH 2 any more.

FYI Blame has been around for a long time.

@mstormi
Copy link
Contributor

mstormi commented Feb 18, 2021

Not really, as I was hoping that @flo-mic would be able to rebase on main because we aren't really making feature changes to OH 2 any more.

yes please. @flo-mic do you read ?

@mstormi
Copy link
Contributor

mstormi commented Mar 2, 2021

@flo-mic sis you notice the request to rebase?

@flo-mic flo-mic closed this Mar 7, 2021
@mstormi
Copy link
Contributor

mstormi commented Mar 7, 2021

@flo-mic any particular reason you closed this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openHAB related Must be important optional component Not part of the base system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Web based menu
3 participants