Merge "Extracted replication capabilities from ServerGroup"
This commit is contained in:
commit
055cd06052
@ -37,7 +37,8 @@ Methods:
|
|||||||
- serverGroup:
|
- serverGroup:
|
||||||
Contract: $.class(ServerGroup).notNull()
|
Contract: $.class(ServerGroup).notNull()
|
||||||
Body:
|
Body:
|
||||||
- $serversToInstall: $serverGroup.items.pselect(switch($this.checkServerIsInstalled($) => null, true => $)).where($ != null)
|
- $serversToInstall: $serverGroup.getServers().pselect(
|
||||||
|
switch($this.checkServerIsInstalled($) => null, true => $)).where($ != null)
|
||||||
- If: any($serversToInstall)
|
- If: any($serversToInstall)
|
||||||
Then:
|
Then:
|
||||||
- $.beforeInstall($serversToInstall, $serverGroup)
|
- $.beforeInstall($serversToInstall, $serverGroup)
|
||||||
@ -198,7 +199,8 @@ Methods:
|
|||||||
- If: $this.checkClusterIsConfigured($serverGroup)
|
- If: $this.checkClusterIsConfigured($serverGroup)
|
||||||
Then:
|
Then:
|
||||||
- Return:
|
- Return:
|
||||||
- $serversToConfigure: $serverGroup.items.pselect(switch($this.checkServerIsConfigured($, $serverGroup) => null, true => $)).where($ != null)
|
- $serversToConfigure: $serverGroup.getServers().pselect(
|
||||||
|
switch($this.checkServerIsConfigured($, $serverGroup) => null, true => $)).where($ != null)
|
||||||
- $this.preConfigure($serversToConfigure, $serverGroup)
|
- $this.preConfigure($serversToConfigure, $serverGroup)
|
||||||
- $failures: $serversToConfigure.pselect($this.configureServer($, $serverGroup)).where($ != null)
|
- $failures: $serversToConfigure.pselect($this.configureServer($, $serverGroup)).where($ != null)
|
||||||
- $.completeConfiguration($serversToConfigure, $serverGroup, $failures)
|
- $.completeConfiguration($serversToConfigure, $serverGroup, $failures)
|
||||||
@ -417,7 +419,7 @@ Methods:
|
|||||||
any:
|
any:
|
||||||
- Return: true
|
- Return: true
|
||||||
quorum:
|
quorum:
|
||||||
- $numServers: len($serverGroup.items)
|
- $numServers: $serverGroup.getServers().count()
|
||||||
- $maxFailures: $numServers - ($numServers/2 + 1)
|
- $maxFailures: $numServers - ($numServers/2 + 1)
|
||||||
- Return: $numFailures <= $maxFailures
|
- Return: $numFailures <= $maxFailures
|
||||||
Value: $allowedFailures
|
Value: $allowedFailures
|
||||||
|
@ -37,7 +37,7 @@ Properties:
|
|||||||
Default: 1
|
Default: 1
|
||||||
|
|
||||||
items:
|
items:
|
||||||
Usage: InOut
|
Usage: Out
|
||||||
Contract:
|
Contract:
|
||||||
- $.class(std:Object)
|
- $.class(std:Object)
|
||||||
|
|
||||||
|
@ -16,20 +16,122 @@ Namespaces:
|
|||||||
res: io.murano.resources
|
res: io.murano.resources
|
||||||
std: io.murano
|
std: io.murano
|
||||||
|
|
||||||
|
--- # ------------------------------------------------------------------ # ---
|
||||||
|
# A group of Servers
|
||||||
|
|
||||||
|
Name: ServerGroup
|
||||||
|
Methods:
|
||||||
|
getServers:
|
||||||
|
|
||||||
|
deployServers:
|
||||||
|
Usage: Static
|
||||||
|
Arguments:
|
||||||
|
- servers:
|
||||||
|
Contract:
|
||||||
|
- $.class(res:Instance).notNull()
|
||||||
|
- environment:
|
||||||
|
Contract: $.class(std:Environment)
|
||||||
|
Body:
|
||||||
|
- $servers.select($this._deployServer($, $environment))
|
||||||
|
- $servers.select($.endDeploy())
|
||||||
|
|
||||||
|
releaseServers:
|
||||||
|
Usage: Static
|
||||||
|
Arguments:
|
||||||
|
- servers:
|
||||||
|
Contract:
|
||||||
|
- $.class(res:Instance).notNull()
|
||||||
|
Body:
|
||||||
|
- $servers.select($.beginReleaseResources())
|
||||||
|
- $servers.select($.endReleaseResources())
|
||||||
|
|
||||||
|
_deployServer:
|
||||||
|
Usage: Static
|
||||||
|
Arguments:
|
||||||
|
- server:
|
||||||
|
Contract: $.class(res:Instance).notNull()
|
||||||
|
- environment:
|
||||||
|
Contract: $.class(std:Environment)
|
||||||
|
Body:
|
||||||
|
- If: $environment and not $server.openstackId
|
||||||
|
Then:
|
||||||
|
- $environment.reporter.report($this, 'Provisioning VM for ' + name($server) or $server.name)
|
||||||
|
- $server.beginDeploy()
|
||||||
|
|
||||||
|
--- # ------------------------------------------------------------------ # ---
|
||||||
|
# A group of prepopulated servers
|
||||||
|
|
||||||
|
Name: ServerList
|
||||||
|
Extends: ServerGroup
|
||||||
|
|
||||||
|
Properties:
|
||||||
|
servers:
|
||||||
|
Contract:
|
||||||
|
- $.class(res:Instance).notNull()
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
.init:
|
||||||
|
Body:
|
||||||
|
- $this._env: $.find(std:Environment)
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
Body:
|
||||||
|
- $this.deployServers($this.servers, $this._env)
|
||||||
|
|
||||||
|
.destroy:
|
||||||
|
Body:
|
||||||
|
- $this.releaseServers($this.items)
|
||||||
|
|
||||||
|
getServers:
|
||||||
|
Body:
|
||||||
|
Return: $.servers
|
||||||
|
|
||||||
|
--- # ------------------------------------------------------------------ # ---
|
||||||
|
# Degenrate case of a server group which consists of a single server
|
||||||
|
|
||||||
|
Name: SingleServerGroup
|
||||||
|
Extends: ServerGroup
|
||||||
|
|
||||||
|
Properties:
|
||||||
|
server:
|
||||||
|
Contract: $.class(res:Instance).notNull()
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
setServer:
|
||||||
|
Arguments:
|
||||||
|
- server:
|
||||||
|
Contract: $.class(res:Instance).notNull()
|
||||||
|
Body:
|
||||||
|
- $this.items: $server
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
Body:
|
||||||
|
- $this.deployServers([$this.server], $this._env)
|
||||||
|
|
||||||
|
.destroy:
|
||||||
|
Body:
|
||||||
|
- $this.releaseServers([$this.server])
|
||||||
|
|
||||||
|
getServers:
|
||||||
|
Body:
|
||||||
|
Return: [$.server]
|
||||||
|
|
||||||
--- # ------------------------------------------------------------------ # ---
|
--- # ------------------------------------------------------------------ # ---
|
||||||
# A replication group aggregating Servers
|
# A replication group aggregating Servers
|
||||||
# Adds a logic to concurrently provision and unprovision servers
|
# Adds a logic to concurrently provision and unprovision servers
|
||||||
|
|
||||||
|
|
||||||
Name: ServerGroup
|
Name: ServerReplicationGroup
|
||||||
Extends:
|
Extends:
|
||||||
- ReplicationGroup
|
- ReplicationGroup
|
||||||
|
- ServerGroup
|
||||||
|
|
||||||
Properties:
|
Properties:
|
||||||
provider:
|
provider:
|
||||||
Contract: $.class(ReplicaProvider).notNull()
|
Contract: $.class(ReplicaProvider).notNull()
|
||||||
|
|
||||||
items:
|
items:
|
||||||
Usage: InOut
|
Usage: Out
|
||||||
Contract:
|
Contract:
|
||||||
- $.class(res:Instance)
|
- $.class(res:Instance)
|
||||||
|
|
||||||
@ -50,27 +152,38 @@ Methods:
|
|||||||
- $target: format(' {0} {1}', $target, name($this))
|
- $target: format(' {0} {1}', $target, name($this))
|
||||||
Else:
|
Else:
|
||||||
- $target: ''
|
- $target: ''
|
||||||
- $this._env.reporter.report($this, format('{0} {1} servers{2}', $verb, abs($delta), $target))
|
- $this._env.reporter.report($this, format('{0} {1} servers{2}',
|
||||||
|
$verb, abs($delta), $target))
|
||||||
|
|
||||||
- cast($this, ReplicationGroup).deploy()
|
- cast($this, ReplicationGroup).deploy()
|
||||||
- $this.items.select($this._deployServer($))
|
- $this.deployServers($this.items, $this._env)
|
||||||
- $this.items.select($.endDeploy())
|
|
||||||
|
|
||||||
_deployServer:
|
|
||||||
Arguments:
|
|
||||||
- server:
|
|
||||||
Contract: $.class(res:Instance)
|
|
||||||
Body:
|
|
||||||
- If: $this._env and not $server.openstackId
|
|
||||||
Then:
|
|
||||||
- $this._env.reporter.report($this, 'Provisioning VM for ' + name($server) or $server.name)
|
|
||||||
- $server.beginDeploy()
|
|
||||||
|
|
||||||
.destroy:
|
.destroy:
|
||||||
Body:
|
Body:
|
||||||
- $this.items.select($.beginReleaseResources())
|
- $this.releaseServers($this.items)
|
||||||
- $this.items.select($.endReleaseResources())
|
|
||||||
|
getServers:
|
||||||
|
Body:
|
||||||
|
Return: $.items
|
||||||
|
|
||||||
|
--- # ------------------------------------------------------------------ # ---
|
||||||
|
# A server group that composed of other server groups
|
||||||
|
|
||||||
|
Name: CompositeServerGroup
|
||||||
|
Extends: ServerGroup
|
||||||
|
|
||||||
|
Properties:
|
||||||
|
serverGroups:
|
||||||
|
Contract:
|
||||||
|
- $.class(ServerGroup).notNull()
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
deploy:
|
||||||
|
Body:
|
||||||
|
- $this.serverGroups.pselect($.deploy())
|
||||||
|
|
||||||
|
getServers:
|
||||||
|
Body:
|
||||||
|
Return: $this.serverGroups.selectMany($.getServers())
|
||||||
|
|
||||||
--- # ------------------------------------------------------------------ # ---
|
--- # ------------------------------------------------------------------ # ---
|
||||||
# A replication provider acting as a default factory class for Servers
|
# A replication provider acting as a default factory class for Servers
|
||||||
|
@ -83,22 +83,22 @@ Methods:
|
|||||||
|
|
||||||
|
|
||||||
- $serverTemplate: new(res:LinuxMuranoInstance, $this.environment,
|
- $serverTemplate: new(res:LinuxMuranoInstance, $this.environment,
|
||||||
name=>'whatever',
|
name => 'whatever',
|
||||||
image=>'murano-latest',
|
image => 'murano-latest',
|
||||||
flavor=>'t1.medium')
|
flavor => 't1.medium')
|
||||||
- $this.provider: new(apps:ServerProvider, source=>$serverTemplate,
|
- $this.provider: new(apps:ServerProvider, source => $serverTemplate,
|
||||||
serverNamePattern=>'testNode-{0}')
|
serverNamePattern => 'testNode-{0}')
|
||||||
|
|
||||||
testCreateSingleServer:
|
testCreateSingleServer:
|
||||||
Body:
|
Body:
|
||||||
- $ssg: new(apps:ServerGroup, provider=>$this.provider)
|
- $ssg: new(apps:ServerReplicationGroup, provider => $this.provider)
|
||||||
- $ssg.deploy()
|
- $ssg.deploy()
|
||||||
- $this.assertServerCount(1)
|
- $this.assertServerCount(1)
|
||||||
|
|
||||||
testServersHaveProperName:
|
testServersHaveProperName:
|
||||||
Body:
|
Body:
|
||||||
- $model:
|
- $model:
|
||||||
apps:ServerGroup:
|
apps:ServerReplicationGroup:
|
||||||
numItems: 2
|
numItems: 2
|
||||||
provider:
|
provider:
|
||||||
apps:ServerProvider:
|
apps:ServerProvider:
|
||||||
@ -113,13 +113,13 @@ Methods:
|
|||||||
|
|
||||||
testCreateMultipleServers:
|
testCreateMultipleServers:
|
||||||
Body:
|
Body:
|
||||||
- $ssg: new(apps:ServerGroup, provider=>$this.provider, numItems=>5)
|
- $ssg: new(apps:ServerReplicationGroup, provider => $this.provider, numItems => 5)
|
||||||
- $ssg.deploy()
|
- $ssg.deploy()
|
||||||
- $this.assertServerCount(5)
|
- $this.assertServerCount(5)
|
||||||
|
|
||||||
testCreateScaleUp:
|
testCreateScaleUp:
|
||||||
Body:
|
Body:
|
||||||
- $ssg: new(apps:ServerGroup, provider=>$this.provider, numItems=>3)
|
- $ssg: new(apps:ServerReplicationGroup, provider => $this.provider, numItems => 3)
|
||||||
- $ssg.deploy()
|
- $ssg.deploy()
|
||||||
- $this.assertServerCount(3)
|
- $this.assertServerCount(3)
|
||||||
- $ssg.scale(4)
|
- $ssg.scale(4)
|
||||||
@ -128,7 +128,7 @@ Methods:
|
|||||||
|
|
||||||
testCreateScaleDown:
|
testCreateScaleDown:
|
||||||
Body:
|
Body:
|
||||||
- $ssg: new(apps:ServerGroup, provider=>$this.provider, numItems=>3)
|
- $ssg: new(apps:ServerReplicationGroup, provider => $this.provider, numItems => 3)
|
||||||
- $ssg.deploy()
|
- $ssg.deploy()
|
||||||
- $this.assertServerCount(3)
|
- $this.assertServerCount(3)
|
||||||
- $ssg.scale(-2)
|
- $ssg.scale(-2)
|
||||||
@ -137,7 +137,8 @@ Methods:
|
|||||||
|
|
||||||
testMultipleServersReporting:
|
testMultipleServersReporting:
|
||||||
Body:
|
Body:
|
||||||
- $ssg: new(apps:ServerGroup, $this.environment, TestGroup, provider=>$this.provider, numItems=>3)
|
- $ssg: new(apps:ServerReplicationGroup, $this.environment, TestGroup,
|
||||||
|
provider => $this.provider, numItems => 3)
|
||||||
- $ssg.deploy()
|
- $ssg.deploy()
|
||||||
- $this.assertEqual('Creating 3 servers for TestGroup', $this.reports[0])
|
- $this.assertEqual('Creating 3 servers for TestGroup', $this.reports[0])
|
||||||
- $ssg.scale(-2)
|
- $ssg.scale(-2)
|
||||||
@ -145,7 +146,8 @@ Methods:
|
|||||||
|
|
||||||
testMultipleServersReportingNoGroupName:
|
testMultipleServersReportingNoGroupName:
|
||||||
Body:
|
Body:
|
||||||
- $ssg: new(apps:ServerGroup, $this.environment, null, provider=>$this.provider, numItems=>3)
|
- $ssg: new(apps:ServerReplicationGroup, $this.environment, null,
|
||||||
|
provider => $this.provider, numItems => 3)
|
||||||
- $ssg.deploy()
|
- $ssg.deploy()
|
||||||
- $this.assertEqual('Creating 3 servers', $this.reports[0])
|
- $this.assertEqual('Creating 3 servers', $this.reports[0])
|
||||||
- $ssg.scale(-2)
|
- $ssg.scale(-2)
|
||||||
@ -153,7 +155,8 @@ Methods:
|
|||||||
|
|
||||||
testNoReportingIfSingleServer:
|
testNoReportingIfSingleServer:
|
||||||
Body:
|
Body:
|
||||||
- $ssg: new(apps:ServerGroup, $this.environment, TestGroup, provider=>$this.provider, numItems=>1)
|
- $ssg: new(apps:ServerReplicationGroup, $this.environment, TestGroup,
|
||||||
|
provider => $this.provider, numItems => 1)
|
||||||
- $ssg.deploy()
|
- $ssg.deploy()
|
||||||
- $this.assertEqual(1, len($this.reports))
|
- $this.assertEqual(1, len($this.reports))
|
||||||
|
|
||||||
@ -163,4 +166,5 @@ Methods:
|
|||||||
- count:
|
- count:
|
||||||
Contract: $.int()
|
Contract: $.int()
|
||||||
Body:
|
Body:
|
||||||
- $this.assertEqual($count, $this.currentTemplate.resources.values().where($.type='OS::Nova::Server').len())
|
- $this.assertEqual($count, $this.currentTemplate.resources.values().where(
|
||||||
|
$.type = 'OS::Nova::Server').len())
|
||||||
|
@ -54,7 +54,7 @@ Methods:
|
|||||||
flavor=>'noop')
|
flavor=>'noop')
|
||||||
- $provider: new(apps:ServerProvider, $this.environment,
|
- $provider: new(apps:ServerProvider, $this.environment,
|
||||||
source=>$server, serverNamePattern=>'testNode-{0}')
|
source=>$server, serverNamePattern=>'testNode-{0}')
|
||||||
- $this.group: new(apps:ServerGroup, provider=>$provider, numItems=>5)
|
- $this.group: new(apps:ServerReplicationGroup, provider=>$provider, numItems=>5)
|
||||||
- $this.group.deploy()
|
- $this.group.deploy()
|
||||||
- $this.reports: []
|
- $this.reports: []
|
||||||
- inject($this.environment.reporter, report, $this, report)
|
- inject($this.environment.reporter, report, $this, report)
|
||||||
|
@ -32,6 +32,10 @@ Classes:
|
|||||||
io.murano.applications.Event: events.yaml
|
io.murano.applications.Event: events.yaml
|
||||||
|
|
||||||
io.murano.applications.ServerGroup: servers.yaml
|
io.murano.applications.ServerGroup: servers.yaml
|
||||||
|
io.murano.applications.ServerList: servers.yaml
|
||||||
|
io.murano.applications.CompositeServerGroup: servers.yaml
|
||||||
|
io.murano.applications.SingleServerGroup: servers.yaml
|
||||||
|
io.murano.applications.ServerReplicationGroup: servers.yaml
|
||||||
io.murano.applications.ServerProvider: servers.yaml
|
io.murano.applications.ServerProvider: servers.yaml
|
||||||
|
|
||||||
io.murano.applications.Installable: component.yaml
|
io.murano.applications.Installable: component.yaml
|
||||||
|
Loading…
x
Reference in New Issue
Block a user