Пример #1
0
def upgrade_to_version_1_1():
    """ Hosts created with older addhost, might have some registered template services """
    print("Upgrading to config version 1.1 ...", end=' ')
    all_hosts = okconfig.get_hosts()
    my_services = Model.Service.objects.filter(register="1",name__contains='')
    for service in my_services:
        if service.name in all_hosts and not service['service_description']:
            service['register'] = 0
            print("Default service for %s updated" % service.name)
            service.save()
    print("ok")
Пример #2
0
def upgrade_to_version_1_1():
    """ Hosts created with older addhost, might have some registered template services """
    print "Upgrading to config version 1.1 ...",
    all_hosts = okconfig.get_hosts()
    my_services = Model.Service.objects.filter(register="1",name__contains='')
    for service in my_services:
        if service.name in all_hosts and not service['service_description']:
            service['register'] = 0
            print "Default service for %s updated" % service.name
            service.save()
    print "ok"
Пример #3
0
 def clean(self):
     cleaned_data = super(AddTemplateForm,self).clean()
     force = self.cleaned_data.get('force')
     host_name = self.cleaned_data.get('host_name')
     templates = self.cleaned_data.get('templates')
     for i in templates:
         if i not in okconfig.get_templates().keys():
             self._errors['templates'] = self.error_class( ['template %s was not found'%i] )
     if not force and host_name not in okconfig.get_hosts():
         self._errors['host_name'] = self.error_class(['Host name not found Use force to write template anyway'])
     return cleaned_data
Пример #4
0
 def clean(self):
     cleaned_data = super(AddTemplateForm,self).clean()
     force = self.cleaned_data.get('force')
     host_name = self.cleaned_data.get('host_name')
     templates = self.cleaned_data.get('templates')
     for i in templates:
         if i not in okconfig.get_templates().keys():
             self._errors['templates'] = self.error_class( ['template %s was not found'%i] )
     if not force and host_name not in okconfig.get_hosts():
         self._errors['host_name'] = self.error_class(['Host name not found Use force to write template anyway'])
     return cleaned_data
Пример #5
0
 def clean(self):
     cleaned_data = super(AddHostForm, self).clean()
     force = self.cleaned_data.get("force")
     host_name = self.cleaned_data.get("host_name")
     templates = self.cleaned_data.get("templates")
     for i in templates:
         if i not in okconfig.get_templates().keys():
             self._errors["templates"] = self.error_class(["template %s was not found" % i])
     if not force and host_name in okconfig.get_hosts():
         self._errors["host_name"] = self.error_class(["Host name already exists. Use force to overwrite"])
     return cleaned_data
Пример #6
0
 def clean(self):
     cleaned_data = super(AddHostForm, self).clean()
     force = self.cleaned_data.get('force')
     host_name = self.cleaned_data.get('host_name')
     templates = self.cleaned_data.get('templates')
     for i in templates:
         if i not in okconfig.get_templates().keys():
             self._errors['templates'] = self.error_class(
                 [_('template %s was not found') % i])
     if not force and host_name in okconfig.get_hosts():
         self._errors['host_name'] = self.error_class(
             [_('Host name already exists. Use force to overwrite')])
     return cleaned_data
Пример #7
0
 def clean(self):
     cleaned_data = super(AddHostForm, self).clean()
     force = self.cleaned_data.get('force')
     host_name = self.cleaned_data.get('host_name')
     templates = self.cleaned_data.get('templates')
     for i in templates:
         if i not in okconfig.get_templates().keys():
             self._errors['templates'] = self.error_class(
                 [_('template %s was not found') % i])
     if not force and host_name in okconfig.get_hosts():
         self._errors['host_name'] = self.error_class(
             [_('Host name already exists. Use force to overwrite')])
     return cleaned_data