pyfarm.models.core.types module¶
Custom Columns and Type Generators¶
Special column types used by PyFarm’s models.
-
class
pyfarm.models.core.types.
AgentStateEnum
(*args, **kwargs)[source]¶ Bases:
pyfarm.models.core.types.EnumType
custom column type for working with
AgentState
-
enum
= AgentState(OFFLINE=Values(201, 'offline'), RUNNING=Values(203, 'running'), DISABLED=Values(200, 'disabled'), ONLINE=Values(202, 'online'))¶
-
-
class
pyfarm.models.core.types.
EnumType
(*args, **kwargs)[source]¶ Bases:
sqlalchemy.sql.type_api.TypeDecorator
Special column type which handles translation from a human readable enum into an integer that the database can use.
Variables: enum – required class level variable which defines what enum this custom column handles Raises AssertionError: raised if enum
is not set on the class-
enum
= NotImplemented¶
-
impl
¶ alias of
Integer
-
json_types
= (<class 'str'>, <class 'int'>)¶
-
process_bind_param
(value, dialect)[source]¶ Takes
value
and maps it to the internal integer.Raises ValueError: raised if value
is not part of the class levelenum
mapping
-
-
class
pyfarm.models.core.types.
IPAddress
(addr, version=None, flags=0)[source]¶ Bases:
netaddr.ip.IPAddress
Custom version of
netaddr.IPAddress
which can match itself against other instance of the same class, a string, or an integer.
-
class
pyfarm.models.core.types.
IPv4Address
(*args, **kwargs)[source]¶ Bases:
sqlalchemy.sql.type_api.TypeDecorator
Column type which can store and retrieve IPv4 addresses in a more efficient manner
-
MAX_INT
= 4294967295¶
-
impl
¶ alias of
BigInteger
-
json_types
= (<class 'str'>, <class 'int'>)¶
-
-
class
pyfarm.models.core.types.
JSONDict
(*args, **kwargs)[source]¶ Bases:
pyfarm.models.core.types.JSONSerializable
Column type for storing dictionary objects as json
-
serialize_types
= (<class 'dict'>, <class 'collections.UserDict'>)¶
-
-
class
pyfarm.models.core.types.
JSONList
(*args, **kwargs)[source]¶ Bases:
pyfarm.models.core.types.JSONSerializable
Column type for storing list objects as json
-
serialize_types
= (<class 'list'>, <class 'tuple'>, <class 'collections.UserList'>)¶
-
-
class
pyfarm.models.core.types.
JSONSerializable
(*args, **kwargs)[source]¶ Bases:
sqlalchemy.sql.type_api.TypeDecorator
Base of all custom types which process json data to and from the database.
Variables: - serialize_types (tuple) – the kinds of objects we expect to serialize to and from the database
- serialize_none (bool) – if True then return None instead of converting it to its json value
- allow_blank (bool) – if True, do not raise a
ValueError
for empty data - allow_empty (bool) – if True, do not raise
ValueError
if the input data itself is empty
-
dumps
(value)[source]¶ Performs the process of dumping value to json. For classes such as
UserDict
orUserList
this will dump the underlying data instead of the object itself.
-
impl
¶ alias of
UnicodeText
-
serialize_none
= False¶
-
serialize_types
= None¶
-
class
pyfarm.models.core.types.
MACAddress
(*args, **kwargs)[source]¶ Bases:
sqlalchemy.sql.type_api.TypeDecorator
Column type which can store and retrieve MAC addresses in a more efficient manner
-
MAX_INT
= 281474976710655¶
-
impl
¶ alias of
BigInteger
-
json_types
= (<class 'str'>, <class 'int'>)¶
-
-
class
pyfarm.models.core.types.
OperatingSystemEnum
(*args, **kwargs)[source]¶ Bases:
pyfarm.models.core.types.EnumType
custom column type for working with
AgentState
-
enum
= OperatingSystem(BSD=Values(304, 'bsd'), WINDOWS=Values(301, 'windows'), OTHER=Values(303, 'other'), MAC=Values(302, 'mac'), LINUX=Values(300, 'linux'))¶
-
-
class
pyfarm.models.core.types.
UUIDType
(*args, **kwargs)[source]¶ Bases:
sqlalchemy.sql.type_api.TypeDecorator
Custom column type which handles UUIDs in the appropriate manner for various databases.
-
impl
¶ alias of
TypeEngine
-
json_types
¶ alias of
UUID
-
-
class
pyfarm.models.core.types.
UseAgentAddressEnum
(*args, **kwargs)[source]¶ Bases:
pyfarm.models.core.types.EnumType
custom column type for working with
UseAgentAddress
-
enum
= UseAgentAddress(LOCAL=Values(310, 'local'), REMOTE=Values(311, 'remote'), PASSIVE=Values(313, 'passive'), HOSTNAME=Values(312, 'hostname'))¶
-
-
class
pyfarm.models.core.types.
WorkStateEnum
(*args, **kwargs)[source]¶ Bases:
pyfarm.models.core.types.EnumType
custom column type for working with
WorkState
-
enum
= WorkState(RUNNING=Values(105, 'running'), PAUSED=Values(100, 'paused'), FAILED=Values(107, 'failed'), DONE=Values(106, 'done'))¶
-