Initial commit
Change-Id: I7b679799cc21963a0b3f942262e40497c9a5d1ba
This commit is contained in:
parent
aed504029b
commit
c697f1da8c
1
.dockerignore
Symbolic link
1
.dockerignore
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
.gitignore
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.eggs
|
||||||
|
.tox
|
||||||
|
*.egg-info
|
47
.zuul.yaml
Normal file
47
.zuul.yaml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2020 VEXXHOST, Inc.
|
||||||
|
#
|
||||||
|
# Licensed 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.
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: openstack-tools:image:build
|
||||||
|
parent: vexxhost-build-docker-image
|
||||||
|
provides: openstack-tools:image
|
||||||
|
vars: &id001
|
||||||
|
docker_images:
|
||||||
|
- context: .
|
||||||
|
repository: vexxhost/openstack-tools
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: openstack-tools:image:upload
|
||||||
|
parent: vexxhost-upload-docker-image
|
||||||
|
provides: openstack-tools:image
|
||||||
|
vars: *id001
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: openstack-tools:image:promote
|
||||||
|
parent: vexxhost-promote-docker-image
|
||||||
|
vars: *id001
|
||||||
|
|
||||||
|
- project:
|
||||||
|
check:
|
||||||
|
jobs:
|
||||||
|
- tox-linters
|
||||||
|
- openstack-tools:image:build
|
||||||
|
gate:
|
||||||
|
jobs:
|
||||||
|
- tox-linters
|
||||||
|
- openstack-tools:image:upload
|
||||||
|
promote:
|
||||||
|
jobs:
|
||||||
|
- openstack-tools:image:promote
|
22
Dockerfile
Normal file
22
Dockerfile
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Copyright 2020 VEXXHOST, Inc.
|
||||||
|
#
|
||||||
|
# Licensed 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.
|
||||||
|
|
||||||
|
FROM docker.io/opendevorg/python-builder:3.7 as builder
|
||||||
|
COPY . /tmp/src
|
||||||
|
RUN assemble
|
||||||
|
|
||||||
|
FROM docker.io/opendevorg/python-base:3.7 as zuul
|
||||||
|
COPY --from=builder /output/ /output
|
||||||
|
RUN /output/install-from-bindep
|
||||||
|
ADD https://raw.githubusercontent.com/openvswitch/ovs/master/vswitchd/vswitch.ovsschema /usr/share/openvswitch/vswitch.ovsschema
|
10
README.rst
Normal file
10
README.rst
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
===============
|
||||||
|
OpenStack Tools
|
||||||
|
===============
|
||||||
|
|
||||||
|
This repository includes useful utilties needed for operations of OpenStack,
|
||||||
|
however, it's important to note that the existance of some of these tools are
|
||||||
|
a bug. These are simple interim solutions (especially clean-up tools) which
|
||||||
|
should all be non-existant as they should be fixed in upstream.
|
||||||
|
|
||||||
|
These tools are also published on DockerHub under ``vexxhost/openstack-tools``.
|
0
openstack_tools/__init__.py
Normal file
0
openstack_tools/__init__.py
Normal file
0
openstack_tools/cmd/__init__.py
Normal file
0
openstack_tools/cmd/__init__.py
Normal file
0
openstack_tools/cmd/cleanup/__init__.py
Normal file
0
openstack_tools/cmd/cleanup/__init__.py
Normal file
79
openstack_tools/cmd/cleanup/openvswitch.py
Normal file
79
openstack_tools/cmd/cleanup/openvswitch.py
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# Copyright 2020 VEXXHOST, Inc.
|
||||||
|
#
|
||||||
|
# Licensed 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.
|
||||||
|
|
||||||
|
"""Clean-up stale Open vSwitch ports
|
||||||
|
|
||||||
|
It is possible that for some reason, when cleaning up system interfaces, that
|
||||||
|
Open vSwitch ends up with many ports inside it's configuration which don't
|
||||||
|
actually exist on the physical host anymore. This script removes them all to
|
||||||
|
reduce the size of the Open vSwitch database.
|
||||||
|
|
||||||
|
NOTE(mnaser): This tool should simply not exist. Anything in here should
|
||||||
|
only be here because we're in the process of figuring out why
|
||||||
|
we need to clean it up. The fact that this file currently
|
||||||
|
exists is a bug.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
import ovs.db.idl
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Entry-point for script."""
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='Open vSwitch Clean-up tool')
|
||||||
|
parser.add_argument('--remote', default='unix:/run/openvswitch/db.sock')
|
||||||
|
parser.add_argument('--schema',
|
||||||
|
default='/usr/share/openvswitch/vswitch.ovsschema')
|
||||||
|
parser.add_argument('--apply', action='store_true')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
schema_helper = ovs.db.idl.SchemaHelper(args.schema)
|
||||||
|
schema_helper.register_columns("Open_vSwitch", ["bridges"])
|
||||||
|
schema_helper.register_columns("Bridge", ["name", "ports"])
|
||||||
|
schema_helper.register_columns("Port", ["name", "interfaces"])
|
||||||
|
schema_helper.register_columns("Interface", [])
|
||||||
|
|
||||||
|
idl = ovs.db.idl.Idl(args.remote, schema_helper)
|
||||||
|
|
||||||
|
seq_no = idl.change_seqno
|
||||||
|
while True:
|
||||||
|
idl.run()
|
||||||
|
|
||||||
|
if seq_no == idl.change_seqno:
|
||||||
|
poller = ovs.poller.Poller()
|
||||||
|
idl.wait(poller)
|
||||||
|
poller.block()
|
||||||
|
continue
|
||||||
|
|
||||||
|
seq_no = idl.change_seqno
|
||||||
|
break
|
||||||
|
|
||||||
|
for _, bridge in idl.tables["Bridge"].rows.items():
|
||||||
|
ports = []
|
||||||
|
|
||||||
|
for port in bridge.ports:
|
||||||
|
assert len(port.interfaces) == 1
|
||||||
|
interface = port.interfaces[0]
|
||||||
|
|
||||||
|
if interface.ofport == [-1]:
|
||||||
|
print("%s is invalid" % interface.name)
|
||||||
|
continue
|
||||||
|
ports.append(port)
|
||||||
|
|
||||||
|
txn = ovs.db.idl.Transaction(idl)
|
||||||
|
bridge.ports = ports
|
||||||
|
txn.commit_block()
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
ovs
|
28
setup.cfg
Normal file
28
setup.cfg
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
[metadata]
|
||||||
|
name = openstack-tools
|
||||||
|
summary = OpenStack system tools
|
||||||
|
description-file =
|
||||||
|
README.rst
|
||||||
|
author = VEXXHOST, Inc.
|
||||||
|
author-email = devops@vexxhost.com
|
||||||
|
home-page = https://opendev.org/vexxhost/openstack-tools
|
||||||
|
python-requires = >=3.6
|
||||||
|
classifier =
|
||||||
|
Environment :: OpenStack
|
||||||
|
Intended Audience :: Information Technology
|
||||||
|
Intended Audience :: System Administrators
|
||||||
|
License :: OSI Approved :: Apache Software License
|
||||||
|
Operating System :: POSIX :: Linux
|
||||||
|
Programming Language :: Python
|
||||||
|
Programming Language :: Python :: 3
|
||||||
|
Programming Language :: Python :: 3.6
|
||||||
|
Programming Language :: Python :: 3.7
|
||||||
|
Programming Language :: Python :: 3.8
|
||||||
|
|
||||||
|
[files]
|
||||||
|
packages =
|
||||||
|
openstack_tools
|
||||||
|
|
||||||
|
[entry_points]
|
||||||
|
console_scripts =
|
||||||
|
openstack-cleanup-openvswitch = openstack_tools.cmd.cleanup.openvswitch:main
|
19
setup.py
Normal file
19
setup.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Copyright 2020 VEXXHOST, Inc.
|
||||||
|
#
|
||||||
|
# Licensed 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.
|
||||||
|
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['pbr'],
|
||||||
|
pbr=True)
|
2
test-requirements.txt
Normal file
2
test-requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
flake8
|
||||||
|
pylint
|
Loading…
Reference in New Issue
Block a user