remote_agent container monitoring update

PROD-15486

Change-Id: I3d1533316b7694bf3bd6861215b35e3196c2d3bb
diff --git a/ceph/common.sls b/ceph/common.sls
index 03acf12..874a444 100644
--- a/ceph/common.sls
+++ b/ceph/common.sls
@@ -1,25 +1,41 @@
 {%- from "ceph/map.jinja" import common with context %}
 
+{% if not common.get('container_mode', False) %}
+
 common_packages:
   pkg.installed:
   - names: {{ common.pkgs }}
 
+{%- endif %}
+
+{{ common.prefix_dir }}/etc/ceph:
+  file.directory:
+  - user: root
+  - group: root
+  - mode: 755
+  - makedirs: True
+
 common_config:
   file.managed:
-  - name: /etc/ceph/ceph.conf
+  - name: {{ common.prefix_dir }}/etc/ceph/ceph.conf
   - source: salt://ceph/files/{{ common.version }}/ceph.conf.{{ grains.os_family }}
   - template: jinja
+  {% if not common.get('container_mode', False) %}
   - require:
     - pkg: common_packages
+  {%- endif %}
+
 
 {%- if common.keyring is defined and common.keyring.admin is defined %}
 
 ceph_create_keyring_admin:
   cmd.run:
-  - name: "ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin {%- for cap_name, cap in  common.keyring.admin.caps.iteritems() %} --cap {{ cap_name }} '{{ cap }}' {%- endfor %}"
-  - unless: "test -f /etc/ceph/ceph.client.admin.keyring"
+  - name: "ceph-authtool --create-keyring {{ common.prefix_dir }}/etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin {%- for cap_name, cap in  common.keyring.admin.caps.iteritems() %} --cap {{ cap_name }} '{{ cap }}' {%- endfor %}"
+  - unless: "test -f {{ common.prefix_dir }}/etc/ceph/ceph.client.admin.keyring"
   - require:
+  {% if not common.get('container_mode', False) %}
     - pkg: common_packages
+  {%- endif %}
     - file: common_config
 
 {%- endif %}
@@ -30,15 +46,17 @@
 
 {%- if loop.index0 == 0 %}
 
-/etc/ceph/ceph.client.admin.keyring:
+{{ common.prefix_dir }}/etc/ceph/ceph.client.admin.keyring:
   file.managed:
   - source: salt://ceph/files/keyring
   - template: jinja
-  - unless: "test -f /etc/ceph/ceph.client.admin.keyring"
+  - unless: "test -f {{ common.prefix_dir }}/etc/ceph/ceph.client.admin.keyring"
   - defaults:
       node_grains: {{ node_grains|yaml }}
   - require:
+  {% if not common.get('container_mode', False) %}
     - pkg: common_packages
+  {%- endif %}
     - file: common_config
 
 {%- endif %}
diff --git a/ceph/files/grafana_dashboards/ceph_cluster_prometheus.json b/ceph/files/grafana_dashboards/ceph_cluster_prometheus.json
index 4f99242..cf88f47 100644
--- a/ceph/files/grafana_dashboards/ceph_cluster_prometheus.json
+++ b/ceph/files/grafana_dashboards/ceph_cluster_prometheus.json
@@ -170,7 +170,7 @@
           "tableColumn": "",
           "targets": [
             {
-              "expr": "ceph_num_mon_quorum",
+              "expr": "avg(ceph_num_mon_quorum)",
               "format": "time_series",
               "interval": "",
               "intervalFactor": 1,
diff --git a/ceph/map.jinja b/ceph/map.jinja
index 0986380..4cc3ec5 100644
--- a/ceph/map.jinja
+++ b/ceph/map.jinja
@@ -3,6 +3,8 @@
 Debian:
   pkgs:
   - ceph-common
+  container_mode: False
+  prefix_dir: ''
   services: []
 {%- endload %}
 {% set common = salt['grains.filter_by'](common_defaults, merge=salt['pillar.get']('ceph:common')) %}
diff --git a/ceph/setup/keyring.sls b/ceph/setup/keyring.sls
index 0c9ce20..aeafc70 100644
--- a/ceph/setup/keyring.sls
+++ b/ceph/setup/keyring.sls
@@ -1,5 +1,7 @@
 {%- from "ceph/map.jinja" import common with context %}
 
+{% if not common.get('container_mode', False) %}
+
 {# run only if ceph cluster is present #}
 {%- for node_name, node_grains in salt['mine.get']('ceph:common:keyring:admin', 'grains.items', 'pillar').iteritems() %}
 
@@ -13,7 +15,7 @@
 
 {%- if keyring.name != 'admin' and keyring.key is defined and common.get("manage_keyring", False) %}
 
-/etc/ceph/ceph.client.{{ keyring.name }}.keyring:
+{{ common.prefix_dir }}/etc/ceph/ceph.client.{{ keyring.name }}.keyring:
   file.managed:
   - source: salt://ceph/files/keyring
   - template: jinja
@@ -23,16 +25,16 @@
 
 ceph_import_keyring_{{ keyring.name }}:
   cmd.run:
-  - name: "ceph auth import -i /etc/ceph/ceph.client.{{ keyring.name }}.keyring"
+  - name: "ceph auth import -i {{ common.prefix_dir }}/etc/ceph/ceph.client.{{ keyring.name }}.keyring"
   - onchanges:
-    - file: /etc/ceph/ceph.client.{{ keyring.name }}.keyring
+    - file: {{ common.prefix_dir }}/etc/ceph/ceph.client.{{ keyring.name }}.keyring
 
 {%- elif keyring.name != 'admin' %}
 
 ceph_create_keyring_{{ keyring.name }}:
   cmd.run:
-  - name: "ceph auth get-or-create client.{{ keyring.name }} {%- for cap_name, cap in  keyring.caps.iteritems() %} {{ cap_name }} '{{ cap }}' {%- endfor %} > /etc/ceph/ceph.client.{{ keyring.name }}.keyring"
-  - unless: "test -f /etc/ceph/ceph.client.{{ keyring.name }}.keyring"
+  - name: "ceph auth get-or-create client.{{ keyring.name }} {%- for cap_name, cap in  keyring.caps.iteritems() %} {{ cap_name }} '{{ cap }}' {%- endfor %} > {{ common.prefix_dir }}/etc/ceph/ceph.client.{{ keyring.name }}.keyring"
+  - unless: "test -f {{ common.prefix_dir }}/etc/ceph/ceph.client.{{ keyring.name }}.keyring"
 
 {%- endif %}
 
@@ -40,7 +42,7 @@
 
 {%- if keyring_name != 'admin' and keyring.key is defined and common.get("manage_keyring", False) %}
 
-/etc/ceph/ceph.client.{{ keyring_name }}.keyring:
+{{ common.prefix_dir }}/etc/ceph/ceph.client.{{ keyring_name }}.keyring:
   file.managed:
   - source: salt://ceph/files/keyring
   - template: jinja
@@ -50,16 +52,16 @@
 
 ceph_import_keyring_{{ keyring_name }}:
   cmd.run:
-  - name: "ceph auth import -i /etc/ceph/ceph.client.{{ keyring_name }}.keyring"
+  - name: "ceph auth import -i {{ common.prefix_dir }}/etc/ceph/ceph.client.{{ keyring_name }}.keyring"
   - onchanges:
-    - file: /etc/ceph/ceph.client.{{ keyring_name }}.keyring
+    - file: {{ common.prefix_dir }}/etc/ceph/ceph.client.{{ keyring_name }}.keyring
 
 {%- elif keyring_name != 'admin' %}
 
 ceph_create_keyring_{{ keyring_name }}:
   cmd.run:
-  - name: "ceph auth get-or-create client.{{ keyring_name }} {%- for cap_name, cap in  keyring.caps.iteritems() %} {{ cap_name }} '{{ cap }}' {%- endfor %} > /etc/ceph/ceph.client.{{ keyring_name }}.keyring"
-  - unless: "test -f /etc/ceph/ceph.client.{{ keyring_name }}.keyring"
+  - name: "ceph auth get-or-create client.{{ keyring_name }} {%- for cap_name, cap in  keyring.caps.iteritems() %} {{ cap_name }} '{{ cap }}' {%- endfor %} > {{ common.prefix_dir }}/etc/ceph/ceph.client.{{ keyring_name }}.keyring"
+  - unless: "test -f {{ common.prefix_dir }}/etc/ceph/ceph.client.{{ keyring_name }}.keyring"
 
 {%- endif %}
 
@@ -71,4 +73,6 @@
 
 {%- endif %}
 
-{%- endfor %}
\ No newline at end of file
+{%- endfor %}
+
+{%- endif %}
diff --git a/metadata/service/common/container.yml b/metadata/service/common/container.yml
new file mode 100644
index 0000000..78b7b0c
--- /dev/null
+++ b/metadata/service/common/container.yml
@@ -0,0 +1,8 @@
+applications:
+- ceph
+parameters:
+  ceph:
+    common:
+      enabled: true
+      container_mode: true
+      prefix_dir: ${_param:ceph_common_prefix_dir}
diff --git a/metadata/service/monitoring/cluster_stats.yml b/metadata/service/monitoring/cluster_stats.yml
index 02fc70a..85ae108 100644
--- a/metadata/service/monitoring/cluster_stats.yml
+++ b/metadata/service/monitoring/cluster_stats.yml
@@ -3,6 +3,8 @@
 classes:
 - service.ceph.support
 parameters:
+  _param:
+    ceph_monitoring_user: admin
   ceph:
     monitoring:
       cluster_stats: