本文整理汇总了Golang中github.com/contiv/netplugin/netplugin/plugin.NetPlugin.DeleteServiceLB方法的典型用法代码示例。如果您正苦于以下问题:Golang NetPlugin.DeleteServiceLB方法的具体用法?Golang NetPlugin.DeleteServiceLB怎么用?Golang NetPlugin.DeleteServiceLB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/contiv/netplugin/netplugin/plugin.NetPlugin
的用法示例。
在下文中一共展示了NetPlugin.DeleteServiceLB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: processServiceLBEvent
func processServiceLBEvent(netPlugin *plugin.NetPlugin, opts cliOpts, svcLBCfg *mastercfg.CfgServiceLBState,
isDelete bool) error {
var err error
portSpecList := []core.PortSpec{}
portSpec := core.PortSpec{}
netPlugin.Lock()
defer func() { netPlugin.Unlock() }()
serviceID := svcLBCfg.ID
log.Infof("Recevied Process Service load balancer event {%v}", svcLBCfg)
//create portspect list from state.
//Ports format: servicePort:ProviderPort:Protocol
for _, port := range svcLBCfg.Ports {
portInfo := strings.Split(port, ":")
if len(portInfo) != 3 {
return errors.New("Invalid Port Format")
}
svcPort := portInfo[0]
provPort := portInfo[1]
portSpec.Protocol = portInfo[2]
sPort, _ := strconv.ParseUint(svcPort, 10, 16)
portSpec.SvcPort = uint16(sPort)
pPort, _ := strconv.ParseUint(provPort, 10, 16)
portSpec.ProvPort = uint16(pPort)
portSpecList = append(portSpecList, portSpec)
}
spec := &core.ServiceSpec{
IPAddress: svcLBCfg.IPAddress,
Ports: portSpecList,
}
operStr := ""
if isDelete {
err = netPlugin.DeleteServiceLB(serviceID, spec)
operStr = "delete"
} else {
err = netPlugin.AddServiceLB(serviceID, spec)
operStr = "create"
}
if err != nil {
log.Errorf("Service Load Balancer %s failed.Error:%s", operStr, err)
return err
}
log.Infof("Service Load Balancer %s succeeded", operStr)
return nil
}