def mksource(self, htdocs): ''' write source html template (placeholders) ''' try: path = '%s%s' % (htdocs, 'index.html') soy.commit(self.pillar['index'], path, **self.__dict__) self.salt['nginx.signal']('reload') return True except (OSError, IOError): raise OSError
def mkconf(self): ''' write and symlink nginx host files from template. ''' try: available = '%s%s.conf' % (self.pillar['available'], self.host) enabled = '%s%s.conf' % (self.pillar['enabled'], self.host) soy.commit(self.pillar['template'], available, **self.__dict__) self.salt['file.symlink'](available, enabled) return True except (OSError, IOError): return False
def suspend(self): ''' suspend users and their hosts ''' try: path = '%s%s.conf' % (self.pillar['available'], self.host) link = '%s%s.conf' % (self.pillar['enabled'], self.host) self.salt['file.remove'](link) self.salt['file.remove'](path) soy.commit(self.pillar['susconf'], path, **self.__dict__) self.salt['file.symlink'](path, link) self.salt['nginx.signal']('reload') return True except (OSError, IOError): return False
def test_pass(self): rv = soy.commit('/tmp/test', '/tmp/test', **{}) ok_(rv == True, 'returned %s' % rv)
def test_fail(self): rv = soy.commit('/tmp/', '/tmp/', **{}) ok_(rv is False, 'returned %s' % rv)