Sapan Bhatia | 2ac8864 | 2016-01-15 10:43:19 -0500 | [diff] [blame] | 1 | import os |
| 2 | import sys |
| 3 | import base64 |
| 4 | from django.db.models import F, Q |
| 5 | from xos.config import Config |
| 6 | from synchronizers.base.syncstep import SyncStep |
| 7 | from services.helloworld.models import Hello,World |
Scott Baker | 3a01eb2 | 2016-01-15 07:57:33 -0800 | [diff] [blame] | 8 | from xos.logger import Logger, logging |
Sapan Bhatia | 2ac8864 | 2016-01-15 10:43:19 -0500 | [diff] [blame] | 9 | |
| 10 | parentdir = os.path.join(os.path.dirname(__file__),"..") |
| 11 | sys.path.insert(0,parentdir) |
| 12 | |
| 13 | logger = Logger(level=logging.INFO) |
| 14 | |
| 15 | class SyncHello(SyncStep): |
| 16 | provides=[Hello] |
| 17 | observes=Hello |
| 18 | requested_interval=0 |
| 19 | |
| 20 | def sync_record(self, record): |
| 21 | instance = record.instance_backref |
| 22 | instance.userData="packages:\n - apache2\nruncmd:\n - update-rc.d apache2 enable\n - service apache2 start\nwrite_files:\n- content: Hello %s\n path: /var/www/html/hello.txt"%record.name |
| 23 | instance.save() |
| 24 | |
| 25 | def delete_record(self, m): |
| 26 | return |