Blame SOURCES/bz1568588-4-gcp-vpc-move-route.patch

391384
From 0ee4c62105ee8f90a43fe0bf8a65bc9b9da2e7e0 Mon Sep 17 00:00:00 2001
391384
From: Helen Koike <helen.koike@collabora.com>
391384
Date: Wed, 18 Jul 2018 11:54:40 -0300
391384
Subject: [PATCH 1/4] gcp-vpc-move-route.in: python implementation of
391384
 gcp-vpc-move-ip.in
391384
391384
gcloud api is not reliable and it is slow, add a python version of
391384
gcp-vpc-move-ip.in
391384
---
391384
 configure.ac                    |   1 +
391384
 doc/man/Makefile.am             |   1 +
391384
 heartbeat/Makefile.am           |   1 +
391384
 heartbeat/gcp-vpc-move-route.in | 441 ++++++++++++++++++++++++++++++++++++++++
391384
 4 files changed, 444 insertions(+)
391384
 create mode 100644 heartbeat/gcp-vpc-move-route.in
391384
391384
diff --git a/configure.ac b/configure.ac
391384
index 3d8f9ca74..039b4942c 100644
391384
--- a/configure.ac
391384
+++ b/configure.ac
391384
@@ -960,6 +960,7 @@ AC_CONFIG_FILES([heartbeat/eDir88], [chmod +x heartbeat/eDir88])
391384
 AC_CONFIG_FILES([heartbeat/fio], [chmod +x heartbeat/fio])
391384
 AC_CONFIG_FILES([heartbeat/gcp-vpc-move-ip], [chmod +x heartbeat/gcp-vpc-move-ip])
391384
 AC_CONFIG_FILES([heartbeat/gcp-vpc-move-vip], [chmod +x heartbeat/gcp-vpc-move-vip])
391384
+AC_CONFIG_FILES([heartbeat/gcp-vpc-move-route], [chmod +x heartbeat/gcp-vpc-move-route])
391384
 AC_CONFIG_FILES([heartbeat/iSCSILogicalUnit], [chmod +x heartbeat/iSCSILogicalUnit])
391384
 AC_CONFIG_FILES([heartbeat/iSCSITarget], [chmod +x heartbeat/iSCSITarget])
391384
 AC_CONFIG_FILES([heartbeat/jira], [chmod +x heartbeat/jira])
391384
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
391384
index e9eaf369f..3ac0569de 100644
391384
--- a/doc/man/Makefile.am
391384
+++ b/doc/man/Makefile.am
391384
@@ -115,6 +115,7 @@ man_MANS	       = ocf_heartbeat_AoEtarget.7 \
391384
                           ocf_heartbeat_garbd.7 \
391384
                           ocf_heartbeat_gcp-vpc-move-ip.7 \
391384
                           ocf_heartbeat_gcp-vpc-move-vip.7 \
391384
+                          ocf_heartbeat_gcp-vpc-move-route.7 \
391384
                           ocf_heartbeat_iSCSILogicalUnit.7 \
391384
                           ocf_heartbeat_iSCSITarget.7 \
391384
                           ocf_heartbeat_iface-bridge.7 \
391384
diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am
391384
index 36b271956..d4750bf09 100644
391384
--- a/heartbeat/Makefile.am
391384
+++ b/heartbeat/Makefile.am
391384
@@ -112,6 +112,7 @@ ocf_SCRIPTS	     =  AoEtarget		\
391384
 			garbd			\
391384
 			gcp-vpc-move-ip		\
391384
 			gcp-vpc-move-vip	\
391384
+			gcp-vpc-move-route	\
391384
 			iSCSILogicalUnit	\
391384
 			iSCSITarget		\
391384
 			ids			\
391384
diff --git a/heartbeat/gcp-vpc-move-route.in b/heartbeat/gcp-vpc-move-route.in
391384
new file mode 100644
391384
index 000000000..5f4569baa
391384
--- /dev/null
391384
+++ b/heartbeat/gcp-vpc-move-route.in
391384
@@ -0,0 +1,441 @@
391384
+#!@PYTHON@ -tt
391384
+# - *- coding: utf- 8 - *-
391384
+#
391384
+#
391384
+# OCF resource agent to move an IP address within a VPC in GCP
391384
+#
391384
+# License: GNU General Public License (GPL)
391384
+# Copyright (c) 2018 Hervé Werner (MFG Labs)
391384
+# Copyright 2018 Google Inc.
391384
+# Based on code from Markus Guertler (aws-vpc-move-ip)
391384
+# All Rights Reserved.
391384
+#
391384
+# This program is free software; you can redistribute it and/or modify
391384
+# it under the terms of version 2 of the GNU General Public License as
391384
+# published by the Free Software Foundation.
391384
+#
391384
+# This program is distributed in the hope that it would be useful, but
391384
+# WITHOUT ANY WARRANTY; without even the implied warranty of
391384
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
391384
+#
391384
+# Further, this software is distributed without any warranty that it is
391384
+# free of the rightful claim of any third person regarding infringement
391384
+# or the like.  Any license provided herein, whether implied or
391384
+# otherwise, applies only to this software file.  Patent licenses, if
391384
+# any, provided herein do not apply to combinations of this program with
391384
+# other software, or any other product whatsoever.
391384
+#
391384
+# You should have received a copy of the GNU General Public License
391384
+# along with this program; if not, write the Free Software Foundation,
391384
+# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
391384
+#
391384
+
391384
+
391384
+#######################################################################
391384
+
391384
+import atexit
391384
+import logging
391384
+import os
391384
+import sys
391384
+import time
391384
+
391384
+try:
391384
+  import googleapiclient.discovery
391384
+  import pyroute2
391384
+except ImportError:
391384
+  pass
391384
+
391384
+if sys.version_info >= (3, 0):
391384
+  # Python 3 imports.
391384
+  import urllib.parse as urlparse
391384
+  import urllib.request as urlrequest
391384
+else:
391384
+  # Python 2 imports.
391384
+  import urllib as urlparse
391384
+  import urllib2 as urlrequest
391384
+
391384
+
391384
+OCF_SUCCESS = 0
391384
+OCF_ERR_GENERIC = 1
391384
+OCF_ERR_UNIMPLEMENTED = 3
391384
+OCF_ERR_PERM = 4
391384
+OCF_ERR_CONFIGURED = 6
391384
+OCF_NOT_RUNNING = 7
391384
+GCP_API_URL_PREFIX = 'https://www.googleapis.com/compute/v1'
391384
+METADATA_SERVER = 'http://metadata.google.internal/computeMetadata/v1/'
391384
+METADATA_HEADERS = {'Metadata-Flavor': 'Google'}
391384
+METADATA = \
391384
+'''
391384
+
391384
+<resource-agent name="gcp-vpc-move-route">
391384
+<version>1.0</version>
391384
+<longdesc lang="en">
391384
+Resource Agent that can move a floating IP addresse within a GCP VPC by changing an
391384
+entry in the routing table. This agent also configures the floating IP locally
391384
+on the instance OS.
391384
+Requirements :
391384
+- IP forwarding must be enabled on all instances in order to be able to
391384
+terminate the route
391384
+- The floating IP address must be choosen so that it is outside all existing
391384
+subnets in the VPC network
391384
+- IAM permissions
391384
+(see https://cloud.google.com/compute/docs/access/iam-permissions) :
391384
+1) compute.routes.delete, compute.routes.get and compute.routes.update on the
391384
+route
391384
+2) compute.networks.updatePolicy on the network (to add a new route)
391384
+3) compute.networks.get on the network (to check the VPC network existence)
391384
+4) compute.routes.list on the project (to check conflicting routes)
391384
+</longdesc>
391384
+<shortdesc lang="en">Move IP within a GCP VPC</shortdesc>
391384
+
391384
+<parameters>
391384
+
391384
+<parameter name="stackdriver_logging" unique="0" required="0">
391384
+<longdesc lang="en">If enabled (set to true), IP failover logs will be posted to stackdriver logging</longdesc>
391384
+<shortdesc lang="en">Stackdriver-logging support</shortdesc>
391384
+<content type="boolean" default="" />
391384
+</parameter>
391384
+
391384
+<parameter name="ip" unique="1" required="1">
391384
+<longdesc lang="en">
391384
+Floating IP address. Note that this IP must be chosen outside of all existing
391384
+subnet ranges
391384
+</longdesc>
391384
+<shortdesc lang="en">Floating IP</shortdesc>
391384
+<content type="string" />
391384
+</parameter>
391384
+
391384
+<parameter name="vpc_network" required="1">
391384
+<longdesc lang="en">
391384
+Name of the VPC network
391384
+</longdesc>
391384
+<shortdesc lang="en">VPC network</shortdesc>
391384
+<content type="string" default="${OCF_RESKEY_vpc_network_default}" />
391384
+</parameter>
391384
+
391384
+<parameter name="interface">
391384
+<longdesc lang="en">
391384
+Name of the network interface
391384
+</longdesc>
391384
+<shortdesc lang="en">Network interface name</shortdesc>
391384
+<content type="string" default="${OCF_RESKEY_interface_default}" />
391384
+</parameter>
391384
+
391384
+<parameter name="route_name" unique="1">
391384
+<longdesc lang="en">
391384
+Route name
391384
+</longdesc>
391384
+<shortdesc lang="en">Route name</shortdesc>
391384
+<content type="string" default="${OCF_RESKEY_route_name_default}" />
391384
+</parameter>
391384
+</parameters>
391384
+
391384
+<actions>
391384
+<action name="start" timeout="180s" />
391384
+<action name="stop" timeout="180s" />
391384
+<action name="monitor" depth="0" timeout="30s" interval="60s" />
391384
+<action name="validate-all" timeout="5s" />
391384
+<action name="meta-data" timeout="5s" />
391384
+</actions>
391384
+</resource-agent>
391384
+'''
391384
+
391384
+
391384
+class Context(object):
391384
+  __slots__ = 'conn', 'iface_idx', 'instance', 'instance_url', 'interface', \
391384
+      'ip', 'iproute', 'project', 'route_name', 'vpc_network', \
391384
+      'vpc_network_url', 'zone'
391384
+
391384
+
391384
+def wait_for_operation(ctx, response):
391384
+  """Blocks until operation completes.
391384
+  Code from GitHub's GoogleCloudPlatform/python-docs-samples
391384
+
391384
+  Args:
391384
+    response: dict, a request's response
391384
+  """
391384
+  def _OperationGetter(response):
391384
+    operation = response[u'name']
391384
+    if response.get(u'zone'):
391384
+      return ctx.conn.zoneOperations().get(
391384
+          project=ctx.project, zone=ctx.zone, operation=operation)
391384
+    else:
391384
+      return ctx.conn.globalOperations().get(
391384
+          project=ctx.project, operation=operation)
391384
+
391384
+  while True:
391384
+    result = _OperationGetter(response).execute()
391384
+
391384
+    if result['status'] == 'DONE':
391384
+      if 'error' in result:
391384
+        raise Exception(result['error'])
391384
+      return result
391384
+
391384
+    time.sleep(1)
391384
+
391384
+
391384
+def get_metadata(metadata_key, params=None, timeout=None):
391384
+  """Performs a GET request with the metadata headers.
391384
+
391384
+  Args:
391384
+    metadata_key: string, the metadata to perform a GET request on.
391384
+    params: dictionary, the query parameters in the GET request.
391384
+    timeout: int, timeout in seconds for metadata requests.
391384
+
391384
+  Returns:
391384
+    HTTP response from the GET request.
391384
+
391384
+  Raises:
391384
+    urlerror.HTTPError: raises when the GET request fails.
391384
+  """
391384
+  timeout = timeout or 60
391384
+  metadata_url = os.path.join(METADATA_SERVER, metadata_key)
391384
+  params = urlparse.urlencode(params or {})
391384
+  url = '%s?%s' % (metadata_url, params)
391384
+  request = urlrequest.Request(url, headers=METADATA_HEADERS)
391384
+  request_opener = urlrequest.build_opener(urlrequest.ProxyHandler({}))
391384
+  return request_opener.open(request, timeout=timeout * 1.1).read()
391384
+
391384
+
391384
+def validate(ctx):
391384
+  if os.geteuid() != 0:
391384
+    logging.error('You must run this agent as root')
391384
+    sys.exit(OCF_ERR_PERM)
391384
+
391384
+  try:
391384
+    ctx.conn = googleapiclient.discovery.build('compute', 'v1')
391384
+  except Exception as e:
391384
+    logging.error('Couldn\'t connect with google api: ' + str(e))
391384
+    sys.exit(OCF_ERR_CONFIGURED)
391384
+
391384
+  ctx.ip = os.environ.get('OCF_RESKEY_ip')
391384
+  if not ctx.ip:
391384
+    logging.error('Missing ip parameter')
391384
+    sys.exit(OCF_ERR_CONFIGURED)
391384
+
391384
+  try:
391384
+    ctx.instance = get_metadata('instance/name')
391384
+    ctx.zone = get_metadata('instance/zone').split('/')[-1]
391384
+    ctx.project = get_metadata('project/project-id')
391384
+  except Exception as e:
391384
+    logging.error(
391384
+        'Instance information not found. Is this a GCE instance ?: %s', str(e))
391384
+    sys.exit(OCF_ERR_CONFIGURED)
391384
+
391384
+  ctx.instance_url = '%s/projects/%s/zones/%s/instances/%s' % (
391384
+      GCP_API_URL_PREFIX, ctx.project, ctx.zone, ctx.instance)
391384
+  ctx.vpc_network = os.environ.get('OCF_RESKEY_vpc_network', 'default')
391384
+  ctx.vpc_network_url = '%s/projects/%s/global/networks/%s' % (
391384
+      GCP_API_URL_PREFIX, ctx.project, ctx.vpc_network)
391384
+  ctx.interface = os.environ.get('OCF_RESKEY_interface', 'eth0')
391384
+  ctx.route_name = os.environ.get(
391384
+      'OCF_RESKEY_route_name', 'ra-%s' % os.environ['__SCRIPT_NAME'])
391384
+  ctx.iproute = pyroute2.IPRoute()
391384
+  atexit.register(ctx.iproute.close)
391384
+  idxs = ctx.iproute.link_lookup(ifname=ctx.interface)
391384
+  if not idxs:
391384
+    logging.error('Network interface not found')
391384
+    sys.exit(OCF_ERR_CONFIGURED)
391384
+  ctx.iface_idx = idxs[0]
391384
+
391384
+
391384
+def check_conflicting_routes(ctx):
391384
+  fl = '(destRange = "%s*") AND (network = "%s") AND (name != "%s")' % (
391384
+      ctx.ip, ctx.vpc_network_url, ctx.route_name)
391384
+  request = ctx.conn.routes().list(project=ctx.project, filter=fl)
391384
+  response = request.execute()
391384
+  route_list = response.get('items', None)
391384
+  if route_list:
391384
+    logging.error(
391384
+        'Conflicting unnmanaged routes for destination %s/32 in VPC %s found : %s',
391384
+        ctx.ip, ctx.vpc_network, str(route_list))
391384
+    sys.exit(OCF_ERR_CONFIGURED)
391384
+
391384
+
391384
+def route_release(ctx):
391384
+  request = ctx.conn.routes().delete(project=ctx.project, route=ctx.route_name)
391384
+  wait_for_operation(ctx, request.execute())
391384
+
391384
+
391384
+def ip_monitor(ctx):
391384
+  logging.info('IP monitor: checking local network configuration')
391384
+
391384
+  def address_filter(addr):
391384
+    for attr in addr['attrs']:
391384
+      if attr[0] == 'IFA_LOCAL':
391384
+        if attr[1] == ctx.ip:
391384
+          return True
391384
+        else:
391384
+          return False
391384
+
391384
+  route = ctx.iproute.get_addr(
391384
+      index=ctx.iface_idx, match=address_filter)
391384
+  if not route:
391384
+    logging.warn(
391384
+        'The floating IP %s is not locally configured on this instance (%s)',
391384
+        ctx.ip, ctx.instance)
391384
+    return OCF_NOT_RUNNING
391384
+
391384
+  logging.debug(
391384
+      'The floating IP %s is correctly configured on this instance (%s)',
391384
+      ctx.ip, ctx.instance)
391384
+  return OCF_SUCCESS
391384
+
391384
+
391384
+def ip_release(ctx):
391384
+  ctx.iproute.addr('del', index=ctx.iface_idx, address=ctx.ip, mask=32)
391384
+
391384
+
391384
+def ip_and_route_start(ctx):
391384
+  logging.info('Bringing up the floating IP %s', ctx.ip)
391384
+
391384
+  # Add a new entry in the routing table
391384
+  # If the route entry exists and is pointing to another instance, take it over
391384
+
391384
+  # Ensure that there is no route that we are not aware of that is also handling our IP
391384
+  check_conflicting_routes(ctx)
391384
+
391384
+  # There is no replace API, We need to first delete the existing route if any
391384
+  try:
391384
+    request = ctx.conn.routes().get(project=ctx.project, route=ctx.route_name)
391384
+    request.execute()
391384
+  # TODO: check specific exception for 404
391384
+  except googleapiclient.errors.HttpError as e:
391384
+    if e.resp.status != 404:
391384
+      raise
391384
+  else:
391384
+      route_release(ctx)
391384
+
391384
+  route_body = {
391384
+      'name': ctx.route_name,
391384
+      'network': ctx.vpc_network_url,
391384
+      'destRange': '%s/32' % ctx.ip,
391384
+      'nextHopInstance': ctx.instance_url,
391384
+  }
391384
+  try:
391384
+    request = ctx.conn.routes().insert(project=ctx.project, body=route_body)
391384
+    wait_for_operation(ctx, request.execute())
391384
+  except googleapiclient.errors.HttpError:
391384
+    try:
391384
+      request = ctx.conn.networks().get(
391384
+          project=ctx.project, network=ctx.vpc_network)
391384
+      request.execute()
391384
+    except googleapiclient.errors.HttpError as e:
391384
+      if e.resp.status == 404:
391384
+        logging.error('VPC network not found')
391384
+        sys.exit(OCF_ERR_CONFIGURED)
391384
+      else:
391384
+        raise
391384
+    else:
391384
+      raise
391384
+
391384
+  # Configure the IP address locally
391384
+  # We need to release the IP first
391384
+  if ip_monitor(ctx) == OCF_SUCCESS:
391384
+    ip_release(ctx)
391384
+
391384
+  ctx.iproute.addr('add', index=ctx.iface_idx, address=ctx.ip, mask=32)
391384
+  ctx.iproute.link('set', index=ctx.iface_idx, state='up')
391384
+  logging.info('Successfully brought up the floating IP %s', ctx.ip)
391384
+
391384
+
391384
+def route_monitor(ctx):
391384
+  logging.info('GCP route monitor: checking route table')
391384
+
391384
+  # Ensure that there is no route that we are not aware of that is also handling our IP
391384
+  check_conflicting_routes
391384
+
391384
+  try:
391384
+    request = ctx.conn.routes().get(project=ctx.project, route=ctx.route_name)
391384
+    response = request.execute()
391384
+  except googleapiclient.errors.HttpError as e:
391384
+    if 'Insufficient Permission' in e.content:
391384
+      return OCF_ERR_PERM
391384
+    elif e.resp.status == 404:
391384
+      return OCF_NOT_RUNNING
391384
+    else:
391384
+      raise
391384
+
391384
+  routed_to_instance = response.get('nextHopInstance', '<unknown>')
391384
+  instance_url = '%s/projects/%s/zones/%s/instances/%s' % (
391384
+      GCP_API_URL_PREFIX, ctx.project, ctx.zone, ctx.instance)
391384
+  if routed_to_instance != instance_url:
391384
+    logging.warn(
391384
+        'The floating IP %s is not routed to this instance (%s) but to instance %s',
391384
+        ctx.ip, ctx.instance, routed_to_instance.split('/')[-1])
391384
+    return OCF_NOT_RUNNING
391384
+
391384
+  logging.debug(
391384
+      'The floating IP %s is correctly routed to this instance (%s)',
391384
+      ctx.ip, ctx.instance)
391384
+  return OCF_SUCCESS
391384
+
391384
+
391384
+def ip_and_route_stop(ctx):
391384
+  logging.info('Bringing down the floating IP %s', ctx.ip)
391384
+
391384
+  # Delete the route entry
391384
+  # If the route entry exists and is pointing to another instance, don't touch it
391384
+  if route_monitor(ctx) == OCF_NOT_RUNNING:
391384
+    logging.info(
391384
+        'The floating IP %s is already not routed to this instance (%s)',
391384
+        ctx.ip, ctx.instance)
391384
+  else:
391384
+    route_release(ctx)
391384
+
391384
+  if ip_monitor(ctx) == OCF_NOT_RUNNING:
391384
+    logging.info('The floating IP %s is already down', ctx.ip)
391384
+  else:
391384
+    ip_release(ctx)
391384
+
391384
+
391384
+def configure_logs(ctx):
391384
+  # Prepare logging
391384
+  logging.basicConfig(
391384
+      format='gcp:route - %(levelname)s - %(message)s', level=logging.INFO)
391384
+  logging.getLogger('googleapiclient').setLevel(logging.WARN)
391384
+  logging_env = os.environ.get('OCF_RESKEY_stackdriver_logging')
391384
+  if logging_env:
391384
+    logging_env = logging_env.lower()
391384
+    if any(x in logging_env for x in ['yes', 'true', 'enabled']):
391384
+      try:
391384
+        import google.cloud.logging.handlers
391384
+        client = google.cloud.logging.Client()
391384
+        handler = google.cloud.logging.handlers.CloudLoggingHandler(
391384
+            client, name=ctx.instance)
391384
+        handler.setLevel(logging.INFO)
391384
+        formatter = logging.Formatter('gcp:route "%(message)s"')
391384
+        handler.setFormatter(formatter)
391384
+        root_logger = logging.getLogger()
391384
+        root_logger.addHandler(handler)
391384
+      except ImportError:
391384
+        logging.error('Couldn\'t import google.cloud.logging, '
391384
+            'disabling Stackdriver-logging support')
391384
+
391384
+
391384
+def main():
391384
+  if 'meta-data' in sys.argv[1]:
391384
+    print(METADATA)
391384
+    return
391384
+
391384
+  ctx = Context()
391384
+
391384
+  validate(ctx)
391384
+  if 'validate-all' in sys.argv[1]:
391384
+    return
391384
+
391384
+  configure_logs(ctx)
391384
+  if 'start' in sys.argv[1]:
391384
+    ip_and_route_start(ctx)
391384
+  elif 'stop' in sys.argv[1]:
391384
+    ip_and_route_stop(ctx)
391384
+  elif 'status' in sys.argv[1] or 'monitor' in sys.argv[1]:
391384
+    sys.exit(ip_monitor(ctx))
391384
+  else:
391384
+    usage = 'usage: $0 {start|stop|monitor|status|meta-data|validate-all}'
391384
+    logging.error(usage)
391384
+    sys.exit(OCF_ERR_UNIMPLEMENTED)
391384
+
391384
+
391384
+if __name__ == "__main__":
391384
+  main()
391384
391384
From 6590c99f462403808854114ec1031755e5ce6b36 Mon Sep 17 00:00:00 2001
391384
From: Helen Koike <helen.koike@collabora.com>
391384
Date: Thu, 19 Jul 2018 12:33:44 -0300
391384
Subject: [PATCH 2/4] gcp-vpc-move-ip.in: add deprecation message
391384
391384
---
391384
 heartbeat/gcp-vpc-move-ip.in | 2 ++
391384
 1 file changed, 2 insertions(+)
391384
391384
diff --git a/heartbeat/gcp-vpc-move-ip.in b/heartbeat/gcp-vpc-move-ip.in
391384
index 4a6c343a8..3b8d998b3 100755
391384
--- a/heartbeat/gcp-vpc-move-ip.in
391384
+++ b/heartbeat/gcp-vpc-move-ip.in
391384
@@ -348,6 +348,8 @@ ip_and_route_stop() {
391384
 #
391384
 ###############################################################################
391384
 
391384
+ocf_log warn "gcp-vpc-move-ip is deprecated, prefer to use gcp-vpc-move-route instead"
391384
+
391384
 case $__OCF_ACTION in
391384
   meta-data)  metadata
391384
               exit $OCF_SUCCESS
391384
391384
From 73608196d21068c6c2d5fb9f77e3d40179c85fee Mon Sep 17 00:00:00 2001
391384
From: Helen Koike <helen.koike@collabora.com>
391384
Date: Fri, 20 Jul 2018 08:26:17 -0300
391384
Subject: [PATCH 3/4] gcp-vpc-move-route.in: move stackdriver parameter
391384
391384
Move stackdriver parameter to the bottom of metadata list
391384
---
391384
 heartbeat/gcp-vpc-move-route.in | 12 ++++++------
391384
 1 file changed, 6 insertions(+), 6 deletions(-)
391384
391384
diff --git a/heartbeat/gcp-vpc-move-route.in b/heartbeat/gcp-vpc-move-route.in
391384
index 5f4569baa..8d5bfff36 100644
391384
--- a/heartbeat/gcp-vpc-move-route.in
391384
+++ b/heartbeat/gcp-vpc-move-route.in
391384
@@ -90,12 +90,6 @@ route
391384
 
391384
 <parameters>
391384
 
391384
-<parameter name="stackdriver_logging" unique="0" required="0">
391384
-<longdesc lang="en">If enabled (set to true), IP failover logs will be posted to stackdriver logging</longdesc>
391384
-<shortdesc lang="en">Stackdriver-logging support</shortdesc>
391384
-<content type="boolean" default="" />
391384
-</parameter>
391384
-
391384
 <parameter name="ip" unique="1" required="1">
391384
 <longdesc lang="en">
391384
 Floating IP address. Note that this IP must be chosen outside of all existing
391384
@@ -128,6 +122,12 @@ Route name
391384
 <shortdesc lang="en">Route name</shortdesc>
391384
 <content type="string" default="${OCF_RESKEY_route_name_default}" />
391384
 </parameter>
391384
+
391384
+<parameter name="stackdriver_logging" unique="0" required="0">
391384
+<longdesc lang="en">If enabled (set to true), IP failover logs will be posted to stackdriver logging</longdesc>
391384
+<shortdesc lang="en">Stackdriver-logging support</shortdesc>
391384
+<content type="boolean" default="" />
391384
+</parameter>
391384
 </parameters>
391384
 
391384
 <actions>
391384
391384
From e54565ec69f809b28337c0471ad0a9b26a64f8bf Mon Sep 17 00:00:00 2001
391384
From: Helen Koike <helen.koike@collabora.com>
391384
Date: Fri, 20 Jul 2018 08:45:53 -0300
391384
Subject: [PATCH 4/4] gcp-vpc-move-route.in: minor fixes
391384
391384
---
391384
 heartbeat/gcp-vpc-move-route.in | 13 +++++++------
391384
 1 file changed, 7 insertions(+), 6 deletions(-)
391384
391384
diff --git a/heartbeat/gcp-vpc-move-route.in b/heartbeat/gcp-vpc-move-route.in
391384
index 8d5bfff36..566a70f86 100644
391384
--- a/heartbeat/gcp-vpc-move-route.in
391384
+++ b/heartbeat/gcp-vpc-move-route.in
391384
@@ -104,7 +104,7 @@ subnet ranges
391384
 Name of the VPC network
391384
 </longdesc>
391384
 <shortdesc lang="en">VPC network</shortdesc>
391384
-<content type="string" default="${OCF_RESKEY_vpc_network_default}" />
391384
+<content type="string" default="default" />
391384
 </parameter>
391384
 
391384
 <parameter name="interface">
391384
@@ -112,7 +112,7 @@ Name of the VPC network
391384
 Name of the network interface
391384
 </longdesc>
391384
 <shortdesc lang="en">Network interface name</shortdesc>
391384
-<content type="string" default="${OCF_RESKEY_interface_default}" />
391384
+<content type="string" default="eth0" />
391384
 </parameter>
391384
 
391384
 <parameter name="route_name" unique="1">
391384
@@ -120,7 +120,7 @@ Name of the network interface
391384
 Route name
391384
 </longdesc>
391384
 <shortdesc lang="en">Route name</shortdesc>
391384
-<content type="string" default="${OCF_RESKEY_route_name_default}" />
391384
+<content type="string" default="ra-%s" />
391384
 </parameter>
391384
 
391384
 <parameter name="stackdriver_logging" unique="0" required="0">
391384
@@ -138,7 +138,7 @@ Route name
391384
 <action name="meta-data" timeout="5s" />
391384
 </actions>
391384
 </resource-agent>
391384
-'''
391384
+''' % os.path.basename(sys.argv[0])
391384
 
391384
 
391384
 class Context(object):
391384
@@ -229,7 +229,7 @@ def validate(ctx):
391384
       GCP_API_URL_PREFIX, ctx.project, ctx.vpc_network)
391384
   ctx.interface = os.environ.get('OCF_RESKEY_interface', 'eth0')
391384
   ctx.route_name = os.environ.get(
391384
-      'OCF_RESKEY_route_name', 'ra-%s' % os.environ['__SCRIPT_NAME'])
391384
+      'OCF_RESKEY_route_name', 'ra-%s' % os.path.basename(sys.argv[0]))
391384
   ctx.iproute = pyroute2.IPRoute()
391384
   atexit.register(ctx.iproute.close)
391384
   idxs = ctx.iproute.link_lookup(ifname=ctx.interface)
391384
@@ -432,7 +432,8 @@ def main():
391384
   elif 'status' in sys.argv[1] or 'monitor' in sys.argv[1]:
391384
     sys.exit(ip_monitor(ctx))
391384
   else:
391384
-    usage = 'usage: $0 {start|stop|monitor|status|meta-data|validate-all}'
391384
+    usage = 'usage: %s {start|stop|monitor|status|meta-data|validate-all}' % \
391384
+        os.path.basename(sys.argv[0])
391384
     logging.error(usage)
391384
     sys.exit(OCF_ERR_UNIMPLEMENTED)
391384