1 var collectConnectionPoints = function(resourceModel, diff) {
2 return collectPorts(resourceModel, diff)
5 function collectPorts(resourceModel, diff){
7 collectResources('', resourceModel, pathToResource, true);
9 Object.keys(pathToResource).forEach(function (path) {
10 var port = pathToResource[path];
12 transformedPort.name = port.attributes.name;
13 transformedPort.providerId = port.attributes.id;
14 transformedPort.cpId = path;
15 var managedPort = false;
16 if(port.hasOwnProperty('externalConnectionPoint')){
17 transformedPort.ecpdId = port.externalConnectionPoint;
20 if(port.hasOwnProperty('connectionPoint')){
21 transformedPort.cpdId = port.connectionPoint;
24 transformedPort.tenantId = port.attributes.tenant_id;
25 transformedPort.ipAddress = port.attributes.fixed_ips[0].ip_address;
26 transformedPort.macAddress = port.attributes.mac_address;
27 transformedPort.serverProviderId = port.attributes.device_id;
28 transformedPort.networkProviderId = port.attributes.network_id;
30 transformedPorts.push(transformedPort)
33 return transformedPorts;
36 function contains(resourceChanges, path){
37 var keys = Object.keys(resourceChanges);
38 return keys.indexOf(path) !== -1;
41 function collectResources(path, root, pathToResouceMap, onResources){
42 root && Object.keys(root).forEach(function(item) {
43 if(item == 'resource_type' && root[item] == 'OS::Neutron::Port'){
44 pathToResouceMap[path] = root
46 else if(typeof root[item] === "object"){
47 var newItem = onResources ? "" : item;
49 if('' != newItem && path != ''){
53 collectResources(newPath, root[item], pathToResouceMap, !onResources)