Skip to content

Instantly share code, notes, and snippets.

@sergmelikyan
Last active August 29, 2015 13:56
Show Gist options
  • Save sergmelikyan/9318745 to your computer and use it in GitHub Desktop.
Save sergmelikyan/9318745 to your computer and use it in GitHub Desktop.
# *****************************************************************************
# This example intended to demonstrate how Applications are defined
# in MuranoPL language.
#
# Note: to keep this document as valid YAML syntetic first-level entities
# are added. All MuranoPL classes (e.g. value of MyTelnetServer entry in this
# document) should be placed in separate YAML file.
MyTelnetServer:
Namespaces:
=: com.mirantis.murano.services.windows.telnetServer
std: com.mirantis.murano
sys: com.mirantis.murano.system
win: com.mirantis.murano.services.windows
Name: TelnetServer
Extends: std:Application
Properties:
name:
Contract: $.string().notNull()
port:
Contract: $.int().notNull()
host:
Contract: $.class(win:Host).notNull()
Workflow:
deploy:
Body:
- $.host.deploy()
- $resources: new(sys:Resources)
- $template: $resources.json('InstallTelnet.template').bind(dict(
port => $.port
))
- $.host.agent.call($template, $resources)
# *****************************************************************************
# Classes shown below already present in MuranoPL and should not be included
# in user-supplied application package. Please use classes below only as rough
# example of how Base Class Library in Murano looks like.
#
# Note: to keep this document as valid YAML syntetic first-level entities
# are added. All MuranoPL classes (e.g. value of MyTelnetServer entry in this
# document) should be placed in separate YAML file.
#
# DO NOT USE THIS AS A REFERENCE!
# *****************************************************************************
Object:
Namespaces:
=: com.mirantis.murano
Name: Object
Environment:
Workflow:
initialize:
Namespaces:
=: com.mirantis.murano
sys: com.mirantis.murano.system
Name: Environment
Properties:
name:
Contract: $.string().notNull()
applications:
Contract: [$.class(Application).owned().notNull()]
agentListener:
Contract: $.class(sys:AgentListener)
Type: Runtime
stack:
Contract: $.class(sys:HeatStack)
Type: Runtime
Workflow:
initialize:
Body:
- $this.agentListener: new(sys:AgentListener, name => $.name)
- $this.stack: new(sys:HeatStack, name => $.name)
deploy:
Body:
- $.agentListener.start()
- $.applications.pselect($.deploy())
- $.agentListener.stop()
Application:
Namespaces:
=: com.mirantis.murano
Name: Application
Host:
Namespaces:
=: com.mirantis.murano.services.windows
ad: com.mirantis.murano.services.windows.activeDirectory
srv: com.mirantis.murano.services
sys: com.mirantis.murano.system
Name: Host
Extends: srv:Instance
Properties:
adminPassword:
Contract: $.string().notNull()
Workflow:
initialize:
Body:
- $.super($.initialize())
- $.resources: new(sys:Resources)
deploy:
Body:
- $.super($.deploy())
- $template: $.resources.json('SetPassword.template').bind(dict(
adminPassword => $.adminPassword
))
- $.agent.send($template, $.resources)
Instance:
Namespaces:
=: com.mirantis.murano.services
std: com.mirantis.murano
sys: com.mirantis.murano.system
Name: Instance
Properties:
name:
Contract: $.string().notNull()
agent:
Contract: $.class(sys:Agent)
Type: Runtime
Workflow:
initialize:
Body:
- $.environment: $.find(std:Environment).require()
- $.agent: new(sys:Agent, host => $)
- $.resources: new(sys:Resources)
deploy:
Body:
- $template:
Resources:
$.name:
Type: 'AWS::EC2::Instance'
Properties:
InstanceType: 'm1.tiny'
ImageId: 'ws-2012-std'
- $.environment.stack.updateTemplate($template)
- $.environment.stack.push()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment