Restructure murano-apps repository

Change-Id: I9cdb1e4afcb9929c7b7a5437faaa25d284daefdb
Closes-Bug: #1441644
This commit is contained in:
Dmytro Dovbii
2015-04-09 10:18:33 +03:00
commit 7cb39996f0
179 changed files with 5948 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
Namespaces:
=: io.murano.apps.docker
std: io.murano
Name: ApplicationPort
Properties:
port:
Contract: $.int().notNull().check($ > 0 and $ < 65536)
scope:
Contract: $.string().notNull().check($ in list(public, cloud, host, internal))
Default: private
protocol:
Contract: $.string().notNull().check($ in list(TCP, UDP))
Default: TCP
Methods:
getRepresentation:
Body:
Return:
port: $.port
scope: $.scope
protocol: $.protocol

View File

@@ -0,0 +1,91 @@
Namespaces:
=: io.murano.apps.docker
std: io.murano
Name: DockerApplication
Extends: std:Application
Properties:
host:
Contract: $.class(DockerContainerHost).notNull()
applicationEndpoints:
Contract:
- port: $.int().notNull().check($ > 0)
address: $.string().notNull()
scope: $.string().notNull().check($ in list(public, cloud, internal, host))
portScope: $.string().notNull().check($ in list(public, cloud, internal, host))
containerPort: $.int().notNull().check($ > 0)
protocol: $.string().notNull().check($ in list(TCP, UDP))
Usage: Out
Methods:
initialize:
Body:
- $._environment: $.find(std:Environment).require()
deploy:
Body:
- $._environment.reporter.report($this, 'Waiting for the host to be ready')
- $.host.deploy()
- $container: $.getContainer()
- $repr: $._getContainerRepresentation($container)
- If: $.getAttr(container, null) != $repr
Then:
- $.onInstallationStart()
- $.applicationEndpoints: $.host.hostContainer($container)
- $.setAttr(container, $repr)
- $.onInstallationFinish()
getConnectionTo:
Arguments:
- application:
Contract: $.class(DockerApplication).notNull()
- port:
Contract: $.int().notNull().check($ > 0)
- protocol:
Contract: $.string().notNull().check($ in list(TCP, UDP))
Default: TCP
Body:
- $scopes: [cloud, public]
- If: $.host = $application.host
Then:
- $scopes: list(host, internal) + $scopes
Else:
- If: $.host.getInternalScopeId() = $application.host.getInternalScopeId()
Then:
- $scopes: list(internal) + $scope
- For: s
In: $scopes
Do:
- $endpoints: $application.applicationEndpoints.where(true).where(
$.scope = $s and $.containerPort = $port and $.protocol = $protocol)
- If: len($endpoints) > 0
Then:
- $index: int(len($endpoints) * random())
- $endpoint: $endpoints[$index]
- Return:
host: $endpoint.address
port: $endpoint.port
_getContainerRepresentation:
Arguments:
- container:
Contract: $.class(DockerContainer).notNull()
Body:
Return: $container.getRepresentation()
getContainer:
onInstallationStart:
Body:
onInstallationFinish:
Body:

View File

@@ -0,0 +1,46 @@
Namespaces:
=: io.murano.apps.docker
Name: DockerContainer
Properties:
name:
Contract: $.string().notNull()
image:
Contract: $.string().notNull()
commands:
Contract:
- $.string().notNull()
Default: []
env:
Contract:
$.string().notNull(): $.string().notNull()
Default: {}
ports:
Contract:
- $.class(ApplicationPort)
Default: []
volumes:
Contract:
$.string().notNull(): $.class(DockerVolume).notNull()
Default: {}
Methods:
getRepresentation:
Body:
- $volumeRepresentations: {}
- For: volume
In: $.volumes
Do:
- $volumeRepresentations[$volume]: $.volumes.get($volume).getRepresentation()
- Return:
name: $.name
image: $.image
env: env
ports: $.ports.select($.getRepresentation())
volumes: $volumeRepresentations

View File

@@ -0,0 +1,30 @@
Namespaces:
=: io.murano.apps.docker
std: io.murano
Name: DockerContainerHost
Extends: std:Application
Properties:
name:
Contract: $.string().notNull()
Methods:
hostContainer:
Arguments:
- container:
Contract: $.class(DockerContainer).notNull()
deleteContainer:
Arguments:
- name:
Contract: $.string().notNull()
getEndpoints:
Arguments:
- applicationName:
Contract: $.string().notNull()
getInternalScopeId:

View File

@@ -0,0 +1,30 @@
Namespaces:
=: io.murano.apps.docker
Name: DockerHelpers
Methods:
labels2Map:
Arguments:
labelsString:
Contract: $.string().notNull()
Body:
- $result: {}
- For: t
In: $labelsString.replace(',', ';').split(';')
Do:
- $pair: $t.split('=')
- If: len($pair) < 2
Then:
Continue:
- $key: $pair[0].trim()
- $result[$key]: $pair[1].trim()
- Return: $result
map2labels:
Arguments:
labelsMap:
Contract:
$.string().notNull(): $.string().notNull()
Body:
- Return: join(';', $labelsMap.select(list($, $labelsMap.get($))).select(join('=', $)))

View File

@@ -0,0 +1,20 @@
Namespaces:
=: io.murano.apps.docker
Name: DockerHostVolume
Extends: DockerVolume
Properties:
path:
Contract: $.string().notNull()
Methods:
getType:
Body:
Return: HostDir
getParameters:
Body:
Return: $.path

View File

@@ -0,0 +1,15 @@
Namespaces:
=: io.murano.apps.docker
Name: DockerTempVolume
Extends: DockerVolume
Methods:
getType:
Body:
Return: TempVolume
getParameters:
Body:
Return: null

View File

@@ -0,0 +1,19 @@
Namespaces:
=: io.murano.apps.docker
Name: DockerVolume
Properties:
name:
Contract: $.string().notNull()
Methods:
getType:
getParameters:
getRepresentation:
Body:
Return:
type: $.getType()
parameters: $.getParameters()

View File

@@ -0,0 +1,19 @@
Format: 1.0
Type: Library
FullName: io.murano.apps.docker.Interfaces
Name: Docker Interface Library
Description: |
The library provides all necessary interface for Docker
and Kubernetes applications
Author: 'Mirantis, Inc'
Tags: [Docker, Kubernetes]
Classes:
io.murano.apps.docker.DockerApplication: DockerApplication.yaml
io.murano.apps.docker.DockerContainer: DockerContainer.yaml
io.murano.apps.docker.DockerContainerHost: DockerContainerHost.yaml
io.murano.apps.docker.DockerHelpers: DockerHelpers.yaml
io.murano.apps.docker.DockerHostVolume: DockerHostVolume.yaml
io.murano.apps.docker.DockerTempVolume: DockerTempVolume.yaml
io.murano.apps.docker.DockerVolume: DockerVolume.yaml
io.murano.apps.docker.ApplicationPort: ApplicationPort.yaml