Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153210430
D12077.id32254.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
35 KB
Referenced Files
None
Subscribers
None
D12077.id32254.diff
View Options
Index: head/sysutils/Makefile
===================================================================
--- head/sysutils/Makefile
+++ head/sysutils/Makefile
@@ -882,6 +882,7 @@
SUBDIR += py-freenas.cli
SUBDIR += py-glances
SUBDIR += py-gmailfs-fuse
+ SUBDIR += py-google-compute-engine
SUBDIR += py-halite
SUBDIR += py-honcho
SUBDIR += py-iowait
Index: head/sysutils/py-google-compute-engine/Makefile
===================================================================
--- head/sysutils/py-google-compute-engine/Makefile
+++ head/sysutils/py-google-compute-engine/Makefile
@@ -0,0 +1,44 @@
+# $FreeBSD$
+
+PORTNAME= google-compute-engine
+PORTVERSION= 2.4.1
+CATEGORIES= sysutils python
+MASTER_SITES= CHEESESHOP
+PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER= helen.koike@collabora.com
+COMMENT= Guest Environment for Google Compute Engine
+
+LICENSE= APACHE20
+LICENSE_FILE= ${WRKSRC}/LICENSE
+
+RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}boto>0:devel/py-boto \
+ ${PYTHON_PKGNAMEPREFIX}netaddr>0:net/py-netaddr \
+ ${PYTHON_PKGNAMEPREFIX}netifaces>0:net/py-netifaces \
+ sudo:security/sudo
+
+USES= python
+USE_PYTHON= autoplist concurrent distutils
+
+USE_RC_SUBR= google_instance_setup \
+ google_network_setup \
+ google_accounts_daemon \
+ google_clock_skew_daemon \
+ google_startup
+
+NO_ARCH= yes
+
+SUB_LIST= PYTHON_CMD="${PYTHON_CMD}"
+REINPLACE_ARGS= -i ''
+
+post-patch:
+ @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' \
+ ${WRKSRC}/google_compute_engine/accounts/accounts_utils.py \
+ ${WRKSRC}/google_compute_engine/boto/boto_config.py \
+ ${WRKSRC}/google_compute_engine/boto/compute_auth.py \
+ ${WRKSRC}/google_compute_engine/config_manager.py \
+ ${WRKSRC}/google_compute_engine/instance_setup/instance_config.py \
+ ${WRKSRC}/google_compute_engine/metadata_scripts/script_executor.py \
+ ${WRKSRC}/google_compute_engine/network_setup/network_setup.py
+
+.include <bsd.port.mk>
Index: head/sysutils/py-google-compute-engine/distinfo
===================================================================
--- head/sysutils/py-google-compute-engine/distinfo
+++ head/sysutils/py-google-compute-engine/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1501403910
+SHA256 (google-compute-engine-2.4.1.tar.gz) = d1709420ade5e7b8318b73c8ae245382cfe362e0f9b5236d3a28c0459a6d8d49
+SIZE (google-compute-engine-2.4.1.tar.gz) = 28626
Index: head/sysutils/py-google-compute-engine/files/google_accounts_daemon.in
===================================================================
--- head/sysutils/py-google-compute-engine/files/google_accounts_daemon.in
+++ head/sysutils/py-google-compute-engine/files/google_accounts_daemon.in
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: google_accounts_daemon
+# BEFORE: LOGIN
+# REQUIRE: NETWORKING syslogd google_instance_setup google_network_setup
+# KEYWORD: shutdown
+#
+# google_accounts_daemon_enable (bool): Set to NO by default.
+# Set it to YES to enable google_accounts_daemon.
+#
+
+. /etc/rc.subr
+
+name="google_accounts_daemon"
+rcvar="google_accounts_daemon_enable"
+
+load_rc_config "${name}"
+
+: ${google_accounts_daemon_enable:="NO"}
+
+command_interpreter="%%PYTHON_CMD%%"
+command=%%PREFIX%%/bin/${name}
+pidfile=/var/run/${name}.pid
+start_cmd="google_accounts_daemon_start"
+
+google_accounts_daemon_start()
+{
+ check_startmsgs && echo "Starting ${name}."
+ daemon -p ${pidfile} -t ${name} ${command}
+}
+
+run_rc_command "$1"
Index: head/sysutils/py-google-compute-engine/files/google_clock_skew_daemon.in
===================================================================
--- head/sysutils/py-google-compute-engine/files/google_clock_skew_daemon.in
+++ head/sysutils/py-google-compute-engine/files/google_clock_skew_daemon.in
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: google_clock_skew_daemon
+# BEFORE: LOGIN
+# REQUIRE: NETWORKING syslogd google_instance_setup google_network_setup
+# KEYWORD: shutdown
+#
+# google_clock_skew_daemon_enable (bool): Set to NO by default.
+# Set it to YES to enable google_clock_skew_daemon.
+#
+
+. /etc/rc.subr
+
+name="google_clock_skew_daemon"
+rcvar="google_clock_skew_daemon_enable"
+
+load_rc_config "${name}"
+
+: ${google_clock_skew_daemon_enable:="NO"}
+
+command_interpreter="%%PYTHON_CMD%%"
+command=%%PREFIX%%/bin/${name}
+pidfile=/var/run/${name}.pid
+start_cmd="google_clock_skew_daemon_start"
+
+google_clock_skew_daemon_start()
+{
+ check_startmsgs && echo "Starting ${name}."
+ daemon -p ${pidfile} -t ${name} ${command}
+}
+
+run_rc_command "$1"
Index: head/sysutils/py-google-compute-engine/files/google_instance_setup.in
===================================================================
--- head/sysutils/py-google-compute-engine/files/google_instance_setup.in
+++ head/sysutils/py-google-compute-engine/files/google_instance_setup.in
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: google_instance_setup
+# BEFORE: LOGIN
+# REQUIRE: NETWORKING syslogd
+#
+# google_instance_setup_enable (bool): Set to NO by default.
+# Set it to YES to enable google_instance_setup.
+#
+
+. /etc/rc.subr
+
+name="google_instance_setup"
+rcvar="google_instance_setup_enable"
+
+load_rc_config "${name}"
+
+: ${google_instance_setup_enable:="NO"}
+
+command_interpreter="%%PYTHON_CMD%%"
+command=%%PREFIX%%/bin/${name}
+pidfile=/var/run/${name}.pid
+
+run_rc_command "$1"
Index: head/sysutils/py-google-compute-engine/files/google_ip_forwarding_daemon.in
===================================================================
--- head/sysutils/py-google-compute-engine/files/google_ip_forwarding_daemon.in
+++ head/sysutils/py-google-compute-engine/files/google_ip_forwarding_daemon.in
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: google_ip_forwarding_daemon
+# BEFORE: LOGIN
+# REQUIRE: NETWORKING syslogd google_instance_setup google_network_setup
+# KEYWORD: shutdown
+#
+# google_ip_forwarding_daemon_enable (bool): Set to NO by default.
+# Set it to YES to enable google_ip_forwarding_daemon.
+#
+
+. /etc/rc.subr
+
+name="google_ip_forwarding_daemon"
+rcvar="google_ip_forwarding_daemon_enable"
+
+load_rc_config "${name}"
+
+: ${google_ip_forwarding_daemon_enable:="NO"}
+
+command_interpreter="%%PYTHON_CMD%%"
+command=%%PREFIX%%/bin/${name}
+pidfile=/var/run/${name}.pid
+start_cmd="google_ip_forwarding_daemon_start"
+
+google_ip_forwarding_daemon_start()
+{
+ check_startmsgs && echo "Starting ${name}."
+ daemon -p ${pidfile} -t ${name} ${command}
+}
+
+run_rc_command "$1"
Index: head/sysutils/py-google-compute-engine/files/google_network_setup.in
===================================================================
--- head/sysutils/py-google-compute-engine/files/google_network_setup.in
+++ head/sysutils/py-google-compute-engine/files/google_network_setup.in
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: google_network_setup
+# BEFORE: LOGIN
+# REQUIRE: NETWORKING syslogd google_instance_setup
+#
+# google_network_setup_enable (bool): Set to NO by default.
+# Set it to YES to enable google_network_setup.
+#
+
+. /etc/rc.subr
+
+name="google_network_setup"
+rcvar="google_network_setup_enable"
+
+load_rc_config "${name}"
+
+: ${google_network_setup_enable:="NO"}
+
+command_interpreter="%%PYTHON_CMD%%"
+command=%%PREFIX%%/bin/${name}
+pidfile=/var/run/${name}.pid
+
+run_rc_command "$1"
Index: head/sysutils/py-google-compute-engine/files/google_startup.in
===================================================================
--- head/sysutils/py-google-compute-engine/files/google_startup.in
+++ head/sysutils/py-google-compute-engine/files/google_startup.in
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: google_startup
+# BEFORE: LOGIN
+# REQUIRE: NETWORKING syslogd google_instance_setup google_network_setup
+# KEYWORD: shutdown
+#
+# google_startup_enable (bool): Set to NO by default.
+# Set it to YES to enable google_startup.
+#
+
+. /etc/rc.subr
+
+name="google_startup"
+rcvar="google_startup_enable"
+
+load_rc_config "${name}"
+
+: ${google_startup_enable:="NO"}
+
+command_interpreter="%%PYTHON_CMD%%"
+command=%%PREFIX%%/bin/google_metadata_script_runner
+command_startup_args="--script-type startup"
+command_shutdown_args="--script-type shutdown"
+pidfile=/var/run/${name}.pid
+start_cmd="google_startup_start"
+stop_cmd="google_startup_stop"
+
+google_startup_start()
+{
+ ${command} ${command_startup_args}
+}
+
+google_startup_stop()
+{
+ echo "Stopping ${name}."
+ ${command} ${command_shutdown_args}
+}
+
+run_rc_command "$1"
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_accounts_accounts__daemon.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_accounts_accounts__daemon.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_accounts_accounts__daemon.py
@@ -0,0 +1,14 @@
+This patch won't be necessary anymore in further versions.
+See https://github.com/GoogleCloudPlatform/compute-image-packages/pull/440
+
+--- google_compute_engine/accounts/accounts_daemon.py.orig 2017-07-18 16:43:14 UTC
++++ google_compute_engine/accounts/accounts_daemon.py
+@@ -27,7 +27,7 @@ from google_compute_engine import logger
+ from google_compute_engine import metadata_watcher
+ from google_compute_engine.accounts import accounts_utils
+
+-LOCKFILE = '/var/lock/google_accounts.lock'
++LOCKFILE = '/var/spool/lock/google_accounts.lock'
+
+
+ class AccountsDaemon(object):
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_accounts_accounts__utils.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_accounts_accounts__utils.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_accounts_accounts__utils.py
@@ -0,0 +1,52 @@
+This patch won't be necessary anymore in further versions.
+See https://github.com/GoogleCloudPlatform/compute-image-packages/pull/440
+
+--- google_compute_engine/accounts/accounts_utils.py.orig 2017-07-23 07:12:16 UTC
++++ google_compute_engine/accounts/accounts_utils.py
+@@ -43,8 +43,8 @@ class AccountsUtils(object):
+ """
+ self.logger = logger
+ self.google_sudoers_group = 'google-sudoers'
+- self.google_sudoers_file = '/etc/sudoers.d/google_sudoers'
+- self.google_users_dir = '/var/lib/google'
++ self.google_sudoers_file = '%%PREFIX%%/etc/sudoers.d/google_sudoers'
++ self.google_users_dir = '%%PREFIX%%/var/lib/google'
+ self.google_users_file = os.path.join(self.google_users_dir, 'google_users')
+
+ self._CreateSudoersGroup()
+@@ -71,7 +71,7 @@ class AccountsUtils(object):
+ """Create a Linux group for Google added sudo user accounts."""
+ if not self._GetGroup(self.google_sudoers_group):
+ try:
+- subprocess.check_call(['groupadd', self.google_sudoers_group])
++ subprocess.check_call(['pw', 'groupadd', self.google_sudoers_group])
+ except subprocess.CalledProcessError as e:
+ self.logger.warning('Could not create the sudoers group. %s.', str(e))
+
+@@ -126,7 +126,7 @@ class AccountsUtils(object):
+ #
+ # To solve the issue, make the password '*' which is also recognized
+ # as locked but does not prevent SSH login.
+- command = ['useradd', '-m', '-s', '/bin/bash', '-p', '*', user]
++ command = ['pw', 'useradd', user, '-m']
+ try:
+ subprocess.check_call(command)
+ except subprocess.CalledProcessError as e:
+@@ -148,7 +148,7 @@ class AccountsUtils(object):
+ """
+ groups = ','.join(groups)
+ self.logger.debug('Updating user %s with groups %s.', user, groups)
+- command = ['usermod', '-G', groups, user]
++ command = ['pw', 'usermod', user, '-G', groups]
+ try:
+ subprocess.check_call(command)
+ except subprocess.CalledProcessError as e:
+@@ -317,7 +317,7 @@ class AccountsUtils(object):
+ """
+ self.logger.info('Removing user %s.', user)
+ if self.remove:
+- command = ['userdel', '-r', user]
++ command = ['pw', 'userdel', user, '-r']
+ try:
+ subprocess.check_call(command)
+ except subprocess.CalledProcessError as e:
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_boto_boto__config.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_boto_boto__config.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_boto_boto__config.py
@@ -0,0 +1,27 @@
+This patch won't be necessary anymore in further versions.
+See https://github.com/GoogleCloudPlatform/compute-image-packages/pull/440
+
+--- google_compute_engine/boto/boto_config.py.orig 2017-07-23 07:12:16 UTC
++++ google_compute_engine/boto/boto_config.py
+@@ -18,8 +18,8 @@
+ If a project ID is not provided, this request the project ID from the
+ metadata server and install the compute authentication plugin.
+
+-Note the config starts with the content in /etc/boto.cfg.template,
+-overrides settings, and then persists it into /etc/boto.cfg. This
++Note the config starts with the content in %%PREFIX%%/etc/boto.cfg.template,
++overrides settings, and then persists it into %%PREFIX%%/etc/boto.cfg. This
+ is done so that the system boto.cfg can be removed prior to image
+ packaging.
+ """
+@@ -34,8 +34,8 @@ from google_compute_engine import metada
+ class BotoConfig(object):
+ """Creates a boto config file for standalone GSUtil."""
+
+- boto_config = '/etc/boto.cfg'
+- boto_config_template = '/etc/boto.cfg.template'
++ boto_config = '%%PREFIX%%/etc/boto.cfg'
++ boto_config_template = '%%PREFIX%%/etc/boto.cfg.template'
+ boto_config_script = os.path.abspath(__file__)
+ boto_config_header = (
+ 'This file is automatically created at boot time by the %s script. Do '
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_boto_compute__auth.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_boto_compute__auth.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_boto_compute__auth.py
@@ -0,0 +1,13 @@
+This is only a cosmetic patch as it fixes docs and not execution
+
+--- google_compute_engine/boto/compute_auth.py.orig 2017-07-23 07:12:16 UTC
++++ google_compute_engine/boto/compute_auth.py
+@@ -29,7 +29,7 @@ GS_SCOPES = set([
+ class ComputeAuth(auth_handler.AuthHandler):
+ """Google Compute service account auth handler.
+
+- The boto library reads the system config file (/etc/boto.cfg) and looks
++ The boto library reads the system config file (%%PREFIX%%/etc/boto.cfg) and looks
+ at a config value called 'plugin_directory'. It then loads the Python
+ files and find classes derived from boto.auth_handler.AuthHandler.
+ """
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_clock__skew_clock__skew__daemon.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_clock__skew_clock__skew__daemon.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_clock__skew_clock__skew__daemon.py
@@ -0,0 +1,28 @@
+BSD doesn't have hwclock, use ntpdate instead
+
+--- google_compute_engine/clock_skew/clock_skew_daemon.py.orig 2017-07-18 16:43:14 UTC
++++ google_compute_engine/clock_skew/clock_skew_daemon.py
+@@ -24,7 +24,7 @@ from google_compute_engine import file_u
+ from google_compute_engine import logger
+ from google_compute_engine import metadata_watcher
+
+-LOCKFILE = '/var/lock/google_clock_skew.lock'
++LOCKFILE = '/var/spool/lock/google_clock_skew.lock'
+
+
+ class ClockSkewDaemon(object):
+@@ -58,9 +58,12 @@ class ClockSkewDaemon(object):
+ response: string, the metadata response with the new drift token value.
+ """
+ self.logger.info('Clock drift token has changed: %s.', response)
+- command = ['/sbin/hwclock', '--hctosys']
++
++ ntpd_inactive = subprocess.call(['service', 'ntpd', 'status'])
+ try:
+- subprocess.check_call(command)
++ if not ntpd_inactive: subprocess.check_call(['service', 'ntpd', 'stop'])
++ subprocess.check_call('ntpdate `awk \'$1=="server" {print $2}\' /etc/ntp.conf`', shell=True)
++ if not ntpd_inactive: subprocess.check_call(['service', 'ntpd', 'start'])
+ except subprocess.CalledProcessError:
+ self.logger.warning('Failed to sync system time with hardware clock.')
+ else:
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_config__manager.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_config__manager.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_config__manager.py
@@ -0,0 +1,23 @@
+This patch won't be necessary anymore in further versions.
+See https://github.com/GoogleCloudPlatform/compute-image-packages/pull/440
+
+--- google_compute_engine/config_manager.py.orig 2017-07-23 07:12:16 UTC
++++ google_compute_engine/config_manager.py
+@@ -21,7 +21,7 @@ import textwrap
+ from google_compute_engine import file_utils
+ from google_compute_engine.compat import parser
+
+-CONFIG = '/etc/default/instance_configs.cfg'
++CONFIG = '%%PREFIX%%/etc/instance_configs.cfg'
+
+
+ class ConfigManager(object):
+@@ -101,7 +101,7 @@ class ConfigManager(object):
+ """
+ config_file = config_file or self.config_file
+ config_name = os.path.splitext(os.path.basename(config_file))[0]
+- config_lock = '/var/lock/google_%s.lock' % config_name
++ config_lock = '/var/spool/lock/google_%s.lock' % config_name
+ with file_utils.LockFile(config_lock):
+ with open(config_file, 'w') as config_fp:
+ if self.config_header:
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_instance__setup_instance__config.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_instance__setup_instance__config.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_instance__setup_instance__config.py
@@ -0,0 +1,49 @@
+This patch fixes the paths and disable optimization scripts used only on Linux.
+The variables won't be needed to be fixed in further versions
+See https://github.com/GoogleCloudPlatform/compute-image-packages/pull/440
+
+--- google_compute_engine/instance_setup/instance_config.py.orig 2017-07-23 07:12:16 UTC
++++ google_compute_engine/instance_setup/instance_config.py
+@@ -16,8 +16,8 @@
+ """A library used to set up the instance's default configurations file.
+
+ Note that the configurations in
+-/etc/default/instance_configs.cfg.template override the values set in
+-/etc/default/instance_configs.cfg. The system instance_configs.cfg may be
++%%PREFIX%%/etc/instance_configs.cfg.template override the values set in
++%%PREFIX%%/etc/instance_configs.cfg. The system instance_configs.cfg may be
+ overridden during package upgrade.
+ """
+
+@@ -32,7 +32,7 @@ from google_compute_engine.compat import
+ class InstanceConfig(config_manager.ConfigManager):
+ """Creates a defaults config file for instance configuration."""
+
+- instance_config = '/etc/default/instance_configs.cfg'
++ instance_config = '%%PREFIX%%/etc/instance_configs.cfg'
+ instance_config_distro = '%s.distro' % instance_config
+ instance_config_template = '%s.template' % instance_config
+ instance_config_script = os.path.abspath(__file__)
+@@ -40,7 +40,7 @@ class InstanceConfig(config_manager.Conf
+ 'This file is automatically created at boot time by the %s script. Do '
+ 'not edit this file directly. If you need to add items to this file, '
+ 'create or edit %s instead and then run '
+- '/usr/bin/google_instance_setup.')
++ '%%PREFIX%%/bin/google_instance_setup.')
+ instance_config_options = {
+ 'Accounts': {
+ 'deprovision_remove': 'false',
+@@ -55,11 +55,11 @@ class InstanceConfig(config_manager.Conf
+ 'instance_id': '0',
+ },
+ 'InstanceSetup': {
+- 'optimize_local_ssd': 'true',
++ 'optimize_local_ssd': 'false',
+ 'network_enabled': 'true',
+ 'set_boto_config': 'true',
+ 'set_host_keys': 'true',
+- 'set_multiqueue': 'true',
++ 'set_multiqueue': 'false',
+ },
+ 'IpForwarding': {
+ 'ethernet_proto_id': '66',
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_instance__setup_instance__setup.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_instance__setup_instance__setup.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_instance__setup_instance__setup.py
@@ -0,0 +1,26 @@
+This patch fixes paths to rc scripts
+The PREFIX fix won't be necessary anymore in further versions
+See https://github.com/GoogleCloudPlatform/compute-image-packages/pull/440
+
+--- google_compute_engine/instance_setup/instance_setup.py.orig 2017-07-18 16:43:14 UTC
++++ google_compute_engine/instance_setup/instance_setup.py
+@@ -143,14 +143,14 @@ class InstanceSetup(object):
+ """Initialize the SSH daemon."""
+ # Exit as early as possible.
+ # Instance setup systemd scripts block sshd from starting.
+- if os.path.exists('/bin/systemctl'):
++ if os.path.exists('%%PREFIX%%/bin/systemctl'):
+ return
+- elif (os.path.exists('/etc/init.d/ssh') or
+- os.path.exists('/etc/init/ssh.conf')):
++ elif (os.path.exists('/etc/rc.d/ssh') or
++ os.path.exists('/etc/rc/ssh.conf')):
+ subprocess.call(['service', 'ssh', 'start'])
+ subprocess.call(['service', 'ssh', 'reload'])
+- elif (os.path.exists('/etc/init.d/sshd') or
+- os.path.exists('/etc/init/sshd.conf')):
++ elif (os.path.exists('/etc/rc.d/sshd') or
++ os.path.exists('/etc/rc/sshd.conf')):
+ subprocess.call(['service', 'sshd', 'start'])
+ subprocess.call(['service', 'sshd', 'reload'])
+
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_ip__forwarding_ip__forwarding__daemon.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_ip__forwarding_ip__forwarding__daemon.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_ip__forwarding_ip__forwarding__daemon.py
@@ -0,0 +1,35 @@
+This patch depends on the follow PR from the upsteram project
+https://github.com/GoogleCloudPlatform/compute-image-packages/pull/442
+
+--- google_compute_engine/ip_forwarding/ip_forwarding_daemon.py.orig 2017-07-18 16:43:14 UTC
++++ google_compute_engine/ip_forwarding/ip_forwarding_daemon.py
+@@ -38,7 +38,7 @@ from google_compute_engine import networ
+
+ from google_compute_engine.ip_forwarding import ip_forwarding_utils
+
+-LOCKFILE = '/var/lock/google_ip_forwarding.lock'
++LOCKFILE = '/var/spool/lock/google_ip_forwarding.lock'
+
+
+ class IpForwardingDaemon(object):
+@@ -131,18 +131,18 @@ class IpForwardingDaemon(object):
+ Args:
+ result: dict, the metadata response with the new network interfaces.
+ """
++ ip_addresses = []
+ for network_interface in result:
+ mac_address = network_interface.get('mac')
+ interface = self.network_utils.GetNetworkInterface(mac_address)
+- ip_addresses = []
+ if interface:
+ ip_addresses.extend(network_interface.get('forwardedIps', []))
+ if self.ip_aliases:
+ ip_addresses.extend(network_interface.get('ipAliases', []))
+- self._HandleForwardedIps(ip_addresses, interface)
+ else:
+ message = 'Network interface not found for MAC address: %s.'
+ self.logger.warning(message, mac_address)
++ self._HandleForwardedIps(ip_addresses, 'lo' + self.ip_forwarding_utils.proto_id)
+
+
+ def main():
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_ip__forwarding_ip__forwarding__utils.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_ip__forwarding_ip__forwarding__utils.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_ip__forwarding_ip__forwarding__utils.py
@@ -0,0 +1,80 @@
+This patch depends on the follow PR from the upsteram project
+https://github.com/GoogleCloudPlatform/compute-image-packages/pull/442
+
+--- google_compute_engine/ip_forwarding/ip_forwarding_utils.py.orig 2017-07-18 16:43:14 UTC
++++ google_compute_engine/ip_forwarding/ip_forwarding_utils.py
+@@ -17,6 +17,8 @@
+
+ import re
+ import subprocess
++import netifaces
++import netaddr
+
+ IP_REGEX = re.compile(r'\A(\d{1,3}\.){3}\d{1,3}\Z')
+ IP_ALIAS_REGEX = re.compile(r'\A(\d{1,3}\.){3}\d{1,3}/\d{1,2}\Z')
+@@ -51,8 +53,8 @@ class IpForwardingUtils(object):
+ options.update(kwargs)
+ return options
+
+- 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 +65,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)
+@@ -108,10 +110,15 @@ class IpForwardingUtils(object):
+ Returns:
+ list, the IP address strings.
+ """
+- args = ['ls', 'table', 'local', 'type', 'local']
+- options = self._CreateRouteOptions(dev=interface)
+- result = self._RunIpRoute(args=args, options=options)
+- return self.ParseForwardedIps(result.split())
++ try:
++ ips = netifaces.ifaddresses('lo' + self.proto_id)
++ ips = ips[netifaces.AF_INET]
++ except (ValueError, KeyError) as e:
++ return []
++ forwarded_ips = []
++ for ip in ips:
++ forwarded_ips.append(ip['addr'] + '/' + str(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,9 +128,12 @@ class IpForwardingUtils(object):
+ 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)
++ cmd = 'alias'
++ try:
++ forwarded_ips = netifaces.ifaddresses(interface)
++ except (ValueError, KeyError) as e:
++ cmd = 'create'
++ self._RunIfconfig(args=[interface, cmd, address])
+
+ def RemoveForwardedIp(self, address, interface):
+ """Delete an IP address on the network interface.
+@@ -132,7 +142,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)
++ address = address if IP_REGEX.match(address) else address[:-3]
++ self._RunIfconfig(args=[interface, '-alias', address])
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_metadata__scripts_script__executor.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_metadata__scripts_script__executor.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_metadata__scripts_script__executor.py
@@ -0,0 +1,14 @@
+This patch won't be necessary anymore in further versions.
+See https://github.com/GoogleCloudPlatform/compute-image-packages/pull/440
+
+--- google_compute_engine/metadata_scripts/script_executor.py.orig 2017-07-23 07:12:16 UTC
++++ google_compute_engine/metadata_scripts/script_executor.py
+@@ -50,7 +50,7 @@ class ScriptExecutor(object):
+ metadata_script: string, the file location of an executable script.
+ """
+ process = subprocess.Popen(
+- metadata_script, shell=True, executable='/bin/bash',
++ metadata_script, shell=True, executable='%%PREFIX%%/bin/bash',
+ stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+ while True:
+ for line in iter(process.stdout.readline, b''):
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_network__setup_network__setup.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_network__setup_network__setup.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_network__setup_network__setup.py
@@ -0,0 +1,47 @@
+dhclient works a bit different in BSD compared to Linux, this patch adapts its usage.
+
+--- google_compute_engine/network_setup/network_setup.py.orig 2017-07-23 07:12:16 UTC
++++ google_compute_engine/network_setup/network_setup.py
+@@ -74,7 +74,7 @@ class NetworkSetup(object):
+ Args:
+ interfaces: list of string, the output device names enable.
+ """
+- interface_path = '/etc/sysconfig/network-scripts'
++ interface_path = '%%PREFIX%%/etc/sysconfig/network-scripts'
+ for interface in interfaces:
+ interface_config = os.path.join(interface_path, 'ifcfg-%s' % interface)
+ if os.path.exists(interface_config):
+@@ -106,12 +106,18 @@ class NetworkSetup(object):
+ self.logger.info('Enabling the Ethernet interfaces %s.', interfaces)
+ dhclient_command = ['dhclient']
+ if os.path.exists(self.dhclient_script):
+- dhclient_command += ['-sf', self.dhclient_script]
+- try:
+- subprocess.check_call(dhclient_command + ['-x'] + interfaces)
+- subprocess.check_call(dhclient_command + interfaces)
+- except subprocess.CalledProcessError:
+- self.logger.warning('Could not enable interfaces %s.', interfaces)
++ dhclient_conf = '/etc/dhclient.conf'
++ if os.path.exists(dhclient_conf):
++ subprocess.call('sed -i "" "/^script/d" ' + dhclient_conf, shell=True)
++ subprocess.call('echo \'script "%s";\' >> %s' % (self.dhclient_script, dhclient_conf), shell=True)
++ for interface in interfaces:
++ try:
++ subprocess.check_call(['ifconfig', interface, 'down', 'delete'])
++ # wait previous dhclient to exit
++ subprocess.check_call(['sleep', '3'])
++ subprocess.check_call(dhclient_command + [interface])
++ except subprocess.CalledProcessError:
++ self.logger.warning('Could not enable interface %s.', interface)
+
+ def _EnableNetworkInterfaces(self, interfaces):
+ """Enable the list of network interfaces.
+@@ -130,7 +136,7 @@ class NetworkSetup(object):
+ except subprocess.CalledProcessError:
+ self.logger.warning('Could not enable Ethernet interfaces.')
+ else:
+- if os.path.exists('/etc/sysconfig/network-scripts'):
++ if os.path.exists('%%PREFIX%%/etc/sysconfig/network-scripts'):
+ self._DisableNetworkManager(interfaces)
+ self._ConfigureNetwork(interfaces)
+
Index: head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_network__utils.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_network__utils.py
+++ head/sysutils/py-google-compute-engine/files/patch-google__compute__engine_network__utils.py
@@ -0,0 +1,30 @@
+This patch depends on the follow PR from the upsteram project
+https://github.com/GoogleCloudPlatform/compute-image-packages/pull/442
+
+--- google_compute_engine/network_utils.py.orig 2017-07-18 16:43:14 UTC
++++ google_compute_engine/network_utils.py
+@@ -17,6 +17,7 @@
+
+ import logging
+ import os
++import netifaces
+
+
+ class NetworkUtils(object):
+@@ -38,11 +39,12 @@ class NetworkUtils(object):
+ dict, string MAC addresses mapped to the string network interface name.
+ """
+ interfaces = {}
+- for interface in os.listdir('/sys/class/net'):
++ for interface in netifaces.interfaces():
+ try:
+- mac_address = open(
+- '/sys/class/net/%s/address' % interface).read().strip()
+- except (IOError, OSError) as e:
++ mac_address = netifaces.ifaddresses(interface)[netifaces.AF_LINK][0]['addr']
++ if mac_address == interface:
++ raise Exception('No MAC Address')
++ except Exception as e:
+ message = 'Unable to determine MAC address for %s. %s.'
+ self.logger.warning(message, interface, str(e))
+ else:
Index: head/sysutils/py-google-compute-engine/files/patch-setup.py
===================================================================
--- head/sysutils/py-google-compute-engine/files/patch-setup.py
+++ head/sysutils/py-google-compute-engine/files/patch-setup.py
@@ -0,0 +1,10 @@
+--- setup.py.orig 2017-07-18 16:43:14 UTC
++++ setup.py
+@@ -30,7 +30,6 @@ setuptools.setup(
+ long_description='Google Compute Engine guest environment.',
+ name='google-compute-engine',
+ packages=setuptools.find_packages(),
+- scripts=glob.glob('scripts/*'),
+ url='https://github.com/GoogleCloudPlatform/compute-image-packages',
+ version='2.4.1',
+ # Entry points create scripts in /usr/bin that call a function.
Index: head/sysutils/py-google-compute-engine/pkg-descr
===================================================================
--- head/sysutils/py-google-compute-engine/pkg-descr
+++ head/sysutils/py-google-compute-engine/pkg-descr
@@ -0,0 +1,14 @@
+Google Compute Engine offers scripts and daemons which run in the
+background and provides the following services:
+
+- Accounts daemon to setup and manage user accounts, and to enable SSH key based
+ authentication.
+- Clock skew daemon to keep the system clock in sync after VM start and stop
+ events.
+- Instance setup scripts to execute VM configuration scripts during boot.
+- IP forwarding daemon that integrates network load balancing with forwarding
+ rule changes into the guest.
+- Metadata scripts to run user provided scripts at VM startup and shutdown.
+- Network setup service to enable multiple network interfaces on boot.
+
+WWW: https://github.com/GoogleCloudPlatform/compute-image-packages
Index: head/sysutils/py-google-compute-engine/pkg-message
===================================================================
--- head/sysutils/py-google-compute-engine/pkg-message
+++ head/sysutils/py-google-compute-engine/pkg-message
@@ -0,0 +1,23 @@
+
+==============================================================================
+
+google-compute-engine has been installed, and the following services are
+available:
+
+google_accounts_daemon Responsible for provisioning and
+ deprovisioning user accounts
+google_clock_skew_daemon Responsible for syncing the software clock with
+ the hypervisor clock
+google_instance_setup Configure the guest at boot
+google_ip_forwarding_daemon Responsible to setup or remove IP routes in the
+ guest
+google_network_setup Responsible to enables all associated network
+ interfaces
+google_startup Implement support for running host provided
+ startup / shutdown scripts
+
+To enable the above services, sysrc <servicename>_enable=YES
+
+Reboot your system or start the services, service <servicename> start
+
+==============================================================================
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 20, 8:11 PM (2 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31816643
Default Alt Text
D12077.id32254.diff (35 KB)
Attached To
Mode
D12077: [NEW PORT] sysutils/google-compute-engine: User daemon for Google Compute Engine
Attached
Detach File
Event Timeline
Log In to Comment