
Added a new package ( io.murano.lib.networks.Neutron) to handle networking via Neutron The package introduces a class 'NewNetwork' (io.murano.lib.networks.neutron.NewNetwork) This class is capable of the following: - Create a new Network (L2 segment) - Use NetworkExplorer class to allocate an available CIDR - Create a new Subnet (L3 segment) in the created Network with the allocated CIDR - Use NetworkExplorer class to locate an available router - Use NetworkExplorer class to detect the default DNS nameserver - Uplink the created subnet to the located router Also, as this class extends io.murano.resources.Network, it implements the addHostToNetwork method The implementation creates a Neutron Port and connects that port to a created network and intance This commit also modifies the environment-creation logic of the API, allowing to add default networks to the Environment object. This is a temporary solution: in future the instantiation of this object(s) should be done in MuranoPL This commit concludes the minimum set of functionality needed to implement AdvancedNetworking in 0.4.x feature set. Closes-bug: #1308921 Change-Id: I885620099995b0d402a23def3ff428fb902973d2
132 lines
3.3 KiB
YAML
132 lines
3.3 KiB
YAML
Namespaces:
|
|
=: io.murano.lib.networks.neutron
|
|
res: io.murano.resources
|
|
std: io.murano
|
|
sys: io.murano.system
|
|
|
|
Name: NewNetwork
|
|
|
|
Extends: res:Network
|
|
|
|
Properties:
|
|
name:
|
|
Contract: $.string().notNull()
|
|
|
|
externalRouterId:
|
|
Contract: $.string()
|
|
Usage: InOut
|
|
|
|
autoUplink:
|
|
Contract: $.bool().notNull()
|
|
Default: true
|
|
|
|
autogenerateSubnet:
|
|
Contract: $.bool().notNull()
|
|
Default: true
|
|
|
|
subnetCidr:
|
|
Contract: $.string()
|
|
Usage: InOut
|
|
|
|
dnsNameserver:
|
|
Contract: $.string()
|
|
Usage: InOut
|
|
|
|
useDefaultDns:
|
|
Contract: $.bool().notNull()
|
|
Default: true
|
|
|
|
Workflow:
|
|
initialize:
|
|
Body:
|
|
- $.environment: $.find(std:Environment).require()
|
|
- $.netExplorer: new(sys:NetworkExplorer)
|
|
|
|
deploy:
|
|
Body:
|
|
- $.ensureNetworkConfigured()
|
|
- $.environment.instanceNotifier.untrackApplication($this)
|
|
|
|
addHostToNetwork:
|
|
Arguments:
|
|
- instance:
|
|
Contract: $.class(res:Instance).notNull()
|
|
Body:
|
|
- $.ensureNetworkConfigured()
|
|
- $portname: $instance.name + '-port-to-' + $.id()
|
|
- $template:
|
|
Resources:
|
|
$portname:
|
|
Type: 'OS::Neutron::Port'
|
|
Properties:
|
|
network_id: {Ref: $.net_res_name}
|
|
fixed_ips: [{subnet_id: {Ref: $.subnet_res_name}}]
|
|
$instance.name:
|
|
Properties:
|
|
NetworkInterfaces:
|
|
- Ref: $portname
|
|
- $.environment.stack.updateTemplate($template)
|
|
|
|
|
|
ensureNetworkConfigured:
|
|
Body:
|
|
- If: !yaql "not bool($.getAttr(networkConfigured))"
|
|
Then:
|
|
- If: $.useDefaultDns and (not bool($.dnsNameserver))
|
|
Then:
|
|
- $.dnsNameserver: $.netExplorer.getDefaultDns()
|
|
|
|
- $.net_res_name: $.name + '-net-' + $.id()
|
|
- $.subnet_res_name: $.name + '-subnet-' + $.id()
|
|
- $.createNetwork()
|
|
- If: $.autoUplink and (not bool($.externalRouterId))
|
|
Then:
|
|
- $.externalRouterId: $.netExplorer.getDefaultRouter()
|
|
- If: $.autogenerateSubnet and (not bool($.subnetCidr))
|
|
Then:
|
|
- $.subnetCidr: $.netExplorer.getAvailableCidr($.externalRouterId, $.id())
|
|
- $.createSubnet()
|
|
- If: !yaql "bool($.externalRouterId)"
|
|
Then:
|
|
- $.createRouterInterface()
|
|
|
|
- $.environment.stack.push()
|
|
- $.setAttr(networkConfigured, true)
|
|
|
|
|
|
createNetwork:
|
|
Body:
|
|
- $template:
|
|
Resources:
|
|
$.net_res_name:
|
|
Type: 'OS::Neutron::Net'
|
|
Properties:
|
|
name: $.name
|
|
- $.environment.stack.updateTemplate($template)
|
|
|
|
createSubnet:
|
|
Body:
|
|
- $template:
|
|
Resources:
|
|
$.subnet_res_name:
|
|
Type: 'OS::Neutron::Subnet'
|
|
Properties:
|
|
network_id: {Ref: $.net_res_name}
|
|
ip_version: 4
|
|
dns_nameservers: [$.dnsNameserver]
|
|
cidr: $.subnetCidr
|
|
- $.environment.stack.updateTemplate($template)
|
|
|
|
createRouterInterface:
|
|
Body:
|
|
- $template:
|
|
Resources:
|
|
$.name + '-ri-' + $.id():
|
|
Type: 'OS::Neutron::RouterInterface'
|
|
Properties:
|
|
router_id: $.externalRouterId
|
|
subnet_id: {Ref: $.subnet_res_name}
|
|
- $.environment.stack.updateTemplate($template)
|
|
|
|
|