コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
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
コード例 #7
0
class Environment(records.Record):
    """ Implementation of foreman environments record
    """
    name = records.StringField()

    class Meta:
        """Linking record definition with api implementation.
        """
        api_class = EnvironmentApi
コード例 #8
0
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
コード例 #9
0
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)
コード例 #10
0
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)