old_contents: #!/usr/bin/env python
  # Copyright 2015-2019 Yelp 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.
  """
  Usage: ./paasta_dump_locally_running_services.py
  
  Outputs a JSON-encoded list of services that are running on this host along
  with the host port that each service is listening on.
  """
  import json
  import sys
  
  from paasta_tools.marathon_tools import get_marathon_services_running_here_for_nerve
  from paasta_tools.utils import DEFAULT_SOA_DIR
  from paasta_tools.utils import paasta_print
  
  
  def main():
      local_services = get_marathon_services_running_here_for_nerve(
          cluster=None,
          soa_dir=DEFAULT_SOA_DIR,
      )
      paasta_print(json.dumps(local_services))
      sys.exit(0)
  
  
  if __name__ == '__main__':
      main()
  
new_contents: #!/usr/bin/env python
  # Copyright 2015-2019 Yelp 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.
  """
  Usage: ./paasta_dump_locally_running_services.pp [options]
  
  Outputs a JSON-encoded list of services that are running on this host along
  with the host port that each service is listening on.
  
  Command line options:
  
  - -t <SERVICE_TYPE>, --service-type <SERVICE_TYPE>: Dump information about
      this type of service. Choose from 'marathon' (default) or 'puppet'.
  - -d <SOA_DIR>, --soa-dir <SOA_DIR>: Specify a SOA config dir to read from
  """
  import argparse
  import json
  import sys
  
  from paasta_tools.marathon_tools import get_marathon_services_running_here_for_nerve
  from paasta_tools.marathon_tools import get_puppet_services_running_here_for_nerve
  from paasta_tools.utils import DEFAULT_SOA_DIR
  from paasta_tools.utils import paasta_print
  
  
  def parse_args(argv):
      parser = argparse.ArgumentParser(description='Dumps information about locally running services.')
      parser.add_argument(
          '-t', '--service-type', dest='service_type', metavar='SERVICE_TYPE',
          default='marathon',
          choices=['marathon', 'puppet'],
          help='Dump information for this type of service (default is marathon)',
      )
      parser.add_argument(
          '-d', '--soa-dir', dest='soa_dir', metavar='SOA_DIR',
          default=DEFAULT_SOA_DIR,
          help='define a different soa config directory',
      )
      return parser.parse_args(argv)
  
  
  def main(argv=None):
      args = parse_args(argv)
      service_type = args.service_type
      soa_dir = args.soa_dir
  
      if service_type == 'marathon':
          service_dump = get_marathon_services_running_here_for_nerve(
              cluster=None,
              soa_dir=soa_dir,
          )
      elif service_type == 'puppet':
          service_dump = get_puppet_services_running_here_for_nerve(
              soa_dir=soa_dir,
          )
      else:
          raise ValueError(f'unknown service type: {service_type}')
  
      paasta_print(json.dumps(service_dump))
      sys.exit(0)
  
  
  if __name__ == '__main__':
      main()
  
subject: Add puppet service type option to paasta_dump_locally_running_services