Example #1
0
  def start_dependencies(self):
    """Start all the external dependencies running on this host."""
    run_dir = self.__installation.EXTERNAL_DEPENDENCY_SCRIPT_DIR

    cassandra_host = self.__bindings.get('services.cassandra.host')
    redis_host = self.__bindings.get('services.redis.host')

    print 'Starting external dependencies...'
    check_run_quick(
        'REDIS_HOST={host}'
        ' LOG_DIR="{log_dir}"'
        ' "{run_dir}/start_redis.sh"'
        .format(host=redis_host,
                log_dir=self.__installation.LOG_DIR,
                run_dir=run_dir),
        echo=True)

    check_run_quick(
        'CASSANDRA_HOST={host}'
        ' CASSANDRA_DIR="{install_dir}/cassandra"'
        ' "{run_dir}/start_cassandra.sh"'
        .format(host=cassandra_host,
                install_dir=self.__installation.SPINNAKER_INSTALL_DIR,
                run_dir=run_dir),
         echo=True)
Example #2
0
def check_write_instance_metadata(name, value):
    """Add a name/value pair to our instance metadata.

  Args:
    name [string]: The key name.
    value [string]: The key value.

  Raises
    UnsupportedError if not on a platform with metadata.
  """
    if is_google_instance():
        check_run_quick(
            'gcloud compute instances add-metadata'
            ' {hostname} --zone={zone} --metadata={name}={value}'.format(
                hostname=socket.gethostname(),
                zone=check_get_zone(),
                name=name,
                value=value))

    elif is_aws_instance():
        result = check_fetch(os.path.join(AWS_METADATA_URL, 'instance-id'))
        id = result.content.strip()

        result = check_fetch(
            os.path.join(AWS_METADATA_URL, 'placement/availability-zone'))
        region = result.content.strip()[:-1]

        command = [
            'aws ec2 create-tags --resources', id, '--region', region,
            '--tags Key={key},Value={value}'.format(key=name, value=value)
        ]
        check_run_quick(' '.join(command), echo=False)

    else:
        raise UnsupportedError('This platform does not support metadata.')
Example #3
0
def check_write_instance_metadata(name, value):
  """Add a name/value pair to our instance metadata.

  Args:
    name [string]: The key name.
    value [string]: The key value.

  Raises
    NotImplementedError if not on a platform with metadata.
  """
  if is_google_instance():
    check_run_quick(
        'gcloud compute instances add-metadata'
        ' {hostname} --zone={zone} --metadata={name}={value}'
        .format(hostname=socket.gethostname(),
                zone=check_get_zone(), name=name, value=value))

  elif is_aws_instance():
    result = check_fetch(os.path.join(AWS_METADATA_URL, 'instance-id'))
    id = result.content.strip()

    result = check_fetch(os.path.join(AWS_METADATA_URL,
                                      'placement/availability-zone'))
    region = result.content.strip()[:-1]

    command = ['aws ec2 create-tags --resources', id,
               '--region', region,
               '--tags Key={key},Value={value}'.format(key=name, value=value)]
    check_run_quick(' '.join(command), echo=False)

  else:
    raise NotImplementedError('This platform does not support metadata.')
Example #4
0
    def start_dependencies(self):
        """Start all the external dependencies running on this host."""
        run_dir = self.__installation.EXTERNAL_DEPENDENCY_SCRIPT_DIR

        cassandra_host = self.__bindings.get('services.cassandra.host')
        redis_host = self.__bindings.get('services.redis.host')

        print 'Starting external dependencies...'
        check_run_quick('REDIS_HOST={host}'
                        ' LOG_DIR="{log_dir}"'
                        ' "{run_dir}/start_redis.sh"'.format(
                            host=redis_host,
                            log_dir=self.__installation.LOG_DIR,
                            run_dir=run_dir),
                        echo=True)

        if self.needs_cassandra():
            check_run_quick(
                'CASSANDRA_HOST={host}'
                ' CASSANDRA_DIR="{install_dir}/cassandra"'
                ' "{run_dir}/start_cassandra.sh"'.format(
                    host=cassandra_host,
                    install_dir=self.__installation.SPINNAKER_INSTALL_DIR,
                    run_dir=run_dir),
                echo=True)
        else:
            print 'Cassandra is not used in the current configuration so not ensuring it.'
    run_dir = self.__installation.EXTERNAL_DEPENDENCY_SCRIPT_DIR

    cassandra_host = self.__bindings.get('services.cassandra.host')
    redis_host = self.__bindings.get('services.redis.host')

    print 'Starting external dependencies...'
    check_run_quick(
        'REDIS_HOST={host}'
        ' LOG_DIR="{log_dir}"'
        ' "{run_dir}/start_redis.sh"'
        .format(host=redis_host,
                log_dir=self.__installation.LOG_DIR,
                run_dir=run_dir),
        echo=True)

    check_run_quick(
        'CASSANDRA_HOST={host}'
        ' CASSANDRA_DIR="{install_dir}/cassandra"'
        ' "{run_dir}/start_cassandra.sh"'
        .format(host=cassandra_host,
                install_dir=self.__installation.SPINNAKER_INSTALL_DIR,
                run_dir=run_dir),
         echo=True)

  def get_subsystem_environ(self, subsystem):
    if self.__bindings and subsystem != 'clouddriver':
       return os.environ

    if not self.__bindings.get('providers.aws.enabled'):
       return os.environ