-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add more python dsl versions of example yaml.
- Loading branch information
Showing
6 changed files
with
125 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import tosca | ||
from tosca import GB, MB | ||
|
||
compute = tosca.nodes.Compute( | ||
host=tosca.capabilities.Compute( | ||
num_cpus=1, | ||
disk_size=200 * GB, | ||
mem_size=512 * MB, | ||
), | ||
) | ||
|
||
mydb = PostgresDB(name="mydb") | ||
|
||
myApp = MyApplication( | ||
ports=tosca.datatypes.NetworkPortSpec("80:8080"), | ||
host=[compute], | ||
db=mydb, | ||
) | ||
myApp.image = tosca.artifacts.DeploymentImageContainerDocker( | ||
"image", | ||
file="myapp:latest", | ||
repository="docker_hub", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
topology_template: | ||
node_templates: | ||
myApp: | ||
type: MyApplication | ||
properties: | ||
ports: | ||
eval: | ||
portspec: "80:8080" | ||
artifacts: | ||
image: | ||
type: tosca.artifacts.Deployment.Image.Container.Docker | ||
file: myapp:latest | ||
repository: docker_hub | ||
requirements: | ||
- host: compute | ||
- db: | ||
node: mydb | ||
|
||
mydb: | ||
type: PostgresDB | ||
properties: | ||
name: mydb | ||
|
||
compute: | ||
type: tosca.nodes.Compute | ||
capabilities: | ||
host: | ||
properties: | ||
num_cpus: 1 | ||
disk_size: 200GB | ||
mem_size: 512MB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import unfurl | ||
from typing import Any, Sequence | ||
import tosca | ||
from tosca import Attribute | ||
import unfurl.configurators.shell | ||
from unfurl.tosca_plugins.expr import get_input | ||
|
||
class MyApplication(tosca.nodes.SoftwareComponent): | ||
domain: str = get_input("domain") | ||
ports: "tosca.datatypes.NetworkPortSpec" | ||
|
||
private_address: str = Attribute() | ||
|
||
host: Sequence[ | ||
"tosca.relationships.HostedOn | tosca.nodes.Compute | tosca.capabilities.Compute" | ||
] = () | ||
db: "tosca.relationships.ConnectsTo | capabilities_postgresdb" | ||
|
||
def create(self, **kw): | ||
return unfurl.configurators.shell.ShellConfigurator( | ||
command=["create.sh"], | ||
) | ||
|
||
def configure(self, **kw): | ||
return unfurl.configurators.shell.ShellConfigurator( | ||
command=["configure.sh"], | ||
) | ||
|
||
def delete(self, **kw): | ||
return unfurl.configurators.shell.ShellConfigurator( | ||
command=["delete.sh"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
tosca_definitions_version: tosca_simple_unfurl_1_0_0 | ||
node_types: | ||
MyApplication: | ||
derived_from: tosca.nodes.SoftwareComponent | ||
attributes: | ||
private_address: | ||
type: string | ||
properties: | ||
domain: | ||
type: string | ||
default: { get_input: domain } | ||
ports: | ||
type: tosca.datatypes.network.PortSpec | ||
requirements: | ||
- host: | ||
capability: tosca.capabilities.Compute | ||
relationship: tosca.relationships.HostedOn | ||
- db: | ||
capability: capabilities.postgresdb | ||
relationship: tosca.relationships.ConnectsTo | ||
interfaces: | ||
# TOSCA defines Standard interface for lifecycle management but you can define your own too | ||
Standard: | ||
create: create.sh | ||
configure: configure.sh | ||
delete: delete.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters