go.ligato.io/vpp-agent/v3@v3.5.0/examples/kvscheduler/mock_plugins/scenario/interface_recreation.go (about) 1 // Copyright (c) 2019 Cisco and/or its affiliates. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at: 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package scenario 16 17 import ( 18 "context" 19 "log" 20 21 "go.ligato.io/vpp-agent/v3/client" 22 interfaces "go.ligato.io/vpp-agent/v3/examples/kvscheduler/mock_plugins/ifplugin/model" 23 ) 24 25 // InterfaceRecreation presents a scenario, in which the interface type is changed, 26 // which cannot be applied incrementally via Update, but requires the interface 27 // to be fully re-created, together with all the objects that depend on it. 28 func InterfaceRecreation() { 29 c := client.LocalClient 30 listKnownModels(c) 31 32 printMessage( 33 "Resync config", 34 " - TAP interfaces tap1 configured inside a bridge-domain", 35 " - FIB entry defined to forward traffic for a certain", 36 " MAC address via tap1", 37 ) 38 err := c.ResyncConfig( 39 tap1, bd2, fib3, 40 ) 41 if err != nil { 42 log.Println(err) 43 } 44 informAboutGraphURL(0, true, true) 45 46 printMessage( 47 "Change config", 48 " - the TAP interface tap1 is requested to be turned into loopback", 49 " -> the change requires the interface to be fully re-created", 50 " -> before the obsolete tap1 is un-configured, the associated FIB", 51 " entry and the binding between the interface and BD must be deleted", 52 " first", 53 " -> once tap1 is re-created as loopback (the name becomes confusing),", 54 " it is then re-added back into the bridge domain and at last", 55 " the FIB entry is restored", 56 ) 57 tap1.Type = interfaces.Interface_LOOPBACK 58 59 req := c.ChangeRequest() 60 req.Update(tap1) 61 if err := req.Send(context.Background()); err != nil { 62 log.Println(err) 63 } 64 informAboutGraphURL(1, false, true) 65 }