blob: 60fe3374d3d9e31e7583a130f52e3bb9c8660540 [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
Scott Bakereaeabad2015-02-09 11:18:46 -08007from planetstack.config import Config, XOS_DIR
Scott Baker2290b052014-05-08 10:28:22 -07008
9parentdir = os.path.join(os.path.dirname(__file__),"..")
10sys.path.insert(0,parentdir)
11
12from rrlib import RequestRouterLibrary
13from configurationPush import ConfigurationPush
14import rrlib_config
15
16logger = Logger(level=logging.INFO)
17
18class ServiceMapDeleter(Deleter, RequestRouterLibrary, ConfigurationPush):
19 model='ServiceMap'
20
21 def __init__(self, **args):
22 Deleter.__init__(self, **args)
23 RequestRouterLibrary.__init__(self)
24 ConfigurationPush.__init__(self)
25
26
27 def call(self, pk, model_dict):
28 try:
29 servicemap = ServiceMap.objects.get(pk=pk)
30 service_uid = self.get_servicemap_uid(servicemap)
Scott Bakereaeabad2015-02-09 11:18:46 -080031 self.config_push(service_uid, rrlib_config.REDIR_USER, XOS_DIR + "/rr_observer/playbook/site_redir_delete.yml", "/etc/ansible/requestrouter/dnsredir/hosts")
32 self.config_push(service_uid, rrlib_config.DEMUX_USER, XOS_DIR + "/rr_observer/playbook/site_demux_delete.yml", "/etc/ansible/requestrouter/dnsdemux/hosts")
Scott Baker2290b052014-05-08 10:28:22 -070033 print "XXX delete ServiceMap %s", servicemap.name
34 return True
35 except Exception, e:
36 traceback.print_exc()
37 logger.exception("Failed to erase map '%s'" % map_name)
38 return False
39
40if __name__ == "__main__":
41 smap = ServiceMapDeleter()
42 smap.call( 6, {'name': 'Service23'} )