mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-30 05:40:06 +00:00
sysutils/py-google-compute-engine: update to 2.8.6
PR: 232439 Submitted by: Lucas Kanashiro <lucas.kanashiro@collabora.com> Approved by: Helen Koike <helen.koike@collabora.com> (maintainer, earlier version of patch)
This commit is contained in:
parent
7d4313e170
commit
bce434d4f5
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=485701
@ -1,10 +1,8 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PORTNAME= google-compute-engine
|
||||
DISTVERSION= 2.8.3
|
||||
PORTREVISION= 2
|
||||
DISTVERSION= 2.8.6
|
||||
CATEGORIES= sysutils python
|
||||
MASTER_SITES= CHEESESHOP
|
||||
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
|
||||
|
||||
MAINTAINER= helen.koike@collabora.com
|
||||
@ -21,9 +19,15 @@ RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}boto>0:devel/py-boto@${PY_FLAVOR} \
|
||||
|
||||
USES= python shebangfix
|
||||
USE_PYTHON= autoplist concurrent distutils
|
||||
|
||||
NO_ARCH= yes
|
||||
SHEBANG_FILES= scripts/set_multiqueue scripts/optimize_local_ssd
|
||||
|
||||
USE_GITHUB= yes
|
||||
GH_ACCOUNT= GoogleCloudPlatform
|
||||
GH_PROJECT= compute-image-packages
|
||||
GH_TAGNAME= 20181011
|
||||
|
||||
USE_RC_SUBR= google_instance_setup \
|
||||
google_accounts_daemon \
|
||||
google_clock_skew_daemon \
|
||||
|
@ -1,3 +1,3 @@
|
||||
TIMESTAMP = 1528807896
|
||||
SHA256 (google-compute-engine-2.8.3.tar.gz) = 14947a0cfc20e1d64d1184bbd137b9f3b66d7c94efcbe1b73e21c090e7002af4
|
||||
SIZE (google-compute-engine-2.8.3.tar.gz) = 45988
|
||||
TIMESTAMP = 1540947814
|
||||
SHA256 (GoogleCloudPlatform-compute-image-packages-2.8.6-20181011_GH0.tar.gz) = c9fb44fb8c4bbde108a2aeba44f11938c7840256ca078804ec3c720a47e79144
|
||||
SIZE (GoogleCloudPlatform-compute-image-packages-2.8.6-20181011_GH0.tar.gz) = 147405
|
||||
|
@ -1,11 +0,0 @@
|
||||
--- google_compute_engine/constants.py.orig 2018-06-11 23:51:09 UTC
|
||||
+++ google_compute_engine/constants.py
|
||||
@@ -18,7 +18,7 @@
|
||||
import platform
|
||||
|
||||
OSLOGIN_CONTROL_SCRIPT = 'google_oslogin_control'
|
||||
-OSLOGIN_NSS_CACHE = '/etc/oslogin_passwd.cache'
|
||||
+OSLOGIN_NSS_CACHE = '/usr/local/etc/oslogin_passwd.cache'
|
||||
OSLOGIN_NSS_CACHE_SCRIPT = 'google_oslogin_nss_cache'
|
||||
|
||||
if platform.system() == 'FreeBSD':
|
@ -1,22 +0,0 @@
|
||||
--- google_compute_engine/networking/ip_forwarding/ip_forwarding.py.orig 2018-06-11 23:51:09 UTC
|
||||
+++ google_compute_engine/networking/ip_forwarding/ip_forwarding.py
|
||||
@@ -85,15 +85,17 @@ class IpForwarding(object):
|
||||
for address in forwarded_ips:
|
||||
self.ip_forwarding_utils.RemoveForwardedIp(address, interface)
|
||||
|
||||
- def HandleForwardedIps(self, interface, forwarded_ips):
|
||||
+ def HandleForwardedIps(self, interface, forwarded_ips, interface_ip):
|
||||
"""Handle changes to the forwarded IPs on a network interface.
|
||||
|
||||
Args:
|
||||
interface: string, the output device to configure.
|
||||
forwarded_ips: list, the forwarded IP address strings desired.
|
||||
+ interface_ip: string, current interface ip address.
|
||||
"""
|
||||
desired = self.ip_forwarding_utils.ParseForwardedIps(forwarded_ips)
|
||||
- configured = self.ip_forwarding_utils.GetForwardedIps(interface)
|
||||
+ configured = self.ip_forwarding_utils.GetForwardedIps(
|
||||
+ interface, interface_ip)
|
||||
to_add = sorted(set(desired) - set(configured))
|
||||
to_remove = sorted(set(configured) - set(desired))
|
||||
self._LogForwardedIpChanges(
|
@ -1,115 +0,0 @@
|
||||
--- google_compute_engine/networking/ip_forwarding/ip_forwarding_utils.py.orig 2018-06-11 23:51:09 UTC
|
||||
+++ google_compute_engine/networking/ip_forwarding/ip_forwarding_utils.py
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
"""Utilities for configuring IP address forwarding."""
|
||||
|
||||
+import netaddr
|
||||
+import netifaces
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
@@ -32,27 +34,11 @@ class IpForwardingUtils(object):
|
||||
logger: logger object, used to write to SysLog and serial port.
|
||||
proto_id: string, the routing protocol identifier for Google IP changes.
|
||||
"""
|
||||
- self.logger = logger
|
||||
- self.proto_id = proto_id or '66'
|
||||
|
||||
- def _CreateRouteOptions(self, **kwargs):
|
||||
- """Create a dictionary of parameters to append to the ip route command.
|
||||
-
|
||||
- Args:
|
||||
- **kwargs: dict, the string parameters to update in the ip route command.
|
||||
-
|
||||
- Returns:
|
||||
- dict, the string parameters to append to the ip route command.
|
||||
- """
|
||||
- options = {
|
||||
- 'proto': self.proto_id,
|
||||
- 'scope': 'host',
|
||||
- }
|
||||
- options.update(kwargs)
|
||||
- return options
|
||||
+ self.logger = logger
|
||||
|
||||
- def _RunIpRoute(self, args=None, options=None):
|
||||
- """Run a command with ip route and return the response.
|
||||
+ def _RunIfconfig(self, args=None, options=None):
|
||||
+ """Run a command with ifconfig and return the response.
|
||||
|
||||
Args:
|
||||
args: list, the string ip route command args to execute.
|
||||
@@ -63,7 +49,7 @@ class IpForwardingUtils(object):
|
||||
"""
|
||||
args = args or []
|
||||
options = options or {}
|
||||
- command = ['ip', 'route']
|
||||
+ command = ['ifconfig']
|
||||
command.extend(args)
|
||||
for item in options.items():
|
||||
command.extend(item)
|
||||
@@ -94,25 +80,33 @@ class IpForwardingUtils(object):
|
||||
forwarded_ips = forwarded_ips or []
|
||||
for ip in forwarded_ips:
|
||||
if ip and (IP_REGEX.match(ip) or IP_ALIAS_REGEX.match(ip)):
|
||||
- addresses.append(ip[:-3] if ip.endswith('/32') else ip)
|
||||
+ addresses.extend([str(addr) for addr in list(netaddr.IPNetwork(ip))])
|
||||
else:
|
||||
self.logger.warning('Could not parse IP address: "%s".', ip)
|
||||
return addresses
|
||||
|
||||
- def GetForwardedIps(self, interface):
|
||||
+ def GetForwardedIps(self, interface, interface_ip):
|
||||
"""Retrieve the list of configured forwarded IP addresses.
|
||||
|
||||
Args:
|
||||
interface: string, the output device to query.
|
||||
+ interface_ip: string, current interface ip address.
|
||||
|
||||
Returns:
|
||||
list, the IP address strings.
|
||||
"""
|
||||
- args = ['ls', 'table', 'local', 'type', 'local']
|
||||
- options = self._CreateRouteOptions(dev=interface)
|
||||
- result = self._RunIpRoute(args=args, options=options)
|
||||
- result = re.sub(r'local\s', r'', result)
|
||||
- return self.ParseForwardedIps(result.split())
|
||||
+ try:
|
||||
+ ips = netifaces.ifaddresses(interface)
|
||||
+ ips = ips[netifaces.AF_INET]
|
||||
+ except (ValueError, IndexError):
|
||||
+ return []
|
||||
+ forwarded_ips = []
|
||||
+ for ip in ips:
|
||||
+ if ip['addr'] != interface_ip:
|
||||
+ forwarded_ips.append(
|
||||
+ '%s/%d' % (ip['addr'],
|
||||
+ netaddr.IPAddress(ip['netmask']).netmask_bits()))
|
||||
+ return self.ParseForwardedIps(forwarded_ips)
|
||||
|
||||
def AddForwardedIp(self, address, interface):
|
||||
"""Configure a new IP address on the network interface.
|
||||
@@ -121,10 +115,8 @@ class IpForwardingUtils(object):
|
||||
address: string, the IP address to configure.
|
||||
interface: string, the output device to use.
|
||||
"""
|
||||
- address = address if IP_ALIAS_REGEX.match(address) else '%s/32' % address
|
||||
- args = ['add', 'to', 'local', address]
|
||||
- options = self._CreateRouteOptions(dev=interface)
|
||||
- self._RunIpRoute(args=args, options=options)
|
||||
+ for ip in list(netaddr.IPNetwork(address)):
|
||||
+ self._RunIfconfig(args=[interface, 'alias', '%s/32' % str(ip)])
|
||||
|
||||
def RemoveForwardedIp(self, address, interface):
|
||||
"""Delete an IP address on the network interface.
|
||||
@@ -133,7 +125,5 @@ class IpForwardingUtils(object):
|
||||
address: string, the IP address to configure.
|
||||
interface: string, the output device to use.
|
||||
"""
|
||||
- address = address if IP_ALIAS_REGEX.match(address) else '%s/32' % address
|
||||
- args = ['delete', 'to', 'local', address]
|
||||
- options = self._CreateRouteOptions(dev=interface)
|
||||
- self._RunIpRoute(args=args, options=options)
|
||||
+ ip = netaddr.IPNetwork(address)
|
||||
+ self._RunIfconfig(args=[interface, '-alias', str(ip.ip)])
|
@ -1,33 +0,0 @@
|
||||
--- google_compute_engine/networking/network_daemon.py.orig 2018-06-11 23:51:09 UTC
|
||||
+++ google_compute_engine/networking/network_daemon.py
|
||||
@@ -96,7 +96,7 @@ class NetworkDaemon(object):
|
||||
for interface in network_interfaces:
|
||||
if self.ip_forwarding_enabled:
|
||||
self.ip_forwarding.HandleForwardedIps(
|
||||
- interface.name, interface.forwarded_ips)
|
||||
+ interface.name, interface.forwarded_ips, interface.ip)
|
||||
|
||||
def _ExtractInterfaceMetadata(self, metadata):
|
||||
"""Extracts network interface metadata.
|
||||
@@ -119,7 +119,8 @@ class NetworkDaemon(object):
|
||||
if self.target_instance_ips:
|
||||
ip_addresses.extend(network_interface.get('targetInstanceIps', []))
|
||||
interfaces.append(NetworkDaemon.NetworkInterface(
|
||||
- interface, ip_addresses))
|
||||
+ interface, ip_addresses, network_interface.get('ip', [])))
|
||||
+
|
||||
else:
|
||||
message = 'Network interface not found for MAC address: %s.'
|
||||
self.logger.warning(message, mac_address)
|
||||
@@ -128,9 +129,10 @@ class NetworkDaemon(object):
|
||||
class NetworkInterface(object):
|
||||
"""Network interface information extracted from metadata."""
|
||||
|
||||
- def __init__(self, name, forwarded_ips=None):
|
||||
+ def __init__(self, name, forwarded_ips=None, ip=None):
|
||||
self.name = name
|
||||
self.forwarded_ips = forwarded_ips
|
||||
+ self.ip = ip
|
||||
|
||||
|
||||
def main():
|
Loading…
Reference in New Issue
Block a user