Gnocchi returned unauthorized error when creating resources alarm from Heat

asked 2017-05-23 22:55:26 -0500

CK Lai gravatar image

updated 2017-05-24 07:50:19 -0500

rbowen gravatar image

I have installed Ocata Openstack by following the following OpenStack Installation Tutorial for Red Hat Enterprise Linux and CentOS.

I have created a Heat Template for creating an autoscaling stack:

heat_template_version: 2015-10-15
description: Example auto scale group, policy and alarm

parameters:
  pcc_name:
    type: string
    description: VM name
    default: pcc
  pcc_image:
    type: string
    description: Image used for servers
    default: CentOS68A
  pcc_flavor:
    type: string
    description: flavor used by the web servers
    default: m1.medium
  policy_name:
    type: string
    description: VM name
    default: nodeA
  policy_image:
    type: string
    description: Image used for servers
    default: CentOS68B
  policy_flavor:
    type: string
    description: flavor used by the web servers
    default: m1.large
  policy_ip:
    type: string
    description: Network used by the server
    default: 172.16.1.149
  key_name:
    type: string
    description: SSH key to connect to the servers
    default: mykey
  public_network:
    type: string
    description: Network used by the server
    default: public
  private_network:
    type: string
    description: Network used by the server
    default: private
  private_subnet:
    type: string
    description: Subnet used by the server
    default: private

resources:
  server_port:
    type: OS::Neutron::Port
    properties:
      network_id: { get_param: private_network }
      fixed_ips:
        - subnet_id: { get_param: private_subnet }
          ip_address: { get_param: policy_ip }

  policy_instance:
    type: OS::Nova::Server
    properties:
      name: {get_param: policy_name}
      flavor: {get_param: policy_flavor}
      image: {get_param: policy_image}
      key_name: {get_param: key_name}
      networks:
        - port: { get_resource: server_port }
      user_data_format: RAW
      user_data: {get_resource: policy_config}

  floating_ip:
     type: OS::Neutron::FloatingIP
     properties:
       floating_network: {get_param: public_network}

  association:
     type: OS::Neutron::FloatingIPAssociation
     properties:
       floatingip_id: { get_resource: floating_ip }
       port_id: {get_attr: [policy_instance, addresses, {get_param: private_network}, 0, port]}

  scaleup_group:
    type: OS::Heat::AutoScalingGroup
    properties:
      cooldown: 60
      desired_capacity: 0
      max_size: 3
      min_size: 0
      resource:
        type: http://localhost/templates/pcc_v1.yaml
        properties:
          name: {get_param: pcc_name}
          flavor: {get_param: pcc_flavor}
          image: {get_param: pcc_image}
          key_name: {get_param: key_name}
          network: {get_param: private_network}
          user_data: {get_resource: pcc_config}

  scaleup_policy:
    type: OS::Heat::ScalingPolicy
    properties:
      adjustment_type: change_in_capacity
      auto_scaling_group_id: { get_resource: scaleup_group }
      cooldown: 60
      scaling_adjustment: 1

  scaledown_policy:
    type: OS::Heat::ScalingPolicy
    properties:
      adjustment_type: change_in_capacity
      auto_scaling_group_id: { get_resource: scaleup_group }
      cooldown: 60
      scaling_adjustment: -1

  cpu_alarm_high:
    type: OS::Ceilometer::GnocchiAggregationByResourcesAlarm
    properties:
      description: Scale-up if the last CPU > 20%
      metric: cpu_util
      aggregation_method: last
      granularity: 300
      evaluation_periods: 1
      threshold: 20
      comparison_operator: gt
      alarm_actions:
        - {get_attr: [scaleup_policy, alarm_url]}
      resource_type: instance
      query:
        str_replace:
          template: '{"=": {"server_group": "stack_id"}}'
          params:
            stack_id: {get_param: "OS::stack_id"}

  cpu_alarm_low:
    type: OS::Ceilometer::GnocchiAggregationByResourcesAlarm
    properties:
      description: Scale-up if the last CPU < 10%
      metric: cpu_util
      aggregation_method: last
      granularity: 300
      evaluation_periods: 1
      threshold: 10
      comparison_operator: lt
      alarm_actions:
        - {get_attr: [scaledown_policy, alarm_url]}
      resource_type: instance
      query:
        str_replace:
          template: '{"=": {"server_group": "stack_id"}}'
          params:
            stack_id: {get_param: "OS::stack_id"}

  pcc_config:
    type: "OS::Heat::CloudConfig"
    properties:
      cloud_config:
        users:
        - default
        - name: tango
          gecos: "Tango User"
          primary-group: tango
          lock-passwd: false
          shell: /bin/bash
          sudo: "ALL=(ALL) NOPASSWD:ALL"
          homedir: /tango
        ssh_pwauth: true

        chpasswd:
          list: |
            tango:t3l3com
          expire: False

        write_files:
          - path: /etc/resolv.conf
            permissions: '0644'
            content: |
              domain pcc.com
              nameserver 192.168.1.68

          - path: /etc/sysconfig/network
            permissions: '0644'
            content: |
              NETWORKING=yes
              HOSTNAME=DYNAMIC_HOST_NAME_PLACEHOLDER

  policy_config:
    type: "OS::Heat::CloudConfig"
    properties:
      cloud_config:
        growpart:
          mode: auto
          devices: ['/']
          ignore_growroot_disabled: false

When creating the stack, the following error was shown in heat-engine.log:

2017-05-24 04:20:21.604 28581 INFO heat.engine.resource [req-d59a4460-5c98-46ff-a88f-884bac069441 demo demo - - -] CREATE: AodhGnocchiAggregationByResourcesAlarm "cpu_alarm_low" Stack "Ocata_Test_050" [28f7556a-dc06-4f08-9ec4-3d0c21a86e90]
2017-05-24 04:20:21.604 28581 ERROR heat ...
(more)
edit retag flag offensive close merge delete