Refactoring of Instance::ipAddresses retrieving
This patch moves network-related heat output processing from Instance class to Network subclasses There are 2 reasons for this patch: 1. Instance::ipAddresses should be retrieved from Network subclasses instead of direct reading Heat template output in Instance. In current implementation ipAddresses property initialized from Instance output in Heat template. The same information can be retrieved via Instance::joinedNetworks property with Network method usage. It breaks single responsibility principle. 2. Implementation details of resource classes methods should be hidden from Instance objects Change-Id: Id26c65b6e73da64fe0b930a6a4c1594aa829ccea
This commit is contained in:
parent
a8800d9b14
commit
d6a546801a
|
@ -215,7 +215,8 @@ deploying, joining to the network, applying security group, and deleting.
|
|||
``io.murano.system.Agent``.
|
||||
- ``Runtime``
|
||||
* - ``ipAddresses``
|
||||
- A list of all IP addresses assigned to an instance.
|
||||
- A list of all IP addresses assigned to an instance. Floating ip address
|
||||
is placed in the list tail if present.
|
||||
- ``Out``
|
||||
* - ``networks``
|
||||
- Specifies the networks that an instance will be joined to.
|
||||
|
|
|
@ -153,10 +153,6 @@ Methods:
|
|||
properties: $properties
|
||||
|
||||
outputs:
|
||||
format('{0}-assigned-ips', $.name):
|
||||
description: format('Network IPs assigned to {0} instance', $.name)
|
||||
value:
|
||||
get_attr: [ $.name, networks ]
|
||||
format('{0}-id', $.name):
|
||||
description: format('ID of {0} instance', $.name)
|
||||
value:
|
||||
|
@ -175,8 +171,6 @@ Methods:
|
|||
- $region: $.getRegion()
|
||||
- $region.stack.push()
|
||||
- $outputs: $region.stack.output()
|
||||
- $netIdToIpsMap: $outputs.get(format('{0}-assigned-ips', $this.name))
|
||||
- $.ipAddresses: $netIdToIpsMap.values().flatten().distinct()
|
||||
- $.openstackId: $outputs.get(format('{0}-id', $this.name))
|
||||
- If: $._floatingIpOutputName != null
|
||||
Then:
|
||||
|
@ -185,8 +179,12 @@ Methods:
|
|||
Then: $.setAttr(fipAssigned, true)
|
||||
- $._environment.instanceNotifier.trackCloudInstance($this)
|
||||
- $.joinedNetworks: $this.joinedNetworks.distinct().select({
|
||||
'network' => $['network'],
|
||||
'ipList' => $['network'].getInstanceIpList($this)})
|
||||
network => $.network,
|
||||
ipList => $.network.getInstanceIpList($this)})
|
||||
- $.ipAddresses: $this.joinedNetworks.selectMany($.ipList).where($ != $this.floatingIpAddress).distinct()
|
||||
- If: $.floatingIpAddress != null
|
||||
Then:
|
||||
- $.ipAddresses: $.ipAddresses.append($.floatingIpAddress)
|
||||
|
||||
deploy:
|
||||
Body:
|
||||
|
@ -320,7 +318,6 @@ Methods:
|
|||
- $._environment.instanceNotifier.untrackCloudInstance($this)
|
||||
|
||||
- $outputsToDelete: list(
|
||||
'{0}-assigned-ips'.format($.name),
|
||||
'{0}-id'.format($.name)).concat($.getAttr(instanceOutputs, []))
|
||||
- $template.outputs: $template.outputs.deleteAll($outputsToDelete)
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ Methods:
|
|||
- $instanceFipOutput: null
|
||||
- $instanceResources: []
|
||||
- $instanceOutputs: []
|
||||
- $instanceNetworkOutput: format('{0}-assigned-ips', $instance.name)
|
||||
- If: $assignFloatingIp
|
||||
Then:
|
||||
- $instanceFipOutput: $instance.name + '-floatingIPaddress'
|
||||
|
@ -57,8 +58,12 @@ Methods:
|
|||
value:
|
||||
get_attr: [$fipName, ip]
|
||||
description: format('Floating IP of {0}', $instance.name)
|
||||
$instanceNetworkOutput:
|
||||
description: format('Network IPs assigned to {0} instance', $instance.name)
|
||||
value:
|
||||
get_attr: [ $instance.name, networks ]
|
||||
- $instanceResources: [$fipName, $fipName + 'Assignment']
|
||||
- $instanceOutputs: [$instanceFipOutput]
|
||||
- $instanceOutputs: [$instanceFipOutput, $instanceNetworkOutput]
|
||||
- Return:
|
||||
template: $template
|
||||
secGroupName:
|
||||
|
@ -83,4 +88,6 @@ Methods:
|
|||
- instance:
|
||||
Contract: $.class(Instance).notNull()
|
||||
Body:
|
||||
- Return: $instance.ipAddresses
|
||||
- Return: $instance.getRegion().stack.output().get(
|
||||
format('{0}-assigned-ips', $instance.name)
|
||||
).values().flatten().distinct()
|
||||
|
|
Loading…
Reference in New Issue