blob: b5d45094ade712ba5bf80faf2b2374d8faab7871 [file] [log] [blame]
Scott Baker2290b052014-05-08 10:28:22 -07001import os
2import sys
3import traceback
4from requestrouter.models import ServiceMap
5from observer.deleter import Deleter
6from util.logger import Logger, logging
7
8parentdir = os.path.join(os.path.dirname(__file__),"..")
9sys.path.insert(0,parentdir)
10
11from rrlib import RequestRouterLibrary
12from configurationPush import ConfigurationPush
13import rrlib_config
14
15logger = Logger(level=logging.INFO)
16
17class ServiceMapDeleter(Deleter, RequestRouterLibrary, ConfigurationPush):
18 model='ServiceMap'
19
20 def __init__(self, **args):
21 Deleter.__init__(self, **args)
22 RequestRouterLibrary.__init__(self)
23 ConfigurationPush.__init__(self)
24
25
26 def call(self, pk, model_dict):
27 try:
28 servicemap = ServiceMap.objects.get(pk=pk)
29 service_uid = self.get_servicemap_uid(servicemap)
30 self.config_push(service_uid, rrlib_config.REDIR_USER, "/opt/planetstack/rr_observer/playbook/site_redir_delete.yml", "/etc/ansible/requestrouter/dnsredir/hosts")
31 self.config_push(service_uid, rrlib_config.DEMUX_USER, "/opt/planetstack/rr_observer/playbook/site_demux_delete.yml", "/etc/ansible/requestrouter/dnsdemux/hosts")
32 print "XXX delete ServiceMap %s", servicemap.name
33 return True
34 except Exception, e:
35 traceback.print_exc()
36 logger.exception("Failed to erase map '%s'" % map_name)
37 return False
38
39if __name__ == "__main__":
40 smap = ServiceMapDeleter()
41 smap.call( 6, {'name': 'Service23'} )