def service_graph_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=True): if to_aim: result = utils.default_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=to_aim) else: result = utils.default_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=to_aim) tn = object_dict['tenant_name'] gr = object_dict['name'] term_cons = _aci_obj('vnsAbsTermConn__Con', tn, gr, 'T1') term_prov = _aci_obj('vnsAbsTermConn__Prov', tn, gr, 'T2') result.extend([ _aci_obj('vnsAbsTermNodeCon', tn, gr, 'T1'), term_cons, _aci_obj('vnsInTerm__Con', tn, gr, 'T1'), _aci_obj('vnsOutTerm__Con', tn, gr, 'T1'), _aci_obj('vnsAbsTermNodeProv', tn, gr, 'T2'), term_prov, _aci_obj('vnsInTerm__Prov', tn, gr, 'T2'), _aci_obj('vnsOutTerm__Prov', tn, gr, 'T2') ]) lc_nodes = [n for n in object_dict['linear_chain_nodes'] if n.get('name')] prev_conn = term_cons.values()[0]['attributes']['dn'] cntr = 0 for fn in lc_nodes: cntr = cntr + 1 node = service_graph.ServiceGraphNode( tenant_name=tn, service_graph_name=gr, name=fn['name'], managed=False, routing_mode='Redirect', sequence_number=str(cntr - 1), connectors=['consumer', 'provider']) if fn.get('device_cluster_name'): node.device_cluster_name = fn['device_cluster_name'] node.device_cluster_tenant_name = ( fn.get('device_cluster_tenant_name', tn)) node_con = _dn('vnsAbsFuncConn', tn, gr, node.name, 'consumer') node_prov = _dn('vnsAbsFuncConn', tn, gr, node.name, 'provider') cxn = service_graph.ServiceGraphConnection( tenant_name=tn, service_graph_name=gr, name='C%s' % cntr, unicast_route=True, connector_dns=[prev_conn, node_con]) prev_conn = node_prov result.extend([node, cxn]) if cntr: cxn = service_graph.ServiceGraphConnection( tenant_name=tn, service_graph_name=gr, name='C%s' % (cntr + 1), unicast_route=True, connector_dns=[prev_conn, term_prov.values()[0]['attributes']['dn']]) result.append(cxn) return result
def device_cluster_context_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=True): if to_aim: result = utils.default_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=to_aim) else: object_dict1 = copy.copy(object_dict) if not object_dict1['device_cluster_tenant_name']: object_dict1['device_cluster_tenant_name'] = ( object_dict1['tenant_name']) result = utils.default_converter(object_dict1, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=to_aim) cons_ctx = service_graph.DeviceClusterInterfaceContext( tenant_name=object_dict['tenant_name'], contract_name=object_dict['contract_name'], service_graph_name=object_dict['service_graph_name'], node_name=object_dict['node_name'], connector_name='consumer') if object_dict['device_cluster_name']: cons_ctx.device_cluster_interface_dn = _dn( 'vnsLIf', (object_dict['device_cluster_tenant_name'] or cons_ctx.tenant_name), object_dict['device_cluster_name'], 'interface') if object_dict['bridge_domain_name']: cons_ctx.bridge_domain_dn = _dn( 'fvBD', (object_dict['bridge_domain_tenant_name'] or cons_ctx.tenant_name), object_dict['bridge_domain_name']) if object_dict['service_redirect_policy_name']: cons_ctx.service_redirect_policy_dn = _dn( 'vnsSvcRedirectPol', (object_dict['service_redirect_policy_tenant_name'] or cons_ctx.tenant_name), object_dict['service_redirect_policy_name']) if (cons_ctx.device_cluster_interface_dn and cons_ctx.bridge_domain_dn and cons_ctx.service_redirect_policy_dn): prov_ctx = copy.copy(cons_ctx) prov_ctx.connector_name = 'provider' result.extend([cons_ctx, prov_ctx]) return result
def device_cluster_context_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=True): if to_aim: result = utils.default_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=to_aim) else: object_dict1 = copy.copy(object_dict) if not object_dict1['device_cluster_tenant_name']: object_dict1['device_cluster_tenant_name'] = ( object_dict1['tenant_name']) result = utils.default_converter(object_dict1, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=to_aim) cons_ctx = service_graph.DeviceClusterInterfaceContext( tenant_name=object_dict['tenant_name'], contract_name=object_dict['contract_name'], service_graph_name=object_dict['service_graph_name'], node_name=object_dict['node_name'], connector_name='consumer') if object_dict['device_cluster_name']: cons_ctx.device_cluster_interface_dn = _dn( 'vnsLIf', (object_dict['device_cluster_tenant_name'] or cons_ctx.tenant_name), object_dict['device_cluster_name'], 'interface') if object_dict['bridge_domain_name']: cons_ctx.bridge_domain_dn = _dn( 'fvBD', (object_dict['bridge_domain_tenant_name'] or cons_ctx.tenant_name), object_dict['bridge_domain_name']) if object_dict['service_redirect_policy_name']: cons_ctx.service_redirect_policy_dn = _dn( 'vnsSvcRedirectPol', (object_dict['service_redirect_policy_tenant_name'] or cons_ctx.tenant_name), object_dict['service_redirect_policy_name']) if (cons_ctx.device_cluster_interface_dn and cons_ctx.bridge_domain_dn and cons_ctx.service_redirect_policy_dn): prov_ctx = copy.copy(cons_ctx) prov_ctx.connector_name = 'provider' result.extend([cons_ctx, prov_ctx]) return result
def device_cluster_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=True): if to_aim: result = utils.default_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=to_aim) else: result = utils.default_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=to_aim) if object_dict['encap']: lif = service_graph.DeviceClusterInterface( tenant_name=object_dict['tenant_name'], device_cluster_name=object_dict['name'], name='interface', encap=object_dict['encap']) result.append(lif) else: lif = None nodes = [] for node in object_dict['devices']: if 'name' in node: cdev = service_graph.ConcreteDevice( tenant_name=object_dict['tenant_name'], device_cluster_name=object_dict['name'], name=node['name']) cdev_if = service_graph.ConcreteDeviceInterface( tenant_name=object_dict['tenant_name'], device_cluster_name=object_dict['name'], device_name=node['name'], name='interface') if 'path' in node: cdev_if.path = node['path'] nodes.extend([cdev, cdev_if]) if lif: lif.concrete_interfaces.append(cdev_if.dn) result.extend(nodes) return result
def _default_converter(self, object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=True): return utils.default_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim)
def device_cluster_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=True): if to_aim: result = utils.default_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=to_aim) else: result = utils.default_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=to_aim) if object_dict['encap']: lif = service_graph.DeviceClusterInterface( tenant_name=object_dict['tenant_name'], device_cluster_name=object_dict['name'], name='interface', encap=object_dict['encap']) result.append(lif) else: lif = None nodes = [] for node in object_dict['devices']: if 'name' in node: cdev = service_graph.ConcreteDevice( tenant_name=object_dict['tenant_name'], device_cluster_name=object_dict['name'], name=node['name']) cdev_if = service_graph.ConcreteDeviceInterface( tenant_name=object_dict['tenant_name'], device_cluster_name=object_dict['name'], device_name=node['name'], name='interface') if 'path' in node: cdev_if.path = node['path'] nodes.extend([cdev, cdev_if]) if lif: lif.concrete_interfaces.append(cdev_if.dn) result.extend(nodes) return result
def _default_converter(self, object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim=True): return utils.default_converter(object_dict, otype, helper, source_identity_attributes, destination_identity_attributes, to_aim)