diff --git a/.github/workflows/cla.yaml b/.github/workflows/cla.yaml new file mode 100644 index 0000000..335ad00 --- /dev/null +++ b/.github/workflows/cla.yaml @@ -0,0 +1,33 @@ +name: Commits +on: + - pull_request + +permissions: + contents: read + +jobs: + cla-check: + permissions: + pull-requests: read + name: Canonical CLA signed + runs-on: ubuntu-latest + steps: + - name: Check if CLA signed + uses: canonical/has-signed-canonical-cla@v1 + + dco-check: + permissions: + pull-requests: read # for tim-actions/get-pr-commits to get list of commits from the PR + name: Signed-off-by (DCO) + runs-on: ubuntu-latest + steps: + - name: Get PR Commits + id: 'get-pr-commits' + uses: tim-actions/get-pr-commits@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Check that all commits are signed-off + uses: tim-actions/dco@master + with: + commits: ${{ steps.get-pr-commits.outputs.commits }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6cb4212..2656915 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,34 +1,67 @@ -# lldpd +# Contributing to the lldpd charm + +## Overview + +This document explains the processes and practices recommended for contributing enhancements to +this charm. + +- Generally, before developing enhancements to this charm you should consider [opening an issue]( + https://github.com/canonical/charm-lldp/issues) explaining your bug or use case. +- Familiarising yourself with the [Charmed Operator Framework](https://juju.is/docs/sdk) + library will help you when working on new features or bug fixes. +- All enhancements and code changes require review before being merged. Code review typically + examines: + - code quality + - test coverage + - user experience for administrators deploying and operating this charm +- Please help us out by ensuring easy to review branches by rebasing your pull request branch + onto the `main` branch. This also avoids merge commits and creates a linear Git commit + history. Please do *not* merge the main branch into your PR. ## Developing -Create and activate a virtualenv with the development requirements: +Install `tox`, `charmcraft` and `juju`. - virtualenv -p python3 venv - source venv/bin/activate - pip install -r requirements-dev.txt +```bash +sudo apt-get install tox +sudo snap install charmcraft --classic +sudo snap install juju +``` -## Code overview +## Testing -TEMPLATE-TODO: -One of the most important things a consumer of your charm (or library) -needs to know is what set of functionality it provides. Which categories -does it fit into? Which events do you listen to? Which libraries do you -consume? Which ones do you export and how are they used? +To test the charm, there are several tox targets which can be used -## Intended use case +```commandline +tox run -e format # update your code according to linting rules +tox run -e lint # code style tests +tox run -e static-charm # runs static analysis on the charm +tox run -e unit # unit tests +tox # runs lint, static analysis and unit tests +``` -TEMPLATE-TODO: -Why were these decisions made? What's the scope of your charm? +## Building -## Roadmap +Build the charm in the local repository using the `charmcraft` tool. -If this Charm doesn't fulfill all of the initial functionality you were -hoping for or planning on, please add a Roadmap or TODO here +```commandline +charmcraft pack +``` -## Testing +## Deploy + +```commandline +# Create a model +juju add-model test + +# Enable debug logging (optional) +juju model-config logging-config="=INFO;unit=DEBUG" -The Python operator framework includes a very nice harness for testing -operator behaviour without full deployment. Just `run_tests`: +# Deploy the charm +juju deploy --base ubuntu@22.04 ./lldpd_ubuntu-22.04-amd64.charm +``` - ./run_tests +## Canonical Contributor Agreement +Canonical welcomes contributions to the lldpd charm. Please check out our [contributor +agreement](https://ubuntu.com/legal/contributors) if you are interested in contributing to this +code base. diff --git a/README.md b/README.md index 2bbc1af..d65577a 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,15 @@ switches and routers. # Usage -Start by installing the lldpd charm and relating it to another application: +Start by installing the lldpd charm and relating it to another application, e.g. +juju deploy ubuntu juju deploy lldpd -juju add-relation lldpd application-on-physical-machine +juju integrate lldpd ubuntu Being a subordinate charm it needs to be related to an application running -on physical machine. It doesn't make much sense to install LLDP on a VM -or LXD container, because Linux bridge will terminate LLDP traffic. +on physical machine, in the above case the Ubuntu charm. ## Scale out Usage @@ -22,12 +22,12 @@ By scaling your application, subordinate charm will get installed automatically. ## Known Limitations and Issues -LLDP is not very useful on containers and virtual machines and therefore it's -use on those is not recommended. +Deploying LLDP to an LXD container or virtual machine may not work as expected +due to network bridges for virtual infrastructure not passing through LLDP frames. # Configuration -By default LLDPd will listen on all interfaces and pick, more or less, a random +By default, LLDPd will listen on all interfaces and pick, more or less, a random systemid. Two given configuration options allow user to specify which interfaces will be used to broadcast LLDP data and which will be used for systemid. diff --git a/config.yaml b/config.yaml index 08ea830..7d405af 100644 --- a/config.yaml +++ b/config.yaml @@ -1,42 +1,45 @@ -"options": - "i40e-lldp-stop": - "type": "boolean" - "default": !!bool "True" - "description": | - "This allows control over Intel's i40e NIC driver. By default - i40e blocks userspace LLDP and does it on its own. Setting this - option to 'True' means charm will disable this functionality in - the NIC and do it within userspace." - "interfaces-regex": - "type": "string" - "default": "" - "description": | - "Which interfaces should lldpd announce details. If you want lldpd - to listen on multiple interfaces, set it here. Examples: +options: + i40e-lldp-stop: + type: boolean + default: True + description: | + This allows control over Intel's i40e NIC driver. By default + i40e blocks userspace LLDP and does it on its own. Setting this + option to 'True' means charm will disable this functionality in + the NIC and do it within userspace. + interfaces-regex: + type: string + default: "" + description: | + Which interfaces should lldpd announce details. If you want lldpd + to listen on multiple interfaces, set it here. Examples: - seth*,meth* + seth*,meth* - You can also use exclamation mark to exclude an interface: + You can also use exclamation mark to exclude an interface: - eth*,!eth1 + eth*,!eth1 - This way lldpd will listen on all eth* interfaces with an - exception of eth1. + This way lldpd will listen on all eth* interfaces with an + exception of eth1. - By default this is set to None, which puts lldpd in listening - mode only." - "systemid-from-interface": - "type": "string" - "default": "" - "description": "Pull systemID from this interface" - "enable-snmp": - "type": "boolean" - "default": False - "description": "Enable the SNMP agent for LLDPD" - "short-name": - "type": "boolean" - "default": !!bool "False" - "description": "Set short name in SysName instead of FQDN" + By default this is set to None, which puts lldpd in listening + mode only. + systemid-from-interface: + type: string + default: "" + description: | + Pull systemID from this interface + enable-snmp: + type: boolean + default: False + description: | + Enable the SNMP agent for LLDPD + short-name: + type: boolean + default: False + description: | + Set short name in SysName instead of FQDN nagios_context: default: "juju" type: string @@ -50,4 +53,4 @@ default: "juju" type: string description: | - Comma separated list of nagios servicegroups for the check + Comma separated list of nagios service groups for the check diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 4f2a3f5..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,3 +0,0 @@ --r requirements.txt -coverage -flake8