Improved Server naming and provisioning reporting

Changed the pattern of component name for servers created with
ServerProviders (now they always have names like 'Server-X' where X is
the index of server, followed by a name of an owning ServerGroup if
one exists), as well as the reporting of Server's provisioning (it now
happens even if the server of server group do not have their component
names)

Change-Id: I6a92b7951606069e576824a0ba4135275b959776
This commit is contained in:
Alexander Tivelkov 2016-08-17 13:18:00 +03:00 committed by Stan Lagun
parent f30906848a
commit 58d92abb16
2 changed files with 13 additions and 10 deletions

View File

@ -62,9 +62,9 @@ Methods:
- server:
Contract: $.class(res:Instance)
Body:
- If: $this._env and name($server) and not $server.openstackId
- If: $this._env and not $server.openstackId
Then:
- $this._env.reporter.report($this, 'Provisioning VM for ' + $server.name)
- $this._env.reporter.report($this, 'Provisioning VM for ' + name($server) or $server.name)
- $server.beginDeploy()
.destroy:
@ -94,11 +94,14 @@ Methods:
- index:
Contract: $.int().notNull()
Body:
- $template[name]: $this.serverNamePattern.format($index)
- $template.name: $this.serverNamePattern.format($index)
- $ownerGroup: $this.find(ServerGroup)
- If: $ownerGroup
- If: $ownerGroup and name($ownerGroup)
Then:
- $template['?'][name]: format('Group {0} server {1}', name($ownerGroup), $index)
- $groupName: format(' ({0})', name($ownerGroup))
Else:
- $groupName: ''
- $template['?'].name: format('Server {0}{1}', $index, $groupName)
- Return: $template
releaseReplica:

View File

@ -107,8 +107,8 @@ Methods:
name: testGroup
- $namedSsg: new($model)
- $namedSsg.deploy()
- $this.assertEqual('Group testGroup server 1', name($namedSsg.items[0]))
- $this.assertEqual('Group testGroup server 2', name($namedSsg.items[1]))
- $this.assertEqual('Server 1 (testGroup)', name($namedSsg.items[0]))
- $this.assertEqual('Server 2 (testGroup)', name($namedSsg.items[1]))
testCreateMultipleServers:
@ -141,7 +141,7 @@ Methods:
- $ssg.deploy()
- $this.assertEqual('Creating 3 servers for TestGroup', $this.reports[0])
- $ssg.scale(-2)
- $this.assertEqual('Removing 2 servers from TestGroup', $this.reports[1])
- $this.assertEqual('Removing 2 servers from TestGroup', $this.reports[4])
testMultipleServersReportingNoGroupName:
Body:
@ -149,13 +149,13 @@ Methods:
- $ssg.deploy()
- $this.assertEqual('Creating 3 servers', $this.reports[0])
- $ssg.scale(-2)
- $this.assertEqual('Removing 2 servers', $this.reports[1])
- $this.assertEqual('Removing 2 servers', $this.reports[4])
testNoReportingIfSingleServer:
Body:
- $ssg: new(apps:ServerGroup, $this.environment, TestGroup, provider=>$this.provider, numItems=>1)
- $ssg.deploy()
- $this.assertEqual([], $this.reports)
- $this.assertEqual(1, len($this.reports))
assertServerCount: