go.ligato.io/vpp-agent/v3@v3.5.0/examples/kvscheduler/mock_plugins/scenario/fixed_invalid_config.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 // InvalidConfigFixedWithUpdate presents a scenario, in which an interface is 25 // first defined with an invalid MAC address and therefore remains in the INVALID 26 // state. All the objects that depend on it must remain PENDING. 27 // The next update, however, will supply an updated interface configuration 28 // where the MAC address is fixed. The interface and all the associated pending 29 // objects are then successfully created. 30 func InvalidConfigFixedWithUpdate() { 31 c := client.LocalClient 32 listKnownModels(c) 33 34 printMessage( 35 "Resync config", 36 " - requested config contains:", 37 " -> 2 TAP interfaces (tap1, tap2) and one loopback inside", 38 " a bridge-domain", 39 " -> FIB entry forwarding traffic for a certain MAC address", 40 " via tap2", 41 " - the issue is that tap2 has invalid MAC address defined, which", 42 " will cause it to remain in the INVALID state after the transaction", 43 " - with tap2 not configured, the binding between the BD and tap2", 44 " will remain pending and so will the FIB entry", 45 ) 46 err := c.ResyncConfig( 47 tap1, tap2Invalid, loopback1, bd1, fib2, 48 ) 49 if err != nil { 50 log.Println(err) 51 } 52 informAboutGraphURL(0, true, true) 53 54 printMessage( 55 "Change config", 56 " - update tap2 to contain valid MAC address", 57 " - tap2 will now get successfully configured and added into", 58 " the bridge domain together with the associated FIB entry which", 59 " was pending", 60 ) 61 62 req := c.ChangeRequest() 63 req.Update(tap2) 64 if err := req.Send(context.Background()); err != nil { 65 log.Println(err) 66 } 67 informAboutGraphURL(1, false, true) 68 }