Ejemplo n.º 1
0
    def by_ip_address(cls, ip_addr):
        """
        Returns a box object based on an ip address, supports both ipv4
        and ipv6
        """
        ip = IpAddress.by_address(ip_addr)

        return ip.box if ip is not None else None
Ejemplo n.º 2
0
    def by_ip_address(cls, ip_addr):
        '''
        Returns a box object based on an ip address, supports both ipv4
        and ipv6
        '''
        ip = IpAddress.by_address(ip_addr)

        return ip.box if ip is not None else None
Ejemplo n.º 3
0
 def edit_ip(self):
     """ Add ip addresses to a box (sorta edits the box object) """
     try:
         box = Box.by_uuid(self.get_argument("box_uuid", ""))
         if box is None:
             raise ValidationError("Box does not exist")
         ip_addr = self.get_argument("ip_address", "")
         if IpAddress.by_address(ip_addr) is None:
             ip = IpAddress(box_id=box.id, address=ip_addr)
             if self.get_argument("visable", "").lower() != "true":
                 ip.visable = False
             box.ip_addresses.append(ip)
             self.dbsession.add(ip)
             self.dbsession.add(box)
             self.dbsession.commit()
             self.redirect("/admin/view/game_objects#%s" % box.uuid)
         else:
             raise ValidationError("IP address is already in use")
     except ValidationError as error:
         self.render("admin/view/game_objects.html", errors=[str(error)])
Ejemplo n.º 4
0
 def edit_ip(self):
     ''' Add ip addresses to a box (sorta edits the box object) '''
     errors = []
     box = Box.by_uuid(self.get_argument('box_uuid', ''))
     if box is not None:
         addr = self.get_argument('ip_address', '')
         if IpAddress.by_address(addr) is None:
             try:
                 ip = IpAddress(box_id=box.id, address=addr)
                 box.ip_addresses.append(ip)
                 self.dbsession.add(ip)
                 self.dbsession.add(box)
                 self.dbsession.commit()
             except Exception as error:
                 errors.append(str(error))
         else:
             errors.append("IP address is already in use")
     else:
         errors.append("Box does not exist")
     self.render("admin/view/game_objects.html", errors=errors)
Ejemplo n.º 5
0
 def edit_ip(self):
     ''' Add ip addresses to a box (sorta edits the box object) '''
     try:
         box = Box.by_uuid(self.get_argument('box_uuid', ''))
         if box is None:
             raise ValidationError("Box does not exist")
         ip_addr = self.get_argument('ip_address', '')
         if IpAddress.by_address(ip_addr) is None:
             ip = IpAddress(box_id=box.id, address=ip_addr)
             if self.get_argument('visable', '').lower() != 'true':
                 ip.visable = False
             box.ip_addresses.append(ip)
             self.dbsession.add(ip)
             self.dbsession.add(box)
             self.dbsession.commit()
             self.redirect("/admin/view/game_objects#%s" % box.uuid)
         else:
             raise ValidationError("IP address is already in use")
     except ValidationError as error:
         self.render("admin/view/game_objects.html", errors=[str(error), ])
Ejemplo n.º 6
0
 def edit_ip(self):
     ''' Add ip addresses to a box (sorta edits the box object) '''
     try:
         box = Box.by_uuid(self.get_argument('box_uuid', ''))
         if box is None:
             raise ValidationError("Box does not exist")
         ip_addr = self.get_argument('ip_address', '')
         if IpAddress.by_address(ip_addr) is None:
             ip = IpAddress(box_id=box.id, address=ip_addr)
             if self.get_argument('visable', '').lower() != 'true':
                 ip.visable = False
             box.ip_addresses.append(ip)
             self.dbsession.add(ip)
             self.dbsession.add(box)
             self.dbsession.commit()
             self.redirect('/admin/view/game_objects')
         else:
             raise ValidationError("IP address is already in use")
     except ValidationError as error:
         self.render("admin/view/game_objects.html", errors=[
             str(error),
         ])