def generate_key(self, shared_secret): if app_settings.CONSISTENT_REGISTRATION: keybase = self.hardware_id if app_settings.HARDWARE_ID_ENABLED else self.mac_address hash = md5('{}+{}'.format(keybase, shared_secret).encode('utf-8')) return hash.hexdigest() else: return KeyField.default_callable()
def save(self, *args, **kwargs): if not self.key: try: shared_secret = self.organization.config_settings.shared_secret except ObjectDoesNotExist: # should not happen, but if organization config settings # is not defined the default key will default to being random self.key = KeyField.default_callable() else: self.key = self.generate_key(shared_secret) super().save(*args, **kwargs)
def save(self, *args, **kwargs): if not self.key: try: shared_secret = self.organization.config_settings.shared_secret except ObjectDoesNotExist: # should not happen, but if organization config settings # is not defined the default key will default to being random self.key = KeyField.default_callable() else: self.key = self.generate_key(shared_secret) # update the status of the config object if the device name # changed, but skip if the save operation is not touching the name update_fields = kwargs.get('update_fields') if not update_fields or 'name' in update_fields: self._check_name_changed() super().save(*args, **kwargs) self._check_management_ip_changed()
def save(self, *args, **kwargs): if not self.key: try: shared_secret = self.organization.config_settings.shared_secret except ObjectDoesNotExist: # should not happen, but if organization config settings # is not defined the default key will default to being random self.key = KeyField.default_callable() else: self.key = self.generate_key(shared_secret) state_adding = self._state.adding super().save(*args, **kwargs) if state_adding and self.group and self.group.templates.exists(): self.create_default_config() # The value of "self._state.adding" will always be "False" # after performing the save operation. Hence, the actual value # is stored in the "state_adding" variable. if not state_adding: self._check_changed_fields()