summaryrefslogtreecommitdiff
path: root/cloudinit/netinfo.py
AgeCommit message (Collapse)Author
2022-01-26Add json parsing of ip addr show (SC-723) (#1210)James Falcon
When obtaining information from "ip addr", default to using "ip --json addr" rather than using regex to parse "ip addr show" as json is machine readable as less prone to error. Deprecate but leave fallback to use "ip addr" for older iproute2 tooling which does not support --json param. Fix regex parsing of "ip addr" to support peer addresses and metrics.
2021-12-15Adopt Black and isort (SC-700) (#1157)James Falcon
Applied Black and isort, fixed any linting issues, updated tox.ini and CI.
2020-06-08Move subp into its own module. (#416)Scott Moser
This was painful, but it finishes a TODO from cloudinit/subp.py. It moves the following from util to subp: ProcessExecutionError subp which target_path I moved subp_blob_in_tempfile into cc_chef, which is its only caller. That saved us from having to deal with it using write_file and temp_utils from subp (which does not import any cloudinit things now). It is arguable that 'target_path' could be moved to a 'path_utils' or something, but in order to use it from subp and also from utils, we had to get it out of utils.
2020-03-12Add Netbsd support (#62)Gonéri Le Bouder
Add support for the NetBSD Operating System. Features in this branch: * Add BSD distro parent class from which NetBSD and FreeBSD can specialize * Add *bsd util functions to cloudinit.net and cloudinit.net.bsd_utils * subclass cloudinit.distro.freebsd.Distro from bsd.Distro * Add new cloudinit.distro.netbsd and cloudinit.net.renderer for netbsd * Add lru_cached util.is_NetBSD functions * Add NetBSD detection for ConfigDrive and NoCloud datasources This branch has been tested with: - NoCloud and OpenStack (with and without config-drive) - NetBSD 8.1. and 9.0 - FreeBSD 11.2 and 12.1 - Python 3.7 only, because of the dependency oncrypt.METHOD_BLOWFISH. This version is available in NetBSD 7, 8 and 9 anyway
2019-12-13cloudinit/netinfo: remove unused getgateway (#111)Daniel Watkins
2019-02-08netinfo: Adjust ifconfig output parsing for FreeBSD ipv6 entriesRyan Harper
FreeBSD ifconfig output for ipv6 addrs doesn't find scopeid values when present in the output and the pformat rendering assumes that an ipv6 address will have a 'scope6' entry in the netdev info dictionary. This patch finds the scopeid value, which is not always inside <>, and in some cases v6 addrs don't have a scopeid value in the output, so when rendering the table, allow scope6 value to be replaced with the empty value. LP: #1779672
2018-05-04pycodestyle: Fix deprecated string literals, move away from flake8.Chad Smith
Fix remaining pycodesytle warnings related to invalid string literals introduced in more recent pycodeflakes versions https://bugs.python.org/issue27364 . Also stop using flake8 in tox as it is incompatible with newer versions of pyflakes. Instead we now add tox environments for pycodestyle and pyflakes individually. Set the versions in both pycodestyle and pyflakes to the currently available versions.
2018-05-01netinfo: fix netdev_pformat when a nic does not have an address assigned.Scott Moser
The last set of changes to netdev_pformat ended up dropping the output of devices that were not up. This adds back the 'down' interfaces to the rendered output. LP: #1766302
2018-04-18net: Depend on iproute2's ip instead of net-tools ifconfig or routeChad Smith
The net-tools package is deprecated and will eventually be dropped. Use "ip route", "link" or "address" instead of "ifconfig" or "route" calls. Cloud-init can now run in an environment that no longer has net-tools. This affects the network and route printing emitted to cloud-config-output.log as well as the cc_disable_ec2_metadata module. Additional changes:  - separate readResource and resourceLocation into standalone test    functions  - Fix ipv4 address rows to report scopes represented by ip addr show  - Formatted route/address ouput now handles multiple ipv4 and ipv6    addresses on a single interface Co-authored-by: James Hogarth <james.hogarth@gmail.com> Co-authored-by: Robert Schweikert <rjschwei@suse.com>
2017-10-10simpletable: Fix get_string method to return table-formatted stringChad Smith
Output in cloud-init-output.log contained only the string representation of a SimpleTable object instead of the table formatted content. This bug also affected ssh_authkey_fingerprints. LP: #1722566
2017-10-02Remove prettytable dependency, introduce simpletableAndrew Jorgensen
The first revision of this rendered tables with less decoration but there was a desire upstream to avoid possibly breaking some parsing someone might be doing, so it has been revised to render the same as prettytable for the cases cloud-init actually uses.
2017-06-12net: Allow netinfo subprocesses to return 0 or 1.Ryan Harper
On systems with selinux enabled, some of the networking commands executed successfully do not return 0. Allow these commands to return 1 since the output is valid. Ultimately we need to get this information in some way so that we can display it correctly. For now, work around the stack trace when selinux does not allow us to collect it. LP: #1686751
2016-12-22LICENSE: Allow dual licensing GPL-3 or Apache 2.0Jon Grimm
This has been a recurring ask and we had initially just made the change to the cloud-init 2.0 codebase. As the current thinking is we'll just continue to enhance the current codebase, its desirable to relicense to match what we'd intended as part of the 2.0 plan here. - put a brief description of license in LICENSE file - put full license versions in LICENSE-GPLv3 and LICENSE-Apache2.0 - simplify the per-file header to reference LICENSE - tox: ignore H102 (Apache License Header check) Add license header to files that ship. Reformat headers, make sure everything has vi: at end of file. Non-shipping files do not need the copyright header, but at the moment tests/ have it.
2016-05-12Fix logging importJoshua Harlow
2016-05-12Fix up a ton of flake8 issuesJoshua Harlow
2015-01-21Largely merge lp:~harlowja/cloud-init/py2-3 albeit manually because it seemedBarry Warsaw
to be behind trunk. `tox -e py27` passes full test suite. Now to work on replacing mocker.
2014-11-30Fix some whitespace issuesJoshua Harlow
2014-11-30Fix the ipv6 header centeringJoshua Harlow
2014-11-30Fix the getgateway functionJoshua Harlow
After the routeinfo function started to return a dictionary containing ipv4 and ipv6 information we now need to make sure we search the appropriate key.
2014-11-30Be more tolerant of missing informationJoshua Harlow
Instead of failing when IPv6 information is not found we should be more tolerant of said information not existing so that we behave like the pre IPv6 addition.
2014-11-21Add IPv6 Support for Rhel.Shraddha Pandhe
This patch does the following: 1. Adds support to process network config with IPv6 2. Adds support to display 'ifconfig -a' information for IPv6 3. Adds support to display routing information for IPv6
2014-09-12netinfo: log error on failure of route infoScott Moser
2014-07-24pep8 fixes (2 unrelated to this mp)Scott Moser
2014-02-26netinfo.py: fix regression causing ubuntu to show 'addr:v.x.y.z'Scott Moser
after freebsd merge, ubuntu shows addr:v.x.y.z instead of v.x.y.z for the ipv4 address. This should fix that by just skipping the 'inet' (or inet6) token if the next token starts with 'addr:'. LP: #1285185
2014-01-24pylint and long line fixes.Scott Moser
This fixes up many long lines to be < 80 chars and some other pylint issues. pylint 1.1 (in trusty) is now complaining about the lazy logging, so I'll clean that up when I touch things.
2014-01-23pep8Scott Moser
2013-12-14fix: Fallback to check the interface state, specifically freebsd benefitsHarm Weites
of this.
2013-12-06new: FreeBSD module to support cloud-init on the FBSD10 platform. In itsHarm Weites
current form its still missing some modules though. Supported: -SSH-keys -growpart -growfs -adduser -powerstate
2012-06-29Readd the original prefix to the netinfo (if provided).Joshua Harlow
2012-06-16Unused import removedJoshua Harlow
2012-06-16For now just stick to using newline joining.Joshua Harlow
2012-06-15Logic test on split up line length (just incase).Joshua Harlow
Removed un-used pre debug info option, since this is not used in the prettytable case.
2012-06-11Fix copy right.Joshua Harlow
2012-06-11Use pretty table to get a parseable format out.Joshua Harlow
2012-06-11Start of cleaning this up.Joshua Harlow
2012-06-08Remove the main function from this, seems like it should also be in a test ↵Joshua Harlow
if needed.
2012-05-22remove usage of subprocess.check_outputScott Moser
in order to work on python 2.6, replace usage of check_output with util.subp.
2012-01-30netinfo.py: minor pylint complaint on unused 'devname'Scott Moser
2012-01-20in netinfo output (ci-info:), fill in empty fields with a "."Scott Moser
If you were trying to parse this output with something, an empty field would be difficult to handle, as you'd have to know the expected lengths of each field. The '.' means empty, but then all fields are non-whitespace delimited by one or more whitespace.
2012-01-18Add HP to Copyright, and Juerg Haefliger Authors.Scott Moser
This copyright change reflects previous changes that Juerg made for pylint and pep8 cleanups. From: Juerg Haefliger <juerg.haefliger@hp.com> Date: Mon, 16 Jan 2012 10:45:12 +0100
2012-01-17[PATCH] PEP8 coding style fixes.Scott Moser
From: Juerg Haefliger <juerg.haefliger@hp.com> This pulls in the named patch for LP: #914739 with a few other changes.
2012-01-17[PATCH 3/4] Fix pylint conventions C0324 (comma not followed by a space)Scott Moser
From: Juerg Haefliger <juerg.haefliger@hp.com>
2012-01-12[PATCH 06/13] Fix pylint warnings W0612 (unused variable)Scott Moser
From: Juerg Haefliger <juerg.haefliger@hp.com>
2012-01-12[PATCH 01/13] Fix pylint warnings W0311 (bad indentation)Scott Moser
From: Juerg Haefliger <juerg.haefliger@hp.com>
2011-10-31fix bug in netinfo.debug_info if no network devices availableScott Moser
LP: #883367
2011-08-22Add some network debug info printed to the consoleScott Moser
When 'cloud-init start' (network) runs, it will print information about the systems network info to the console. This will help in debugging instances. LP: #828186