blob: 2a9ee11904f6c157b349a3fb8466ec000e2cd3f4 [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
Murat Parlakisik638c65f2017-05-31 11:10:24 +030014from synchronizers.new_base.syncstep import SyncStep
15from synchronizers.new_base.ansible_helper import run_template_ssh
16from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
17#from services.monitoring.models import CeilometerService, MonitoringChannel
18#from core.models import Service, Slice
19from modelaccessor import *
raghunath dudyalaa927d562016-09-28 14:04:13 +053020from xos.logger import Logger, logging
21
22parentdir = os.path.join(os.path.dirname(__file__),"..")
23sys.path.insert(0,parentdir)
24
25logger = Logger(level=logging.INFO)
26
27class SyncCeilometerService(SyncInstanceUsingAnsible):
28 provides=[CeilometerService]
29 observes=CeilometerService
30 requested_interval=0
31 template_name = "sync_ceilometerservice.yaml"
32 service_key_name = "/opt/xos/synchronizers/monitoring/monitoring_channel_private_key"
33
34 def __init__(self, *args, **kwargs):
35 super(SyncCeilometerService, self).__init__(*args, **kwargs)
36
37 def fetch_pending(self, deleted):
38 if (not deleted):
39 objs = CeilometerService.get_service_objects().filter(Q(enacted__lt=F('updated')) | Q(enacted=None),Q(lazy_blocked=False))
40 else:
41 objs = CeilometerService.get_deleted_service_objects()
42
43 return objs
44
45 def get_instance(self, o):
46 return o.get_instance()
47
48 def get_extra_attributes(self, o):
49 fields={}
50 fields["instance_hostname"] = o.get_instance().instance_name.replace("_","-")
51 #fields = {"instance_hostname": o.get_instance().instance_name.replace("_","-"),
52 # "instance_ip": o.get_instance().private_ip()}
53
54
55 return fields
56
57 def sync_fields(self, o, fields):
58 # the super causes the playbook to be run
59 super(SyncCeilometerService, self).sync_fields(o, fields)
60
61 def run_playbook(self, o, fields):
62 instance = self.get_instance(o)
63 #if (instance.isolation=="container"):
64 # If the instance is already a container, then we don't need to
65 # install ONOS.
66 # return
67 super(SyncCeilometerService,self).run_playbook(o, fields)
68
69 def delete_record(self, m):
70 pass