old_contents: # -*- coding: utf-8 -*-
  # Copyright (c) 2012 The Pycroft Authors. See the AUTHORS file.
  # This file is part of the Pycroft project and licensed under the terms of
  # the Apache License, Version 2.0. See the LICENSE file for details.
  """
      pycroft.model.hosts
      ~~~~~~~~~~~~~~
  
      This module contains the classes Host, NetDevice, Switch.
  
      :copyright: (c) 2011 by AG DSN.
  """
  from base import ModelBase
  from sqlalchemy import ForeignKey
  from sqlalchemy import Column
  #from sqlalchemy.dialects import postgresql
  from sqlalchemy.orm import relationship, backref
  from sqlalchemy.types import Integer
  from sqlalchemy.types import String
  
  from pycroft.model.user import User
  
  
  class Host(ModelBase):
      hostname = Column(String(255), nullable=False)
  
      # many to one from Host to User
      user = relationship(User, backref=backref("hosts"))
      user_id = Column(Integer, ForeignKey("user.id"), nullable=True)
  
  
  class NetDevice(ModelBase):
      #ipv4 = Column(postgresql.INET, nullable=True)
      ipv4 = Column(String(12), unique=True, nullable=True)
      #ipv6 = Column(postgresql.INET, nullable=True)
      ipv6 = Column(String(51), unique=True, nullable=True)
      #mac = Column(postgresql.MACADDR, nullable=False)
      mac = Column(String(12), nullable=False)
  
      # one to one from PatchPort to NetDevice
      patch_port_id = Column(Integer, ForeignKey('patchport.id'), nullable=True)
      patch_port = relationship("PatchPort", backref=backref("net_device",
                                                            uselist=False))
  
  
  class Switch(Host):
      # Concrete Table Inheritance
      __mapper_args__ = {"concrete": True}
  
      name = Column(String(127), nullable=False)
  
new_contents: # -*- coding: utf-8 -*-
  # Copyright (c) 2012 The Pycroft Authors. See the AUTHORS file.
  # This file is part of the Pycroft project and licensed under the terms of
  # the Apache License, Version 2.0. See the LICENSE file for details.
  """
      pycroft.model.hosts
      ~~~~~~~~~~~~~~
  
      This module contains the classes Host, NetDevice, Switch.
  
      :copyright: (c) 2011 by AG DSN.
  """
  from base import ModelBase
  from sqlalchemy import ForeignKey
  from sqlalchemy import Column
  #from sqlalchemy.dialects import postgresql
  from sqlalchemy.orm import relationship, backref
  from sqlalchemy.types import Integer
  from sqlalchemy.types import String
  
  from pycroft.model.user import User
  from pycroft.model.dormitory import Room
  
  
  class Host(ModelBase):
      hostname = Column(String(255), nullable=False)
  
      # many to one from Host to User
      user = relationship(User, backref=backref("hosts"))
      user_id = Column(Integer, ForeignKey("user.id"), nullable=True)
  
      # many to one from Host to Room
      room = relationship(Room, backref=backref("hosts"))
      room_id = Column(Integer, ForeignKey("room.id"), nullable=True)
  
  
  class NetDevice(ModelBase):
      #ipv4 = Column(postgresql.INET, nullable=True)
      ipv4 = Column(String(12), unique=True, nullable=True)
      #ipv6 = Column(postgresql.INET, nullable=True)
      ipv6 = Column(String(51), unique=True, nullable=True)
      #mac = Column(postgresql.MACADDR, nullable=False)
      mac = Column(String(12), nullable=False)
  
      # one to one from PatchPort to NetDevice
      patch_port_id = Column(Integer, ForeignKey('patchport.id'), nullable=True)
      patch_port = relationship("PatchPort", backref=backref("net_device",
                                                            uselist=False))
  
  
  class Switch(Host):
      # Concrete Table Inheritance
      __mapper_args__ = {"concrete": True}
  
      name = Column(String(127), nullable=False)
  
subject: ADD relationship Host Room