func (m *NetworkManagerImpl) disconnectNetworkFromPolicy(policy *types.NetworkPolicy, targetCSN string) error { target, err := types.VirtualNetworkByName(m.client, targetCSN) if err != nil { return err } err = target.DeleteNetworkPolicy(policy.GetUuid()) if err != nil { return err } return m.client.Update(target) }
func policyAttach(client contrail.ApiClient, network *types.VirtualNetwork, policy *types.NetworkPolicy) error { refs, err := network.GetNetworkPolicyRefs() if err != nil { glog.Errorf("get network policy-refs %s: %v", network.GetName(), err) return err } for _, ref := range refs { if ref.Uuid == policy.GetUuid() { return nil } } network.AddNetworkPolicy(policy, types.VirtualNetworkPolicyType{ Sequence: &types.SequenceType{Major: 10, Minor: 0}, }) err = client.Update(network) if err != nil { glog.Errorf("Update network %s policies: %v", network.GetName(), err) return err } return nil }
func (m *ServiceManagerImpl) attachPolicy(network *types.VirtualNetwork, policy *types.NetworkPolicy) error { refs, err := network.GetNetworkPolicyRefs() if err != nil { glog.Errorf("get network policy-refs %s: %v", network.GetName(), err) return err } for _, ref := range refs { if ref.Uuid == policy.GetUuid() { return nil } } network.AddNetworkPolicy(policy, types.VirtualNetworkPolicyType{ Sequence: &types.SequenceType{10, 0}, }) err = m.client.Update(network) if err != nil { glog.Errorf("Update network %s policies: %v", network.GetName(), err) return err } return nil }