Changeset 6421 for branches/exodus-roland
- Timestamp:
- Dec 10, 2008, 7:48:07 AM (16 years ago)
- Location:
- branches/exodus-roland/exodus
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/exodus-roland/exodus/forms.py
r6420 r6421 5 5 6 6 class NodeForm(forms.ModelForm): 7 #masterip = forms.IPAddressField(widget=forms.HiddenInput) 7 8 class Meta: 8 9 model = Node 10 11 def clean_masterip(self): 12 import pdb; pdb.set_trace() ; 13 masterip = self.cleaned_data.get('masterip') 14 if self.instance.pk is None: 15 masterip = free_masterip() 16 if masterip: 17 pass 18 19 20 masterip = self.cleaned_data.get('masterip') 21 def save(self, commit=True): 22 import pdb; pdb.set_trace() ; 23 -
branches/exodus-roland/exodus/models.py
r6420 r6421 79 79 status = models.CharField(max_length=10, choices=STATUS_CHOICES , \ 80 80 default='up') 81 network = models.ForeignKey(Network,default=1) 81 82 masterip = models.IPAddressField(unique=True) 82 network = models.ForeignKey(Network,default=1)83 83 84 84 class Meta: … … 89 89 return self.name 90 90 91 def save(self, force_insert=False, force_update=False): 92 #XXX: Maybe move this to a model form, 93 from wllogic import free_masterip 94 # check if there is a masterip, if not generate one. 95 # check if there is a network change, if so, generate a new masterip. 96 if self.masterip: 97 old = Node.objects.get(pk=self.pk) 98 if old.network != self.network: 99 self.masterip = free_masterip(self.network) 100 else: 101 self.masterip = free_masterip(self.network) 102 super(Node, self).save(force_insert, force_update) 91 # def save(self, force_insert=False, force_update=False): 92 # #XXX: could there be racing conditions? 93 # #XXX: Maybe move this to a model form, 94 # from wllogic import free_masterip 95 # # check if there is a masterip, if not generate one. 96 # # check if there is a network change, if so, generate a new masterip. 97 # if self.masterip: 98 # old = Node.objects.get(pk=self.pk) 99 # if old.network != self.network: 100 # self.masterip = free_masterip(self.network) 101 # else: 102 # self.masterip = free_masterip(self.network) 103 # super(Node, self).save(force_insert, force_update) 103 104 104 105 class Interface(models.Model):
Note:
See TracChangeset
for help on using the changeset viewer.