class Host(records.Record): """ Implementation of foreman hosts record Utilizes _post_init to ensure, that name matches domain, operating system matches architecture and partition table """ name = records.StringField(format=r"host\d\d\d\d\d") root_pass = records.StringField(default="changeme") mac = records.MACField() environment = records.RelatedField(Environment) architecture = records.RelatedField(Architecture) domain = records.RelatedField(Domain) puppet_proxy = records.RelatedField(SmartProxy) operatingsystem = records.RelatedField(OperatingSystem) ptable = records.RelatedField(PartitionTable) def _post_init(self): """Ensures, that certain fields are consistent with api requirements """ self.name = self.name + "." + self.domain.name self.architecture.operatingsystem = [self.operatingsystem] self.ptable.operatingsystem = [self.operatingsystem] self.operatingsystem.ptables = [self.ptable] class Meta: """Linking record definition with api implementation. """ api_class = HostApi
class SmartProxy(records.Record): """ Implementation of foreman SmartProxy record We asume, that main server has smart proxy configured. """ name = records.StringField() url = records.StringField(default="https://" + conf.properties['main.server.hostname']) class Meta: """Linking record definition with api implementation. """ api_class = SmartProxyApi
class EnvironmentKatello(records.Record): """ Implementation of foreman environments record """ name = records.StringField() label = records.StringField() prior = records.IntegerField(min=1, max=1) organization = records.RelatedField(Organization) class Meta: """Linking record definition with api implementation. """ api_class = EnvironmentKatelloApi
class PartitionTable(records.Record): """ Implementation of foreman partition table record """ name = records.StringField() layout = records.StringField(default="d-i partman-auto/disk") operatingsystem = records.ManyRelatedField(OperatingSystem, 1, 3) os_family = records.ChoiceField(OPERATING_SYSTEMS) class Meta: """Linking record definition with api implementation. """ api_class = PTableApi
class OperatingSystem(records.Record): """ Implementation of foreman OS record """ name = records.StringField() major = records.IntegerField() minor = records.IntegerField() family = records.ChoiceField(OPERATING_SYSTEMS) release_name = records.StringField(r"osrelease\d\d\d") class Meta: """Linking record definition with api implementation. """ api_class = OperatingSystemApi
class CustomRepository(records.Record): """Definition of activation key entity """ name = records.BasicPositiveField() description = records.BasicPositiveField() product = records.RelatedField(CustomProduct) url = records.StringField( default="http://inecas.fedorapeople.org/fakerepos/zoo/") enabled = records.Field(default=True) content_type = records.StringField(default="yum") class Meta: """Linking record definition with api implementation. """ api_class = CustomRepositoryApi
class Environment(records.Record): """ Implementation of foreman environments record """ name = records.StringField() class Meta: """Linking record definition with api implementation. """ api_class = EnvironmentApi
class Role(records.Record): """Definition of activation key entity """ name = records.StringField(required=True) class Meta: """Linking record definition with api implementation. """ api_class = RolesApi
class Domain(records.Record): """ Implementation of foreman domains record """ name = records.StringField(format=r"domain\d\d\d\d") class Meta: """Linking record definition with api implementation. """ api_class = DomainApi change_for_update = lambda i: i.record_set_field(name="%s.uk" % i.name)
class Architecture(records.Record): """Definition of architecture entity""" name = records.StringField(required=True) operatingsystem = records.ManyRelatedField(OperatingSystem, 1, 3) class Meta: """Linking record definition with api implementation. """ api_class = ArchitectureApi change_for_update = lambda i: i.record_set_field(name="%s_updated" % i. name)