Add simple web server for service disruption page
diff --git a/xos/synchronizers/vcpe/files/etc/service/message/run b/xos/synchronizers/vcpe/files/etc/service/message/run
new file mode 100644
index 0000000..59c2759
--- /dev/null
+++ b/xos/synchronizers/vcpe/files/etc/service/message/run
@@ -0,0 +1,16 @@
+#!/usr/bin/python
+
+import BaseHTTPServer
+class HTTPHandlerOne(BaseHTTPServer.BaseHTTPRequestHandler):
+ def do_GET(self):
+ with open('./message.html', 'r') as msgfile:
+ message = msgfile.read()
+ self.wfile.write(message)
+
+def run(server_class=BaseHTTPServer.HTTPServer,
+ handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
+ server_address = ('192.168.0.1', 8000)
+ httpd = server_class(server_address, handler_class)
+ httpd.serve_forever()
+
+run(handler_class=HTTPHandlerOne)
diff --git a/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml b/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
index eed6b42..ae32dcd 100644
--- a/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
+++ b/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
@@ -239,6 +239,20 @@
notify:
- reset bwlimits
+ - name: copy simple webserver
+ copy: src=/opt/xos/synchronizers/vcpe/files/etc/service/ dest=/var/container_volumes/{{ container_name }}/etc/service/ owner=root group=root
+ when: status != "enabled"
+
+ - name: generate the message page
+ template: src=/opt/xos/synchronizers/vcpe/templates/message.html.j2 dest=/var/container_volumes/{{ container_name }}/etc/service/message/message.html owner=root group=root mode=0644
+ when: status != "enabled"
+ notify: restart vcpe
+
+ - name: remove simple webserver
+ file: path=/var/container_volumes/{{ container_name }}/etc/service/message state=absent
+ when: status == "enabled"
+ notify: restart vcpe
+
- name: Make sure vCPE service is running
service: name={{ container_name }} state=started
diff --git a/xos/synchronizers/vcpe/templates/before.rules.j2 b/xos/synchronizers/vcpe/templates/before.rules.j2
index e6f7d4a..b60aaef 100644
--- a/xos/synchronizers/vcpe/templates/before.rules.j2
+++ b/xos/synchronizers/vcpe/templates/before.rules.j2
@@ -26,6 +26,10 @@
{% endfor %}
{% endif %}
+{% if status != "enabled" %}
+-A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8000
+{% endif %}
+
# don't delete the 'COMMIT' line or these nat table rules won't be processed
COMMIT
diff --git a/xos/synchronizers/vcpe/templates/message.html.j2 b/xos/synchronizers/vcpe/templates/message.html.j2
new file mode 100644
index 0000000..a04e822
--- /dev/null
+++ b/xos/synchronizers/vcpe/templates/message.html.j2
@@ -0,0 +1,8 @@
+{% if status == "delinquent" %}
+Your account is delinquent. Please visit the customer portal to pay your bill.
+{% elif status == "copyrightviolation" %}
+Someone in your home has been illegally downloading copyrighted material.
+Please visit the customer portal and perform the Copyright Training course.
+{% else %}
+Your service has been suspended. Please visit the customer portal to resume.
+{% endif %}