本文整理匯總了Golang中github.com/Juniper/contrail-go-api/types.VirtualNetwork.DeleteNetworkPolicy方法的典型用法代碼示例。如果您正苦於以下問題:Golang VirtualNetwork.DeleteNetworkPolicy方法的具體用法?Golang VirtualNetwork.DeleteNetworkPolicy怎麽用?Golang VirtualNetwork.DeleteNetworkPolicy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Juniper/contrail-go-api/types.VirtualNetwork
的用法示例。
在下文中一共展示了VirtualNetwork.DeleteNetworkPolicy方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DeleteConnections
func (m *ServiceManagerImpl) DeleteConnections(network *types.VirtualNetwork, purgeList []string) error {
if len(purgeList) == 0 {
return nil
}
for _, policyId := range purgeList {
network.DeleteNetworkPolicy(policyId)
}
err := m.client.Update(network)
if err != nil {
return err
}
for _, policyId := range purgeList {
policy, err := types.NetworkPolicyByUuid(m.client, policyId)
if err != nil {
glog.Error(err)
continue
}
refs, err := policy.GetVirtualNetworkBackRefs()
if err != nil {
glog.Error(err)
continue
}
if len(refs) == 0 {
err = m.client.Delete(policy)
if err != nil {
glog.Error(err)
}
}
}
return nil
}
示例2: DeleteConnections
func (m *NetworkManagerImpl) DeleteConnections(network *types.VirtualNetwork, policies map[string]string) error {
for policyID, _ := range policies {
network.DeleteNetworkPolicy(policyID)
}
err := m.client.Update(network)
for policyID, targetName := range policies {
policy, policyErr := types.NetworkPolicyByUuid(m.client, policyID)
if policyErr != nil {
glog.Error(policyErr)
continue
}
networkRefs, policyErr := policy.GetVirtualNetworkBackRefs()
if len(networkRefs) > 1 {
continue
}
if len(networkRefs) == 1 {
if strings.Join(networkRefs[0].To, ":") == targetName {
policyErr = m.disconnectNetworkFromPolicy(policy, targetName)
if policyErr != nil {
glog.Error(policyErr)
continue
}
} else {
continue
}
}
policyErr = m.client.Delete(policy)
if policyErr != nil {
glog.Error(policyErr)
}
}
return err
}
示例3: PurgeStalePolicyRefs
func (m *ServiceManagerImpl) PurgeStalePolicyRefs(network *types.VirtualNetwork, services ServiceIdList,
doDelete func(string, string) bool) error {
purgeList := make([]string, 0)
refs, err := network.GetNetworkPolicyRefs()
if err != nil {
return err
}
for _, ref := range refs {
if len(ref.To) < 3 {
glog.Errorf("unexpected policy id %+v", ref.To)
continue
}
namespace := ref.To[1]
serviceName := ref.To[len(ref.To)-1]
if !services.Contains(namespace, serviceName) && doDelete(namespace, serviceName) {
purgeList = append(purgeList, ref.Uuid)
}
}
if len(purgeList) == 0 {
return nil
}
for _, policyId := range purgeList {
network.DeleteNetworkPolicy(policyId)
}
err = m.client.Update(network)
if err != nil {
return err
}
for _, policyId := range purgeList {
policy, err := types.NetworkPolicyByUuid(m.client, policyId)
if err != nil {
glog.Error(err)
continue
}
refs, err := policy.GetVirtualNetworkBackRefs()
if err != nil {
glog.Error(err)
}
if len(refs) == 0 {
err = m.client.Delete(policy)
if err != nil {
glog.Error(err)
}
}
}
return nil
}
示例4: policyDetach
func policyDetach(client contrail.ApiClient, network *types.VirtualNetwork, policyName string) 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 strings.Join(ref.To, ":") == policyName {
network.DeleteNetworkPolicy(ref.Uuid)
err := client.Update(network)
if err != nil {
glog.Errorf("Update network %s policies: %v", network.GetName(), err)
}
return err
}
}
return nil
}
示例5: detachPolicy
func (m *ServiceManagerImpl) detachPolicy(network *types.VirtualNetwork, policyName string) 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 strings.Join(ref.To, ":") == policyName {
network.DeleteNetworkPolicy(ref.Uuid)
err := m.client.Update(network)
if err != nil {
glog.Errorf("Update network %s policies: %v", network.GetName(), err)
}
return err
}
}
return nil
}