remove requestrouter service from xos
Change-Id: Iba9857f8d07339f23f3bf524ef692c970d601089
diff --git a/xos/services/requestrouter/__init__.py b/xos/services/requestrouter/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/xos/services/requestrouter/__init__.py
+++ /dev/null
diff --git a/xos/services/requestrouter/admin.py b/xos/services/requestrouter/admin.py
deleted file mode 100644
index a17bc44..0000000
--- a/xos/services/requestrouter/admin.py
+++ /dev/null
@@ -1,62 +0,0 @@
-from django.contrib import admin
-
-from services.requestrouter.models import *
-from django import forms
-from django.utils.safestring import mark_safe
-from django.contrib.auth.admin import UserAdmin
-from django.contrib.admin.widgets import FilteredSelectMultiple
-from django.contrib.auth.forms import ReadOnlyPasswordHashField
-from django.contrib.auth.signals import user_logged_in
-from django.utils import timezone
-from suit.widgets import LinkedSelect
-from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, ServicePrivilegeInline
-
-class RequestRouterAdmin(ReadOnlyAwareAdmin):
- # Change the application breadcrumb to point to an RR Service if one is
- # defined
-
- change_form_template = "admin/change_form_bc.html"
- change_list_template = "admin/change_list_bc.html"
- custom_app_breadcrumb_name = "Request Router"
- @property
- def custom_app_breadcrumb_url(self):
- services = RequestRouterService.objects.all()
- if len(services)==1:
- return "/admin/requestrouter/requestrouterservice/%s/" % services[0].id
- else:
- return "/admin/requestrouter/requestrouterservice/"
-
-class RequestRouterServiceAdmin(ServiceAppAdmin):
- model = RequestRouterService
- verbose_name = "Request Router Service"
- verbose_name_plural = "Request Router Service"
- list_display = ("name","enabled")
- fieldsets = [(None, {'fields': ['name','enabled','versionNumber', 'description','behindNat','defaultTTL','defaultAction','lastResortAction','maxAnswers'], 'classes':['suit-tab suit-tab-general']})]
- inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
-
- user_readonly_fields = ["name", "enabled", "versionNumber", "description", "behindNat", "defaultTTL", "defaultAction", "lastResortAction", "maxAnswers"]
-
- suit_form_tabs =(('general', 'Request Router Service Details'),
- ('administration', 'Administration'),
- ('slices','Slices'),
- ('serviceattrs','Additional Attributes'),
- ('serviceprivileges','Privileges'),
- )
-
- suit_form_includes = (('rradmin.html', 'top', 'administration'),)
-
-class ServiceMapAdmin(RequestRouterAdmin):
- model = ServiceMap
- verbose_name = "Service Map"
- verbose_name_plural = "Service Map"
- list_display = ("name", "owner", "slice", "prefix")
- fieldsets = [(None, {'fields': ['name','owner','slice', 'prefix','siteMap','accessMap'], 'classes':['suit-tab suit-tab-general']})]
-
- user_readonly_fields = ["name", "owner", "slice", "prefix", "siteMap", "accessMap"]
-
- suit_form_tabs =(('general', 'Service Map Details'),
- )
-
-admin.site.register(RequestRouterService, RequestRouterServiceAdmin)
-admin.site.register(ServiceMap, ServiceMapAdmin)
-
diff --git a/xos/services/requestrouter/migrations/__init__.py b/xos/services/requestrouter/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/xos/services/requestrouter/migrations/__init__.py
+++ /dev/null
diff --git a/xos/services/requestrouter/models.py b/xos/services/requestrouter/models.py
deleted file mode 100644
index 8e4cc43..0000000
--- a/xos/services/requestrouter/models.py
+++ /dev/null
@@ -1,41 +0,0 @@
-from core.models import User,Site,Service,SingletonModel,PlCoreBase, Slice
-import os
-from django.db import models
-from django.forms.models import model_to_dict
-
-# Create your models here.
-
-class RequestRouterService(SingletonModel,Service):
- class Meta:
- app_label = "requestrouter"
- verbose_name = "Request Router Service"
-
- behindNat = models.BooleanField(default=False, help_text="Enables 'Behind NAT' mode.")
- defaultTTL = models.PositiveIntegerField(default=30, help_text="DNS response time-to-live(TTL)")
- defaultAction = models.CharField(max_length=30, default = "best", help_text="Review if this should be enum")
- lastResortAction = models.CharField(max_length=30, default = "random", help_text="Review if this should be enum")
- maxAnswers = models.PositiveIntegerField(default=3, help_text="Maximum number of answers in DNS response.")
-
- def __unicode__(self): return u'Request Router Service'
-
-class ServiceMap(PlCoreBase):
-
- class Meta:
- app_label = "requestrouter"
-
- name = models.SlugField(max_length=50, unique=True, blank=False, null=False, help_text="name of this service map")
- owner = models.ForeignKey(Service, help_text="service which owns this map")
- slice = models.ForeignKey(Slice, help_text="slice that implements this service")
- prefix = models.CharField(max_length=256, help_text="FQDN of the region of URI space managed by RR on behalf of this service")
- # need to fix the upload location appropriately, for now we are not using access/site map
- siteMap = models.FileField(upload_to="maps/", help_text="maps client requests to service instances", blank=True)
- accessMap = models.FileField(upload_to="maps/", help_text="specifies which client requests are allowed", blank=True)
-
- def siteMapName(self):
- return self.name + ".site"
-
- def accessMapName(self):
- return self.name + ".access"
-
- def __unicode__(self): return u'%s' % self.name
-
diff --git a/xos/services/requestrouter/templates/rradmin.html b/xos/services/requestrouter/templates/rradmin.html
deleted file mode 100644
index 142d87a..0000000
--- a/xos/services/requestrouter/templates/rradmin.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<div class = "left-nav">
-<ul>
-{% for admin in registered_admins %}
- <li><a href="{{ admin.url }}">{{ admin.name }}</a></li>
-{% endfor %}
-</ul>
-</div>
-
-<!--
-<ul>
-<li><a href="/admin/requestrouter/servicemap/">Service Maps</a></li>
-</ul>
--->
diff --git a/xos/synchronizers/requestrouter/configurationPush.py b/xos/synchronizers/requestrouter/configurationPush.py
deleted file mode 100644
index 857de8b..0000000
--- a/xos/synchronizers/requestrouter/configurationPush.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import ansible.playbook
-import ansible.constants as C
-import ansible.utils.template
-from ansible import errors
-from ansible import callbacks
-from ansible import utils
-from subprocess import call
-
-class ConfigurationPush:
- def __init__(self):
- pass
-
- def config_push(self, service_name, user, playbook_name,hostfile):
- '''stats = callbacks.AggregateStats()
- playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
- runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY)
- pb = ansible.playbook.PlayBook(playbook="playbook/site.yml",
- callbacks=playbook_cb,
- runner_callbacks=runner_cb,
- stats=stats
- )
- result = pb.run()
- print result
- '''
-
- call("ansible-playbook --private-key=planetw "+playbook_name+" -i "+hostfile+" -u "+user+" --extra-vars \"name="+service_name+"\"", shell=True)
-
-
-if __name__ == "__main__":
- main()
diff --git a/xos/synchronizers/requestrouter/deleters/servicemap_deleter.py b/xos/synchronizers/requestrouter/deleters/servicemap_deleter.py
deleted file mode 100644
index d2efd64..0000000
--- a/xos/synchronizers/requestrouter/deleters/servicemap_deleter.py
+++ /dev/null
@@ -1,42 +0,0 @@
-import os
-import sys
-import traceback
-from services.requestrouter.models import ServiceMap
-from synchronizers.base.deleter import Deleter
-from xos.logger import Logger, logging
-from xos.config import Config, XOS_DIR
-
-parentdir = os.path.join(os.path.dirname(__file__),"..")
-sys.path.insert(0,parentdir)
-
-from rrlib import RequestRouterLibrary
-from configurationPush import ConfigurationPush
-import rrlib_config
-
-logger = Logger(level=logging.INFO)
-
-class ServiceMapDeleter(Deleter, RequestRouterLibrary, ConfigurationPush):
- model='ServiceMap'
-
- def __init__(self, **args):
- Deleter.__init__(self, **args)
- RequestRouterLibrary.__init__(self)
- ConfigurationPush.__init__(self)
-
-
- def call(self, pk, model_dict):
- try:
- servicemap = ServiceMap.objects.get(pk=pk)
- service_uid = self.get_servicemap_uid(servicemap)
- self.config_push(service_uid, rrlib_config.REDIR_USER, XOS_DIR + "/observers/requestrouter/playbook/site_redir_delete.yml", "/etc/ansible/requestrouter/dnsredir/hosts")
- self.config_push(service_uid, rrlib_config.DEMUX_USER, XOS_DIR + "/observers/requestrouter/playbook/site_demux_delete.yml", "/etc/ansible/requestrouter/dnsdemux/hosts")
- print "XXX delete ServiceMap %s", servicemap.name
- return True
- except Exception, e:
- traceback.print_exc()
- logger.exception("Failed to erase map '%s'" % map_name)
- return False
-
-if __name__ == "__main__":
- smap = ServiceMapDeleter()
- smap.call( 6, {'name': 'Service23'} )
diff --git a/xos/synchronizers/requestrouter/model-deps b/xos/synchronizers/requestrouter/model-deps
deleted file mode 100644
index 36ef620..0000000
--- a/xos/synchronizers/requestrouter/model-deps
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "ServiceMap": [
- "Slice"
- ],
- "Slice": [
- "Site",
- "Service"
- ],
- "User": [
- "Site"
- ]
-}
diff --git a/xos/synchronizers/requestrouter/playbook/roles/delete_demux/handlers/main.yml b/xos/synchronizers/requestrouter/playbook/roles/delete_demux/handlers/main.yml
deleted file mode 100644
index a888468..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/delete_demux/handlers/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-- name: restart dnsdemux
- service: name=dnsdemux state=restarted
diff --git a/xos/synchronizers/requestrouter/playbook/roles/delete_demux/tasks/main.yml b/xos/synchronizers/requestrouter/playbook/roles/delete_demux/tasks/main.yml
deleted file mode 100644
index 417401a..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/delete_demux/tasks/main.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-# This playbook contains plays to delete configuration files from dnsdemux slice
-- name: delete dnsdemux config files
- file: path={{dst_dnsdemux_conf}}/{{name}}.conf state=absent
- notify: restart dnsdemux
diff --git a/xos/synchronizers/requestrouter/playbook/roles/delete_demux/vars/main.yml b/xos/synchronizers/requestrouter/playbook/roles/delete_demux/vars/main.yml
deleted file mode 100644
index b457050..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/delete_demux/vars/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
----
-# Variables listed here are applicable to all host groups
-
-src_dnsdemux: ../../../../temp_config/dnsdemux
-dst_dnsdemux_conf: /etc/dnsdemux/default/
-
diff --git a/xos/synchronizers/requestrouter/playbook/roles/delete_redir/handlers/main.yml b/xos/synchronizers/requestrouter/playbook/roles/delete_redir/handlers/main.yml
deleted file mode 100644
index 8aa497e..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/delete_redir/handlers/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-- name: restart dnsredir
- service: name=dnsredir state=restarted
diff --git a/xos/synchronizers/requestrouter/playbook/roles/delete_redir/tasks/main.yml b/xos/synchronizers/requestrouter/playbook/roles/delete_redir/tasks/main.yml
deleted file mode 100644
index 58833bb..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/delete_redir/tasks/main.yml
+++ /dev/null
@@ -1,13 +0,0 @@
----
-# This playbook contains plays to delete configuration files from dnsredir slice
-- name: delete maps.d directory ( and deletes all intermeadiate directories )
- #copy: src={{src_dnsredir}}/{{name}}.d dest={{dst_dnsredir_confdir}}
- file: path={{dst_dnsredir_confdir}}/{{name}}.d/maps.d state=absent
-
-- name: delete config directory
- file: path={{dst_dnsredir_confdir}}/{{name}}.d/ state=absent
-
-- name: copy dnsredir config file
- file: path={{dst_dnsredir_conf}}/{{name}}.conf state=absent
- notify: restart dnsredir
-
diff --git a/xos/synchronizers/requestrouter/playbook/roles/delete_redir/vars/main.yml b/xos/synchronizers/requestrouter/playbook/roles/delete_redir/vars/main.yml
deleted file mode 100644
index dc79d35..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/delete_redir/vars/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
----
-# Variables listed here are applicable to all host groups
-
-src_dnsredir: ../../../../temp_config/dnsredir
-dst_dnsredir_conf: /etc/dnsredir/conf.d/
-dst_dnsredir_confdir: /etc/dnsredir
diff --git a/xos/synchronizers/requestrouter/playbook/roles/demux/handlers/main.yml b/xos/synchronizers/requestrouter/playbook/roles/demux/handlers/main.yml
deleted file mode 100644
index a888468..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/demux/handlers/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-- name: restart dnsdemux
- service: name=dnsdemux state=restarted
diff --git a/xos/synchronizers/requestrouter/playbook/roles/demux/tasks/main.yml b/xos/synchronizers/requestrouter/playbook/roles/demux/tasks/main.yml
deleted file mode 100644
index 0339aed..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/demux/tasks/main.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-# This playbook contains plays to copy configurations to destination
-- name: copy dnsdemux config files
- copy: src={{src_dnsdemux}}/{{name}}.conf dest={{dst_dnsdemux_conf}}/{{name}}.conf
- notify: restart dnsdemux
-
-#- name: Start the dnsdemux service
- #service: name=dnsdemux state=started enabled=true
-
diff --git a/xos/synchronizers/requestrouter/playbook/roles/demux/vars/main.yml b/xos/synchronizers/requestrouter/playbook/roles/demux/vars/main.yml
deleted file mode 100644
index b457050..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/demux/vars/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
----
-# Variables listed here are applicable to all host groups
-
-src_dnsdemux: ../../../../temp_config/dnsdemux
-dst_dnsdemux_conf: /etc/dnsdemux/default/
-
diff --git a/xos/synchronizers/requestrouter/playbook/roles/redir/handlers/main.yml b/xos/synchronizers/requestrouter/playbook/roles/redir/handlers/main.yml
deleted file mode 100644
index 8aa497e..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/redir/handlers/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-- name: restart dnsredir
- service: name=dnsredir state=restarted
diff --git a/xos/synchronizers/requestrouter/playbook/roles/redir/tasks/main.yml b/xos/synchronizers/requestrouter/playbook/roles/redir/tasks/main.yml
deleted file mode 100644
index e390ed9..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/redir/tasks/main.yml
+++ /dev/null
@@ -1,19 +0,0 @@
----
-# This playbook contains plays to copy configurations to destination
-- name: create maps.d directory ( and creates all intermeadiate directories )
- #copy: src={{src_dnsredir}}/{{name}}.d dest={{dst_dnsredir_confdir}}
- file: src={{src_dnsredir}}/{{name}}.d/maps.d dest={{dst_dnsredir_confdir}}/{{name}}.d/maps.d state=directory
-
-- name: copy map.conf
- copy: src={{src_dnsredir}}/{{name}}.d/maps.d/map.conf dest={{dst_dnsredir_confdir}}/{{name}}.d/maps.d/map.conf
-
-- name: copy codeen_nodes.conf
- copy: src={{src_dnsredir}}/{{name}}.d/codeen_nodes.conf dest={{dst_dnsredir_confdir}}/{{name}}.d/codeen_nodes.conf
-
-- name: copy node-to-ip.txt
- copy: src={{src_dnsredir}}/{{name}}.d/node-to-ip.txt dest={{dst_dnsredir_confdir}}/{{name}}.d/node-to-ip.txt
-
-- name: copy dnsredir config file
- copy: src={{src_dnsredir}}/{{name}}.conf dest={{dst_dnsredir_conf}}/{{name}}.conf
- notify: restart dnsredir
-
diff --git a/xos/synchronizers/requestrouter/playbook/roles/redir/vars/main.yml b/xos/synchronizers/requestrouter/playbook/roles/redir/vars/main.yml
deleted file mode 100644
index dc79d35..0000000
--- a/xos/synchronizers/requestrouter/playbook/roles/redir/vars/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
----
-# Variables listed here are applicable to all host groups
-
-src_dnsredir: ../../../../temp_config/dnsredir
-dst_dnsredir_conf: /etc/dnsredir/conf.d/
-dst_dnsredir_confdir: /etc/dnsredir
diff --git a/xos/synchronizers/requestrouter/playbook/site_demux.yml b/xos/synchronizers/requestrouter/playbook/site_demux.yml
deleted file mode 100644
index b5261dc..0000000
--- a/xos/synchronizers/requestrouter/playbook/site_demux.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-# This playbook copies the dnsdemux configuration files from temp directory.
-
-- name: copies the configuration files from temp directory
- hosts: all
- #remote_user: {{r_user}}
-
- roles:
- - demux
diff --git a/xos/synchronizers/requestrouter/playbook/site_demux_delete.yml b/xos/synchronizers/requestrouter/playbook/site_demux_delete.yml
deleted file mode 100644
index 49a7c87..0000000
--- a/xos/synchronizers/requestrouter/playbook/site_demux_delete.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-# This playbook deletes the dnsdemux configuration files from request router instances
-
-- name: deletes the configuration files from request router instances
- hosts: all
- #remote_user: {{r_user}}
-
- roles:
- - delete_demux
diff --git a/xos/synchronizers/requestrouter/playbook/site_redir.yml b/xos/synchronizers/requestrouter/playbook/site_redir.yml
deleted file mode 100644
index 50a7284..0000000
--- a/xos/synchronizers/requestrouter/playbook/site_redir.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-# This playbook copies the dnsredir configuration files from temp directory.
-
-- name: copies the configuration files from temp directory
- hosts: all
- #remote_user: {{r_user}}
-
- roles:
- - redir
diff --git a/xos/synchronizers/requestrouter/playbook/site_redir_delete.yml b/xos/synchronizers/requestrouter/playbook/site_redir_delete.yml
deleted file mode 100644
index 9a8611d..0000000
--- a/xos/synchronizers/requestrouter/playbook/site_redir_delete.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-# This playbook deletes the dnsredir configuration files from request router instances
-
-- name: deletes the configuration files from request router instances
- hosts: all
- #remote_user: {{r_user}}
-
- roles:
- - delete_redir
diff --git a/xos/synchronizers/requestrouter/rr_synchronizer_config b/xos/synchronizers/requestrouter/rr_synchronizer_config
deleted file mode 100644
index 179540e..0000000
--- a/xos/synchronizers/requestrouter/rr_synchronizer_config
+++ /dev/null
@@ -1,36 +0,0 @@
-
-[plc]
-name=plc
-#deployment=VICCI
-deployment=VINI
-
-[db]
-name=xos
-user=plstackuser
-#password=2uMDYtJK
-password=1HL07C0E
-host=localhost
-port=5432
-
-[api]
-host=128.112.171.237
-port=8000
-ssl_key=None
-ssl_cert=None
-ca_ssl_cert=None
-ratelimit_enabled=0
-omf_enabled=0
-mail_support_address=support@localhost
-nova_enabled=True
-
-[observer]
-dependency_graph=/opt/xos/synchronizers/requestrouter/model-deps
-steps_dir=/opt/xos/synchronizers/requestrouter/steps
-deleters_dir=/opt/xos/synchronizers/requestrouter/deleters
-log_file=console
-#/var/log/hpc.log
-driver=None
-
-#[feefie]
-#client_id='vicci_dev_central'
-#user_id='pl'
diff --git a/xos/synchronizers/requestrouter/rrlib.py b/xos/synchronizers/requestrouter/rrlib.py
deleted file mode 100644
index e2100b0..0000000
--- a/xos/synchronizers/requestrouter/rrlib.py
+++ /dev/null
@@ -1,203 +0,0 @@
-import os
-import base64
-import string
-import sys
-import socket
-from sets import Set
-if __name__ == '__main__':
- sys.path.append("/opt/xos")
- os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
-
-from xos.config import Config
-from core.models import Service
-from services.requestrouter.models import RequestRouterService, ServiceMap
-from xos.logger import Logger, logging
-import rrlib_config
-
-logger = Logger(level=logging.INFO)
-
-'''
-Conventions:
-1) All dnsredir backend will listen at port 9000+ servicemap.pk ( where pk is the primary key generated in django model)
-'''
-
-class RequestRouterLibrary:
-
- def __init__(self):
- pass
-
- def gen_slice_info(self, service=None):
- """generates instance information from slice of request router
- """
-
- if (service is None ):
- service = RequestRouterService.objects.get()
-
- mapping = {}
- #static mapping for demo purpose
- #mapping["node47.princeton.vicci.org"] = "128.112.171.112"
- mapping["node48.princeton.vicci.org"] = "128.112.171.114"
-
- '''for slice in service.service.all():
- name = slice.name
- for instance in slice.instances.all():
- mapping[instance.name] = str(instance.ip)
- '''
- return mapping
-
- def gen_servicemap_slice_info(self, servicemap):
- """generates instance information from slice of servicemap
- """
-
- wzone = Set(['arizona', 'stanford', 'on.lab', 'housten']) # zone=1 in cooden.conf
- ezone = Set(['princeton', 'atlanta', 'new york', 'georgia tech']) # zone=2 in coodeen.conf
-
- mapping_zone = {}
- mapping_ip = {}
- slice = servicemap.slice
- name = slice.name
- for instance in slice.instances.all():
- mapping_ip[instance.node.name] = socket.gethostbyname(instance.node.name)
- #print "instance name "+instance.name+str(instance.ip)+"\n"
- site = instance.node.site.name
- if(site.lower() in wzone):
- mapping_zone[instance.node.name] = str(1)
- else:
- mapping_zone[instance.node.name] = str(2)
-
- return mapping_ip, mapping_zone
-
-
-
- def gen_slice_file(self, service):
- """ generates host file for the slice information
- to be used by ansible to push configuration files
- """
-
- mapping = self.gen_slice_info(service)
-
- fn = "/etc/ansible/requestrouter/dnsredir/hosts"
- f = open(fn, "w")
- for (k,v) in mapping.items():
- f.write("%s\n" % k)
-
- fn = "/etc/ansible/requestrouter/dnsdemux/hosts"
- f = open(fn, "w")
- for (k,v) in mapping.items():
- f.write("%s\n" % k)
-
-
- def get_servicemap_uid(self, servicemap):
- seq = ("service_", str(servicemap.pk));
- return "".join(seq)
-
- def get_service_port(self, servicemap):
- return str(9000+servicemap.pk)
-
- def gen_dnsredir_serviceconf(self, servicemap):
- objname = self.get_servicemap_uid(servicemap)
-
- rr_mapping = self.gen_slice_info(None)
-
- #generate dnsredir.conf file parameters to be used in static file.
- mapping = {}
- mapping["port_listen"] = self.get_service_port(servicemap)
- mapping["configdir"] = rrlib_config.DNSREDIR_CONFIGDIR_PREFIX+objname+".d/"
- mapping["logdir"] = rrlib_config.DNSREDIR_LOGDIR_PREFIX+objname+".d"
- mapping["pidfile"] = rrlib_config.DNSREDIR_PIDFILE_PREFIX+objname+".pid"
- mapping["domain_name"] = servicemap.prefix
- mapping["heartbeat_port"] = rrlib_config.HEARTBEAT_PORT
-
- #generate dnsredir.conf file
-
- fn = "./temp_config/dnsredir/"+objname+".conf"
- f = open(fn, "w")
- for (k,v) in rr_mapping.items():
- f.write(mapping["domain_name"]+". NS "+k+". "+v+" 3600 \n" % mapping)
-
-
- f.write("""
-Default_TTL 30
-
-Port %(port_listen)s
-
-ConfigDir %(configdir)s
-
-MapsDir maps.d
-
-HTTPPort %(heartbeat_port)d
-
-PidFile %(pidfile)s
-
-HttpRequestPort 8081
-
-""" % mapping)
-
- #generate configdirectory
-
- os.mkdir("./temp_config/dnsredir/"+objname+".d")
-
- #geenrate codeen_nodes.conf
- mapping_ip, mapping_zone = self.gen_servicemap_slice_info(servicemap)
-
- codeen_name = "./temp_config/dnsredir/"+objname+".d/codeen_nodes.conf"
- f = open(codeen_name, "w")
- for (k,v) in mapping_zone.items():
- f.write(k+" zone="+v+" \n")
-
- iptxt = "./temp_config/dnsredir/"+objname+".d/node-to-ip.txt"
- f = open(iptxt, "w")
- for (k,v) in mapping_ip.items():
- f.write(k+" "+v+" \n")
-
- #generate maps directory
- os.mkdir("./temp_config/dnsredir/"+objname+".d/maps.d")
-
- # redirection map
- map = "./temp_config/dnsredir/"+objname+".d/maps.d/map.conf"
- f = open(map, "w")
- #hardcoded probable public IP masks from arizona and princeton region respectively
- f.write("prefix "+servicemap.prefix+" \n")
- f.write("map 150.135.211.252/32 zone 1 || zone 2 \n")
- f.write("map 128.112.171.112/24 zone 2 || zone 1 \n")
- f.write("map 0.0.0.0/0 zone 1 || zone 2 \n")
-
-
- def gen_dnsdemux_serviceconf(self, servicemap):
- '''
- generates frontend service*.conf file for each of the service
- It assumes that there is a dnsdemux frontend running on the RR istallation and will
- just add a conf file for each service in /etc/dnsdemux/default
- '''
- objname = self.get_servicemap_uid(servicemap)
- #generate dnsdemux.conf file parameters to be used in static file.
-
- port_listen = self.get_service_port(servicemap)
- domain_name = servicemap.prefix
- #generate service specific .conf file
-
- rr_mapping = self.gen_slice_info(None)
-
- fn = "./temp_config/dnsdemux/"+objname+".conf"
- f = open(fn, "w")
-
- for (k,v) in rr_mapping.items():
- f.write("Forward "+v+" "+port_listen+" 8081 "+domain_name+".\n")
-
-
- def teardown_temp_configfiles(self, objname):
- if os.path.exists("./temp_config/dnsdemux/"+objname+".conf"):
- os.remove("./temp_config/dnsdemux/"+objname+".conf")
- if os.path.exists("./temp_config/dnsredir/"+objname+".d/maps.d/map.conf"):
- os.remove("./temp_config/dnsredir/"+objname+".d/maps.d/map.conf")
- if os.path.exists("./temp_config/dnsredir/"+objname+".d/maps.d"):
- os.rmdir("./temp_config/dnsredir/"+objname+".d/maps.d")
- if os.path.exists("./temp_config/dnsredir/"+objname+".d/node-to-ip.txt"):
- os.remove("./temp_config/dnsredir/"+objname+".d/node-to-ip.txt")
- if os.path.exists("./temp_config/dnsredir/"+objname+".d/codeen_nodes.conf"):
- os.remove("./temp_config/dnsredir/"+objname+".d/codeen_nodes.conf")
- if os.path.exists("./temp_config/dnsredir/"+objname+".d"):
- os.rmdir("./temp_config/dnsredir/"+objname+".d")
- if os.path.exists("./temp_config/dnsredir/"+objname+".conf"):
- os.remove("./temp_config/dnsredir/"+objname+".conf")
-
diff --git a/xos/synchronizers/requestrouter/rrlib_config.py b/xos/synchronizers/requestrouter/rrlib_config.py
deleted file mode 100644
index d0c00c2..0000000
--- a/xos/synchronizers/requestrouter/rrlib_config.py
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env python
-
-DNSREDIR_CONFIGDIR_PREFIX = "/etc/dnsredir/"
-DNSREDIR_LOGDIR_PREFIX = "/var/log/dnsredir/"
-DNSREDIR_PIDFILE_PREFIX = "/var/run/dnsredir."
-REDIR_USER = "princeton_coredirect"
-#REDIR_USER = "arizona_tools1"
-#DEMUX_USER = "arizona_tools1"
-DEMUX_USER = "princeton_codnsdemux"
-HEARTBEAT_PORT = 9000
-#not required as of now, as there will be only one frontend dnsdemux for all the services
-#DNSDEMUX_CONFIGDIR_PREFIX = "/etc/dnsdemux/"
-#DNSDEMUX_LOGDIR_PREFIX = "/var/log/dnsdemux/"
-#DNSDEMUX_PIDFILE_PREFIX = "/var/run/dnsdemux."
-
-TBD = "TBD"
diff --git a/xos/synchronizers/requestrouter/steps/sync_requestrouterservices.py b/xos/synchronizers/requestrouter/steps/sync_requestrouterservices.py
deleted file mode 100644
index 15a9b91..0000000
--- a/xos/synchronizers/requestrouter/steps/sync_requestrouterservices.py
+++ /dev/null
@@ -1,46 +0,0 @@
-import os
-import sys
-import base64
-import traceback
-from django.db.models import F, Q
-from xos.config import Config
-from synchronizers.base.syncstep import SyncStep
-from core.models import Service
-from services.requestrouter.models import RequestRouterService
-from xos.logger import Logger, logging
-
-parentdir = os.path.join(os.path.dirname(__file__),"..")
-sys.path.insert(0,parentdir)
-
-from rrlib import RequestRouterLibrary
-
-logger = Logger(level=logging.INFO)
-
-class SyncRequestRouterService(SyncStep, RequestRouterLibrary):
- provides=[RequestRouterService]
- requested_interval=0
-
- def __init__(self, **args):
- SyncStep.__init__(self, **args)
- RequestRouterLibrary.__init__(self)
-
- def fetch_pending(self):
- try:
- ret = RequestRouterService.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- return ret
- except Exception, e:
- traceback.print_exc()
- return None
-
- def sync_record(self, rr_service):
- try:
- print "syncing service!"
- logger.info("sync'ing rr_service %s" % str(rr_service),extra=rr_service.tologdict())
- self.gen_slice_file(rr_service)
- rr_service.save()
- return True
- except Exception, e:
- traceback.print_exc()
- return False
-
-
diff --git a/xos/synchronizers/requestrouter/steps/sync_servicemap.py b/xos/synchronizers/requestrouter/steps/sync_servicemap.py
deleted file mode 100644
index bef7e42..0000000
--- a/xos/synchronizers/requestrouter/steps/sync_servicemap.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env python
-
-import os
-import sys
-import base64
-import traceback
-from django.db.models import F, Q
-from xos.config import Config, XOS_DIR
-from synchronizers.base.syncstep import SyncStep
-from core.models import Service
-from services.requestrouter.models import ServiceMap
-from xos.logger import Logger, logging
-
-parentdir = os.path.join(os.path.dirname(__file__),"..")
-sys.path.insert(0,parentdir)
-
-from rrlib import RequestRouterLibrary
-from configurationPush import ConfigurationPush
-import rrlib_config
-
-logger = Logger(level=logging.INFO)
-
-class SyncServiceMap(SyncStep, RequestRouterLibrary, ConfigurationPush):
- provides=[ServiceMap]
- requested_interval=0
-
- def __init__(self, **args):
- SyncStep.__init__(self, **args)
- RequestRouterLibrary.__init__(self)
- ConfigurationPush.__init__(self)
-
- def fetch_pending(self):
- try:
- ret = ServiceMap.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- return ret
- except Exception, e:
- traceback.print_exc()
- return None
-
- def sync_record(self, servicemap):
- try:
- print "sync! %s " % self.get_servicemap_uid(servicemap)
- self.gen_dnsredir_serviceconf(servicemap)
- self.gen_dnsdemux_serviceconf(servicemap)
- # push generated files from temp_config
- service_uid = self.get_servicemap_uid(servicemap)
- self.config_push(service_uid, rrlib_config.REDIR_USER, XOS_DIR + "/observers/requestrouter/playbook/site_redir.yml", "/etc/ansible/requestrouter/dnsredir/hosts")
- self.config_push(service_uid, rrlib_config.DEMUX_USER, XOS_DIR + "/observers/requestrouter/playbook/site_demux.yml", "/etc/ansible/requestrouter/dnsdemux/hosts")
- self.teardown_temp_configfiles(service_uid)
- except Exception, e:
- traceback.print_exc()
- return False
-
-if __name__ == "__main__":
- sv = SyncServiceMap()
-
- recs = sv.fetch_pending()
-
- for rec in recs:
- sv.sync_record( rec )
diff --git a/xos/tools/xos-manage b/xos/tools/xos-manage
index e10a47e..c06a12b 100755
--- a/xos/tools/xos-manage
+++ b/xos/tools/xos-manage
@@ -108,7 +108,7 @@
mkdir -p $BACKUP_DIR
FN="$BACKUP_DIR/dumpdata-`date +%Y-%m-%d_%H:%M:%S`.json"
echo "Saving data to $FN"
- python manage.py dumpdata core hpc syndicate_storage requestrouter -a --indent 4 > $FN
+ python manage.py dumpdata core syndicate_storage -a --indent 4 > $FN
if [[ ! -f $FN ]]; then
echo "FAILED to create $FN"
exit
@@ -139,8 +139,6 @@
function makemigrations {
rm -rf /opt/xos/*/migrations /opt/xos/services/*/migrations
python ./manage.py makemigrations core
- python ./manage.py makemigrations hpc
- python ./manage.py makemigrations requestrouter
python ./manage.py makemigrations syndicate_storage
python ./manage.py makemigrations mcord
diff --git a/xos/xos/settings.py b/xos/xos/settings.py
index 6f82f71..f0dfe46 100644
--- a/xos/xos/settings.py
+++ b/xos/xos/settings.py
@@ -182,7 +182,6 @@
'django_extensions',
'core',
'services.mcord',
- 'services.requestrouter',
'services.syndicate_storage',
'geoposition',
# 'rest_framework_swagger',