Merge "Remove getRegion() calls from network initializers"

This commit is contained in:
Jenkins
2016-10-14 05:03:35 +00:00
committed by Gerrit Code Review
3 changed files with 36 additions and 28 deletions

View File

@@ -38,7 +38,6 @@ Properties:
Workflow:
initialize:
Body:
- $._netExplorer: new(sys:NetworkExplorer, $this.getRegion())
- $._networks: null
- $._subnetworks: null
- $._ports: null
@@ -48,6 +47,7 @@ Workflow:
deploy:
Body:
- $netExplorer: $._getNetExplorer()
- If: $.internalNetworkName = null
Then:
$.internalNetworkName: $._getNetworks().where(
@@ -72,7 +72,7 @@ Workflow:
- If: $.externalNetworkName = null and $._internalNetworkId != null
Then:
- $ports: $._netExplorer.listPorts()
- $ports: $netExplorer.listPorts()
- $routerCandidates: $ports.where(
$.network_id = $this._internalNetworkId and $.device_owner = 'network:router_interface').
select($.device_id)
@@ -100,14 +100,14 @@ Workflow:
Body:
- If: not $._networks
Then:
$._networks: $._netExplorer.listNetworks()
$._networks: $._getNetExplorer().listNetworks()
- Return: $._networks
_getSubnetworks:
Body:
- If: $._subnetworks = null
Then:
$._subnetworks : $._netExplorer.listSubnetworks()
$._subnetworks : $._getNetExplorer().listSubnetworks()
- Return: $._subnetworks
joinInstance:

View File

@@ -50,35 +50,32 @@ Properties:
Usage: InOut
Methods:
.init:
Body:
- $._region: $.getRegion()
- $._netExplorer: new(sys:NetworkExplorer, $this)
deploy:
Body:
- If: not $.getAttr(deployed, false)
Then:
- $netExplorer: $._getNetExplorer()
- If: len($.dnsNameservers) = 0
Then:
- $.dnsNameservers: $._netExplorer.getDefaultDns()
- $.dnsNameservers: $netExplorer.getDefaultDns()
- $template: $._createNetwork()
- If: $.autoUplink and (not bool($.externalRouterId))
Then:
- $.externalRouterId: $._netExplorer.getDefaultRouter()
- $.externalRouterId: $netExplorer.getDefaultRouter()
- If: $.autogenerateSubnet and (not bool($.subnetCidr))
Then:
- $.subnetCidr: $._netExplorer.getAvailableCidr($.externalRouterId, id($))
- $.subnetCidr: $netExplorer.getAvailableCidr($.externalRouterId, id($))
- $template: $template.mergeWith($._createSubnet())
- If: $.externalRouterId != null
Then:
- $template: $template.mergeWith($._createRouterInterface())
- $._region.stack.updateTemplate($template)
- $._region.stack.push()
- $outputs: $._region.stack.output()
- $region: $.getRegion()
- $region.stack.updateTemplate($template)
- $region.stack.push()
- $outputs: $region.stack.output()
- $.openstackId: $outputs.get(format('{0}-id', $this.name))
- $.setAttr(deployed, true)
@@ -182,7 +179,7 @@ Methods:
describe:
Body:
- $.deploy()
- $subnet: $._netExplorer.listSubnetworks().where(
- $subnet: $._getNetExplorer().listSubnetworks().where(
$.network_id = $this.openstackId).first()
- Return:
provider: Neutron
@@ -196,7 +193,8 @@ Methods:
releaseResources:
Body:
- $template: $._region.stack.current()
- $region: $.getRegion()
- $template: $region.stack.current()
- $template.resources: $template.resources.delete($._getHeatName())
- $template.resources: $template.resources.delete($._getSubnetName())
@@ -207,8 +205,8 @@ Methods:
Then:
$template.resources: $template.resources.delete($._getRouterInterfaceName())
- $._regiont.stack.setTemplate($template)
- $._region.stack.push()
- $regiont.stack.setTemplate($template)
- $region.stack.push()
- $.openstackId: null
getInstanceIpList:
@@ -216,7 +214,7 @@ Methods:
- instance:
Contract: $.class(Instance).notNull()
Body:
- Return: $._region.stack.output().get(format('adresses-{0}-in-{1}', $instance.name, $this.name)).select($["addr"]).distinct()
- Return: $.getRegion().stack.output().get(format('adresses-{0}-in-{1}', $instance.name, $this.name)).select($["addr"]).distinct()
_getRouterInterfaceName:
@@ -236,7 +234,7 @@ Methods:
_getExternalNetId:
Body:
Return: $._netExplorer.getExternalNetworkIdForRouter($.externalRouterId)
Return: $._getNetExplorer().getExternalNetworkIdForRouter($.externalRouterId)
_getHeatName:
Body:

View File

@@ -22,10 +22,15 @@ Extends: Network
Methods:
.init:
Body:
- $._netExplorer: null
- $._environment: $.find(std:Environment)
- $._region: $.getRegion()
- $._netExplorer: new(sys:NetworkExplorer, $this._region)
- $._securityGroupsEnabled: $._netExplorer.listNeutronExtensions().alias.contains('security-group')
_getNetExplorer:
Body:
- If: $._netExplorer = null
Then:
- $._netExplorer: new(sys:NetworkExplorer, $this.getRegion())
- Return: $._netExplorer
joinInstanceToNetwork:
Arguments:
@@ -45,6 +50,8 @@ Methods:
- floatingIpNetRef:
Contract: $
Body:
- $netExplorer: $._getNetExplorer()
- $securityGroupsEnabled: $netExplorer.listNeutronExtensions().alias.contains('security-group')
- $portName: format('port-{0}-{1}', id($), $instance.name)
- $patchTemplate:
resources:
@@ -56,7 +63,7 @@ Methods:
- subnet: $subnetRef
replacement_policy: AUTO
- If: bool($securityGroupName) and $this._securityGroupsEnabled
- If: bool($securityGroupName) and $securityGroupsEnabled
Then:
- $template:
resources:
@@ -111,9 +118,12 @@ Methods:
generateSecurityGroupManager:
Body:
- If: $this._securityGroupsEnabled
- $region: $.getRegion()
- $netExplorer: $._getNetExplorer()
- $securityGroupsEnabled: $netExplorer.listNeutronExtensions().alias.contains('security-group')
- If: $securityGroupsEnabled
Then:
- Return: new(sys:NeutronSecurityGroupManager, $._region)
- Return: new(sys:NeutronSecurityGroupManager, $region)
Else:
- $._environment.reporter.report($this, "Warning! Security groups are disabled!")
- Return: new(sys:DummySecurityGroupManager, $._region)
- Return: new(sys:DummySecurityGroupManager, $region)