Hi guys,
I'm developing an ISP control panel for my organization. I just finished the web interface based on django admin and now it's time to introduce calls to the "system scripts" in order to make the changes effective on the ISP servers (add users, manage virtualhosts, domains, and all this stuff). To achieve that I was thinking in overriding the save and delete methods from my models ( virtualhost model, domain model..). For example. before saving a new "apache virtualhost" I want to run a proper "create vhost" script through ssh using Paramiko library and if it is successful save the new virtualhost into the database, otherwise send a message to enduser telling that an error has occurred.
class Virtualhost(models.Model):
....
def save(self, *args, **kwargs):
if not self.id:
ssh = Ssh('create_new_virtualhost', self)
if ssh.errors:
message.add(self.user, 'something wrong was happend')
else:
super(self, Virtualhost).save(*args, **kwargs)
I'm wondering if this approach is the right way for the interaction between django and ISP servers.
Moreover, I read that is highly recommended to use a message queue like celery in order to avoid a possible 'long wait' until ssh command ends [1]. Would you execute the save function through celery? Is it safe? or maybe if save() is executed asynchronously it can cause some unexpected behavior?
I need some "expert" opinion here :) Would you affront this situation in a similar way or would you take a completely different approach?
Many thanks!!
--
Marc
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment