Skip to content

Commit

Permalink
Intitial/base plugin (#1)
Browse files Browse the repository at this point in the history
* Start working on hand shake exchange

* Add cookie cutter template

* Add assets bind thru cookie-cutter template

* Further customise plugin and add readme

* Small thing

* Add port and OF host override settings

* Rework OctoPrint plugin with OIDC, add settings frontend

* Finish the plugin settings and push to OF succesfully

* Switch announce method to POST

* Try to couple to backend for testing

* Big boom

* Also push URL to navbar

* Rectify plugin version and add changelog

* Bit of cleanup
  • Loading branch information
David Zwart authored Jun 21, 2021
1 parent c9affd6 commit e0430f3
Show file tree
Hide file tree
Showing 18 changed files with 1,027 additions and 5 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
quote_type = double

[**.py]
indent_style = space

[**.js]
indent_style = space
indent_size = 4
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
.DS_Store
.idea
*.iml

# C extensions
*.so
*.pyc
*.swp
*.zip

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
Expand All @@ -24,7 +31,7 @@ pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
*.egg*
MANIFEST

# PyInstaller
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog

All notable changes to this project will be documented in this file.

## [0.1.0-rc1]

### Added
- Feature: add unique key `device_uuid` to `config.yaml` to recognize the device
- Feature: store backup-excluded unique key `perrsistence_uuid` to data folder to see when backups are restored
- Feature: announce the OctoPrint device to OctoFarm automatically using OpenID Connect with `client_credentials` as auth flow.
- Feature: add settings and navbar templates to OctoPrint under `OctoFarm Companion`

### Changed

### Removed

### Fixed
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include README.md
recursive-include octofarm_companion/templates *
recursive-include octofarm_companion/translations *
recursive-include octofarm_companion/static *
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
# OctoFarm-Companion
OctoFarm's official OctoPrint plugin companion.

This plugin is your friend when using OctoFarm with one or more OctoPrint instances. The plugin is intended to simplify
the initial connection with OctoFarm. Next to that some more functionality will be built in future.

Current feature(s):
- Auto-registration - send your OctoPrint connection parameters to OctoFarm safely, to make setting up printers a breeze.

Future features:
- Filament Pedometer - send filament usage data to OctoFarm, making the filament manager plugin and its PostGres database unnecessary.
- Http Tunnel - connect to OctoFarm, to make connection to printers a breeze especially over docker, VPN, DMZ, VLAN, the cloud or other complex network setups.
- Single-sign-On - client-to-machine (C2M) and machine-to-machine (M2M) authentication removing the need for more than 1 set of credentials across the farm.

For more feature requests, bugs, or ideas please head over to https://github.com/OctoFarm/OctoFarm/discussions.

## Setup
**!! Work in progress !!**

Install via the bundled [Plugin Manager](https://docs.octoprint.org/en/master/bundledplugins/pluginmanager.html)
or manually using this URL:

https://github.com/OctoFarm/OctoFarm-Companion/archive/master.zip

Please configure the plugin completely for one or more printers before checking OctoFarm.

## Configuration
**Warning - restoring from a OctoPrint backup can be cause of security weakness due to copied passwords. In the end we are not responsible for your choices, but we advise to change the `accessControl:salt` and to regenerate the main user account for each OctoPrint instance.**

### Configuration - auto-registration
Configuring the auto-registration properly can massively improve the steps you need to undertake to setup your farm.
- `octofarmHost` the host to reach OctoFarm with (IP, localhost, domain name, etc)
- `octofarmPort` the port to approach the OctoFarm server (number)

We understand if you restore OctoPrint backups to install new OctoPrints. For that reason we've introduced two unique ID's (UUID).
- `persistenceUuid` a unique identifier stored in the plugin folder in `device.json`, which is excluded from backups to prevent duplicate printers.
- `deviceUuid` a unique identifier stored in the `config.yaml` at startup.

Periodic updates
- `ping` the time in seconds between each call to OctoFarm (default is 15 * 60, or 15 minutes)

The plugin will use `server:host` and `server:port` to give OctoFarm a handle to connect back to this OctoPrint. This is often incorrect, if your OctoPrint is behind a proxy, in a VM, UnRaid, a different device, DMZ, in a docker container or in a VPN.
At this moment this needs to be rectified in OctoFarm. Later we will allow more advanced ways to fix this, but for now we believe this plugin is going to make it much easier already.
8 changes: 8 additions & 0 deletions babel.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[python: */**.py]

[jinja2: */**.jinja2]
silent=false
extensions=jinja2.ext.autoescape, jinja2.ext.with_, jinja2.ext.do, octoprint.util.jinja.trycatch

[javascript: */**.js]
extract_messages = gettext, ngettext
8 changes: 8 additions & 0 deletions extras/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Currently Cookiecutter generates the following helpful extras to this folder:

octofarm_companion.md
Data file for plugins.octoprint.org. Fill in the missing TODOs once your
plugin is ready for release and file a PR as described at
http://plugins.octoprint.org/help/registering/ to get it published.

This folder may be safely removed if you don't need it.
102 changes: 102 additions & 0 deletions extras/octofarm_companion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
layout: plugin

id: octofarm_companion
title: OctoFarm-Companion
description: The companion plugin to bridge the gap between OctoFarm and OctoPrint.
authors:
- David Zwart
license: AGPLv3

# TODO
date: today's date in format YYYY-MM-DD, e.g. 2015-04-21

homepage: https://github.com/OctoFarm/OctoFarm-Companion
source: https://github.com/OctoFarm/OctoFarm-Companion
archive: https://github.com/OctoFarm/OctoFarm-Companion/archive/master.zip

# TODO
# Set this to true if your plugin uses the dependency_links setup parameter to include
# library versions not yet published on PyPi. SHOULD ONLY BE USED IF THERE IS NO OTHER OPTION!
#follow_dependency_links: false

# TODO
tags:
- a list
- of tags
- that apply
- to your plugin
- (take a look at the existing plugins for what makes sense here)

# TODO
screenshots:
- url: url of a screenshot, /assets/img/...
alt: alt-text of a screenshot
caption: caption of a screenshot
- url: url of another screenshot, /assets/img/...
alt: alt-text of another screenshot
caption: caption of another screenshot
- ...

# TODO
featuredimage: url of a featured image for your plugin, /assets/img/...

# TODO
# You only need the following if your plugin requires specific OctoPrint versions or
# specific operating systems to function - you can safely remove the whole
# "compatibility" block if this is not the case.

compatibility:

# List of compatible versions
#
# A single version number will be interpretated as a minimum version requirement,
# e.g. "1.3.1" will show the plugin as compatible to OctoPrint versions 1.3.1 and up.
# More sophisticated version requirements can be modelled too by using PEP440
# compatible version specifiers.
#
# You can also remove the whole "octoprint" block. Removing it will default to all
# OctoPrint versions being supported.

octoprint:
- 1.2.0

# List of compatible operating systems
#
# Valid values:
#
# - windows
# - linux
# - macos
# - freebsd
#
# There are also two OS groups defined that get expanded on usage:
#
# - posix: linux, macos and freebsd
# - nix: linux and freebsd
#
# You can also remove the whole "os" block. Removing it will default to all
# operating systems being supported.

os:
- linux
- windows
- macos
- freebsd

# Compatible Python version
#
# Plugins should aim for compatibility for Python 2 and 3 for now, in which case the value should be ">=2.7,<4".
#
# Plugins that only wish to support Python 3 should set it to ">=3,<4".
#
# If your plugin only supports Python 2 (worst case, not recommended for newly developed plugins since Python 2
# is EOL), leave at ">=2.7,<3" - be aware that your plugin will not be allowed to register on the
# plugin repository if it only support Python 2.

python: ">=2.7,<3"

---

**TODO**: Longer description of your plugin, configuration examples etc. This part will be visible on the page at
http://plugins.octoprint.org/plugin/octofarm_companion/
Loading

0 comments on commit e0430f3

Please sign in to comment.