go.ligato.io/vpp-agent/v3@v3.5.0/examples/kvscheduler/mock_plugins/scenario/pending_after_change.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 ) 23 24 // PendingAfterChange presents a scenario, in which originally configured objects 25 // must be deleted and set as PENDING, because some another object, which they 26 // depend on, was set to be un-configured by an update transaction. 27 func PendingAfterChange() { 28 c := client.LocalClient 29 listKnownModels(c) 30 31 printMessage( 32 "Resync config", 33 " - 2 TAP interfaces (tap1, tap2) and 1 loopback are configured", 34 " and added into a bridge-domain", 35 " - FIB entry is defined to forward traffic for a certain", 36 " MAC address via tap2", 37 ) 38 err := c.ResyncConfig( 39 tap1, tap2, loopback1, bd1, fib2, 40 ) 41 if err != nil { 42 log.Println(err) 43 } 44 informAboutGraphURL(0, true, true) 45 46 printMessage( 47 "Change config", 48 " - the loopback interface is put DOWN", 49 " (no further effect, remains in the bridge-domain)", 50 " - tap1 MAC address is changed", 51 " -> the changed is performed by Update, re-creation is not needed", 52 " - tap2 interface is removed", 53 " -> the associated FIB that depends on tap2 to be in the bridge", 54 " domain is un-configured *first*, and goes into the PENDING", 55 " state", 56 " -> the interface is correctly removed from BD *before* it is", 57 " un-configured", 58 " -> the binding between BD and the TAP becomes pending", 59 ) 60 loopback1.Enabled = false 61 tap1.PhysAddress = "11:22:33:44:55:66" 62 63 req := c.ChangeRequest() 64 req.Update(tap1, loopback1) 65 req.Delete(tap2) 66 if err := req.Send(context.Background()); err != nil { 67 log.Println(err) 68 } 69 informAboutGraphURL(1, false, true) 70 }