Skip to content

Commit

Permalink
dsl: regenerate Python from YAML.
Browse files Browse the repository at this point in the history
  • Loading branch information
aszs committed Oct 12, 2024
1 parent 5ea6914 commit ad58c26
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 288 deletions.
119 changes: 65 additions & 54 deletions tosca-package/tosca/builtin_types.py
Original file line number Diff line number Diff line change
@@ -1,60 +1,49 @@
# Generated by tosca.yaml2python from unfurl/vendor/tosca/vendor/toscaparser/elements/TOSCA_definition_1_3.yaml at 2024-02-28T08:06:45 overwrite not modified (change to "overwrite ok" to allow)
# Generated by tosca.yaml2python from unfurl/vendor/tosca/vendor/toscaparser/elements/TOSCA_definition_1_3.yaml at 2024-10-11T15:21:52 overwrite not modified (change to "overwrite ok" to allow)
"""
The content of this file reflects TOSCA Simple Profile in YAML version 1.3. It describes the definition for TOSCA types including Node Type, Relationship Type, Capability Type and Interfaces.
"""


from typing import List, Dict, Any, Tuple, Union, Sequence
from typing_extensions import Annotated
import tosca
from tosca import (
Artifact,
ArtifactType,
ArtifactEntity,
Attribute,
AttributeOptions,
CONSTRAINED,
Capability,
CapabilityType,
Computed,
DEFAULT,
DataType,
Eval,
CapabilityEntity,
DataEntity,
Frequency,
GB,
GHz,
GroupType,
InterfaceType,
Group,
Interface,
MB,
MISSING,
Namespace,
NodeType,
PolicyType,
Node,
Policy,
Property,
PropertyOptions,
RelationshipType,
Relationship,
Requirement,
Size,
ToscaInputs,
ToscaOutputs,
equal,
greater_or_equal,
in_range,
min_length,
operation,
tosca_version,
valid_values,
)
import tosca
import typing_extensions


class interfaces(Namespace):
class Root(InterfaceType):
class Root(Interface):
"""
The TOSCA root Interface Type all other TOSCA Interface types derive from
"""

_type_name = "tosca.interfaces.Root"

class NodeLifecycleStandard(InterfaceType):
class NodeLifecycleStandard(Interface):
_type_name = "tosca.interfaces.node.lifecycle.Standard"

def create(self, **kw: Any) -> Any:
Expand All @@ -72,7 +61,7 @@ def stop(self, **kw: Any) -> Any:
def delete(self, **kw: Any) -> Any:
"""Standard lifecycle delete operation."""

class RelationshipConfigure(InterfaceType):
class RelationshipConfigure(Interface):
_type_name = "tosca.interfaces.relationship.Configure"

def pre_configure_source(self, **kw: Any) -> Any:
Expand Down Expand Up @@ -128,7 +117,7 @@ def restart(self, **kw: Any) -> Any:


class datatypes(Namespace):
class Root(DataType):
class Root(DataEntity):
"""
The TOSCA root Data Type all other TOSCA base Data Types derive from
"""
Expand All @@ -155,15 +144,17 @@ class NetworkPortDef(tosca.ValueType, int):

class NetworkPortSpec(Root):
_type_name = "tosca.datatypes.network.PortSpec"
protocol: Annotated[str, (valid_values(["udp", "tcp", "icmp"]),)] = "tcp"
protocol: typing_extensions.Annotated[
str, (valid_values(["udp", "tcp", "icmp"]),)
] = "tcp"
target: Union["datatypes.NetworkPortDef", None] = None
target_range: Union[Annotated[Tuple[int, int], (in_range(1, 65535),)], None] = (
None
)
target_range: Union[
typing_extensions.Annotated[Tuple[int, int], (in_range(1, 65535),)], None
] = None
source: Union["datatypes.NetworkPortDef", None] = None
source_range: Union[Annotated[Tuple[int, int], (in_range(1, 65535),)], None] = (
None
)
source_range: Union[
typing_extensions.Annotated[Tuple[int, int], (in_range(1, 65535),)], None
] = None

class Credential(Root):
_type_name = "tosca.datatypes.Credential"
Expand All @@ -181,7 +172,7 @@ class Xml(tosca.ValueType, str):


class artifacts(Namespace):
class Root(ArtifactType):
class Root(ArtifactEntity):
"""
The TOSCA Artifact Type all other TOSCA Artifact Types derive from
"""
Expand Down Expand Up @@ -249,7 +240,7 @@ class Template(Root):


class capabilities(Namespace):
class Root(CapabilityType):
class Root(CapabilityEntity):
"""
The TOSCA root Capability Type all other TOSCA base Capability Types derive from.
"""
Expand All @@ -269,12 +260,18 @@ class Storage(Root):
class Compute(Container):
_type_name = "tosca.capabilities.Compute"
name: Union[str, None] = None
num_cpus: Union[Annotated[int, (greater_or_equal(1),)], None] = None
num_cpus: Union[
typing_extensions.Annotated[int, (greater_or_equal(1),)], None
] = None
cpu_frequency: Union[
Annotated[Frequency, (greater_or_equal(0.1 * GHz),)], None
typing_extensions.Annotated[Frequency, (greater_or_equal(0.1 * GHz),)], None
] = None
disk_size: Union[
typing_extensions.Annotated[Size, (greater_or_equal(0 * MB),)], None
] = None
mem_size: Union[
typing_extensions.Annotated[Size, (greater_or_equal(0 * MB),)], None
] = None
disk_size: Union[Annotated[Size, (greater_or_equal(0 * MB),)], None] = None
mem_size: Union[Annotated[Size, (greater_or_equal(0 * MB),)], None] = None

class Endpoint(Root):
_type_name = "tosca.capabilities.Endpoint"
Expand All @@ -285,21 +282,29 @@ class Endpoint(Root):
port_name: Union[str, None] = None
network_name: Union[str, None] = "PRIVATE"
initiator: Union[
Annotated[str, (valid_values(["source", "target", "peer"]),)], None
typing_extensions.Annotated[
str, (valid_values(["source", "target", "peer"]),)
],
None,
] = "source"
ports: Union[
Annotated[Dict[str, "datatypes.NetworkPortSpec"], (min_length(1),)], None
typing_extensions.Annotated[
Dict[str, "datatypes.NetworkPortSpec"], (min_length(1),)
],
None,
] = None

ip_address: str = Attribute()

class EndpointAdmin(Endpoint):
_type_name = "tosca.capabilities.Endpoint.Admin"
secure: Union[Annotated[bool, (equal(True),)], None] = True
secure: Union[typing_extensions.Annotated[bool, (equal(True),)], None] = True

class EndpointPublic(Endpoint):
_type_name = "tosca.capabilities.Endpoint.Public"
network_name: Union[Annotated[str, (equal("PUBLIC"),)], None] = "PUBLIC"
network_name: Union[
typing_extensions.Annotated[str, (equal("PUBLIC"),)], None
] = "PUBLIC"
floating: bool = Property(status="experimental", default=False)
"""
Indicates that the public address should be allocated from a pool of floating IPs that are associated with the network.
Expand Down Expand Up @@ -396,7 +401,7 @@ class ContainerDocker(Container):


class relationships(Namespace):
class Root(RelationshipType, interfaces.RelationshipConfigure):
class Root(Relationship, interfaces.RelationshipConfigure):
"""
The TOSCA root Relationship Type all other TOSCA base Relationship Types derive from.
"""
Expand All @@ -419,7 +424,7 @@ class ConnectsTo(Root):

class AttachesTo(Root):
_type_name = "tosca.relationships.AttachesTo"
location: Annotated[str, (min_length(1),)]
location: typing_extensions.Annotated[str, (min_length(1),)]
device: Union[str, None] = None

_valid_target_types = [capabilities.Attachment]
Expand All @@ -438,7 +443,7 @@ class NetworkBindsTo(DependsOn):


class nodes(Namespace):
class Root(NodeType, interfaces.Install, interfaces.NodeLifecycleStandard):
class Root(Node, interfaces.Install, interfaces.NodeLifecycleStandard):
"""
The TOSCA root node all other TOSCA base node types derive from.
"""
Expand All @@ -457,7 +462,7 @@ class Root(NodeType, interfaces.Install, interfaces.NodeLifecycleStandard):
class AbstractStorage(Root):
_type_name = "tosca.nodes.Abstract.Storage"
name: str
size: Annotated[Size, (greater_or_equal(0 * MB),)] = 0 * MB
size: typing_extensions.Annotated[Size, (greater_or_equal(0 * MB),)] = 0 * MB

class StorageBlockStorage(AbstractStorage):
_type_name = "tosca.nodes.Storage.BlockStorage"
Expand All @@ -474,7 +479,7 @@ class BlockStorage(StorageBlockStorage):

class StorageObjectStorage(AbstractStorage):
_type_name = "tosca.nodes.Storage.ObjectStorage"
maxsize: Annotated[Size, (greater_or_equal(0 * GB),)]
maxsize: typing_extensions.Annotated[Size, (greater_or_equal(0 * GB),)]

storage_endpoint: "capabilities.Endpoint" = Capability(
factory=capabilities.Endpoint
Expand Down Expand Up @@ -609,7 +614,9 @@ class NetworkNetwork(Root):
"""

_type_name = "tosca.nodes.network.Network"
ip_version: Union[Annotated[int, (valid_values([4, 6]),)], None] = 4
ip_version: Union[
typing_extensions.Annotated[int, (valid_values([4, 6]),)], None
] = 4
"""
The IP version of the requested network. Valid values are 4 for ipv4 or 6 for ipv6.
"""
Expand Down Expand Up @@ -679,7 +686,7 @@ class NetworkPort(Root):
Allow the user to set a static IP.
"""

order: Union[Annotated[int, (greater_or_equal(0),)], None] = 0
order: Union[typing_extensions.Annotated[int, (greater_or_equal(0),)], None] = 0
"""
The order of the NIC on the compute instance (e.g. eth2).
"""
Expand Down Expand Up @@ -744,12 +751,16 @@ class ObjectStorage(Root):
The logical name of the object store (or container).
"""

size: Union[Annotated[Size, (greater_or_equal(0 * GB),)], None] = None
size: Union[
typing_extensions.Annotated[Size, (greater_or_equal(0 * GB),)], None
] = None
"""
The requested initial storage size.
"""

maxsize: Union[Annotated[Size, (greater_or_equal(0 * GB),)], None] = None
maxsize: Union[
typing_extensions.Annotated[Size, (greater_or_equal(0 * GB),)], None
] = None
"""
The requested maximum storage size.
"""
Expand Down Expand Up @@ -807,14 +818,14 @@ class ContainerApplicationDocker(ContainerApplication):


class groups(Namespace):
class Root(GroupType, interfaces.NodeLifecycleStandard):
class Root(Group, interfaces.NodeLifecycleStandard):
"""The TOSCA Group Type all other TOSCA Group Types derive from"""

_type_name = "tosca.groups.Root"


class policies(Namespace):
class Root(PolicyType):
class Root(Policy):
"""The TOSCA Policy Type all other TOSCA Policy Types derive from."""

_type_name = "tosca.policies.Root"
Expand Down
25 changes: 7 additions & 18 deletions unfurl/configurators/templates/dns.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
# Generated by tosca.yaml2python from unfurl/configurators/templates/dns.yaml at 2024-02-18T10:26:42 overwrite not modified (change to "overwrite ok" to allow)
# Generated by tosca.yaml2python from unfurl/configurators/templates/dns.yaml at 2024-10-11T15:20:31 overwrite not modified (change to "overwrite ok" to allow)

import unfurl
from typing import List, Dict, Any, Tuple, Union, Sequence
from typing_extensions import Annotated
import tosca
from tosca import (
Artifact,
Attribute,
AttributeOptions,
CONSTRAINED,
Capability,
CapabilityType,
Computed,
DEFAULT,
DataType,
Eval,
MISSING,
NodeType,
CapabilityEntity,
DataEntity,
Node,
Property,
PropertyOptions,
RelationshipType,
Relationship,
Requirement,
ToscaInputs,
ToscaOutputs,
operation,
)
import tosca
import unfurl.configurators.dns


class unfurl_datatypes_DNSRecord(DataType):
class unfurl_datatypes_DNSRecord(DataEntity):
_type_name = "unfurl.datatypes.DNSRecord"
_type_metadata = {"additionalProperties": True}
type: str
Expand Down
37 changes: 11 additions & 26 deletions unfurl/configurators/templates/docker.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,17 @@
# Generated by tosca.yaml2python from unfurl/configurators/templates/docker.yaml at 2024-02-18T10:26:42 overwrite not modified (change to "overwrite ok" to allow)
# Generated by tosca.yaml2python from unfurl/configurators/templates/docker.yaml at 2024-10-11T15:21:53 overwrite not modified (change to "overwrite ok" to allow)

import unfurl
from typing import List, Dict, Any, Tuple, Union, Sequence
from typing_extensions import Annotated
from tosca import (
Artifact,
Attribute,
AttributeOptions,
CONSTRAINED,
Capability,
Computed,
DEFAULT,
DataType,
Eval,
MISSING,
NodeType,
Property,
PropertyOptions,
Requirement,
ToscaInputs,
ToscaOutputs,
operation,
valid_values,
OpenDataType
)
import tosca
from tosca import OpenDataEntity, Eval, Property, operation, valid_values
import typing_extensions
import unfurl.configurators.ansible
from unfurl.tosca_plugins.artifacts import *


class unfurl_datatypes_DockerContainer(OpenDataType):
class unfurl_datatypes_DockerContainer(OpenDataEntity):
_type_name = "unfurl.datatypes.DockerContainer"
environment: Union["unfurl.datatypes.EnvironmentVariables", None] = Property(
environment: Union[unfurl.datatypes.EnvironmentVariables, None] = Property(
factory=lambda: (unfurl.datatypes.EnvironmentVariables())
)
container_name: Union[str, None] = None
Expand All @@ -50,12 +30,17 @@ class unfurl_datatypes_DockerContainer(OpenDataType):
entrypoint: Union[List[str], None] = None
privileged: Union[bool, None] = None
pull_policy: Union[
Annotated[str, (valid_values(["always", "never", "missing", "build"]),)], None
typing_extensions.Annotated[
str, (valid_values(["always", "never", "missing", "build"]),)
],
None,
] = None
network_mode: Union[str, None] = None
"""Use the same values as the docker client --network parameter ("bridge", "host", "none")"""

deploy: Union[Dict[str, Any], None] = None


class unfurl_nodes_Container_Application_Docker(tosca.nodes.Root):
_type_name = "unfurl.nodes.Container.Application.Docker"
name: str = Eval({"eval": {"or": [".::container.container_name", ".name"]}})
Expand Down
Loading

0 comments on commit ad58c26

Please sign in to comment.