blob: fe59f4aeb6226718c042b3faf208a879ce2cfa80 [file] [log] [blame]
raghunath dudyalaa927d562016-09-28 14:04:13 +05301import hashlib
2import os
3import socket
4import sys
5import base64
6import time
7#import threading
8import subprocess
9import random
10import tempfile
11#from sshtunnel import SSHTunnelForwarder
12from django.db.models import F, Q
13from xos.config import Config
14from synchronizers.base.syncstep import SyncStep
Sapan Bhatia7e9f4d32017-01-24 19:32:59 +010015from synchronizers.base.ansible_helper import run_template_ssh
raghunath dudyalaa927d562016-09-28 14:04:13 +053016from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
17from core.models import Service, Slice
18from services.monitoring.models import CeilometerService, MonitoringChannel
19from xos.logger import Logger, logging
20
21parentdir = os.path.join(os.path.dirname(__file__),"..")
22sys.path.insert(0,parentdir)
23
24logger = Logger(level=logging.INFO)
25
26class SyncCeilometerService(SyncInstanceUsingAnsible):
27 provides=[CeilometerService]
28 observes=CeilometerService
29 requested_interval=0
30 template_name = "sync_ceilometerservice.yaml"
31 service_key_name = "/opt/xos/synchronizers/monitoring/monitoring_channel_private_key"
32
33 def __init__(self, *args, **kwargs):
34 super(SyncCeilometerService, self).__init__(*args, **kwargs)
35
36 def fetch_pending(self, deleted):
37 if (not deleted):
38 objs = CeilometerService.get_service_objects().filter(Q(enacted__lt=F('updated')) | Q(enacted=None),Q(lazy_blocked=False))
39 else:
40 objs = CeilometerService.get_deleted_service_objects()
41
42 return objs
43
44 def get_instance(self, o):
45 return o.get_instance()
46
47 def get_extra_attributes(self, o):
48 fields={}
49 fields["instance_hostname"] = o.get_instance().instance_name.replace("_","-")
50 #fields = {"instance_hostname": o.get_instance().instance_name.replace("_","-"),
51 # "instance_ip": o.get_instance().private_ip()}
52
53
54 return fields
55
56 def sync_fields(self, o, fields):
57 # the super causes the playbook to be run
58 super(SyncCeilometerService, self).sync_fields(o, fields)
59
60 def run_playbook(self, o, fields):
61 instance = self.get_instance(o)
62 #if (instance.isolation=="container"):
63 # If the instance is already a container, then we don't need to
64 # install ONOS.
65 # return
66 super(SyncCeilometerService,self).run_playbook(o, fields)
67
68 def delete_record(self, m):
69 pass