|
| 1 | +# fabric_create.py |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +Create or update one or more fabrics. |
| 6 | + |
| 7 | +## Example configuration file |
| 8 | + |
| 9 | +Note, for a description of all configuration parameters for all fabric types |
| 10 | +see [dcnm_fabric](https://allenrobel.github.io/dcnm-docpoc/modules/dcnm_fabric/). |
| 11 | + |
| 12 | +``` yaml title="config/config_fabric_create.yaml" |
| 13 | +--- |
| 14 | +config: |
| 15 | + - FABRIC_NAME: MyFabric |
| 16 | + FABRIC_TYPE: VXLAN_EVPN |
| 17 | + BGP_AS: 65002 |
| 18 | + REPLICATION_MODE: Ingress |
| 19 | + VRF_VLAN_RANGE: 2000-2299 |
| 20 | + - FABRIC_NAME: YourFabric |
| 21 | + FABRIC_TYPE: LAN_Classic |
| 22 | + BGP_AS: 65003 |
| 23 | +``` |
| 24 | +
|
| 25 | +## Example Usage |
| 26 | +
|
| 27 | +The example below uses environment variables for credentials, so requires |
| 28 | +only the `--config` argument. See [Running the Example Scripts] |
| 29 | +for details around specifying credentials from the command line, from |
| 30 | +environment variables, from Ansible Vault, or a combination of these |
| 31 | +credentials sources. |
| 32 | + |
| 33 | +[Running the Example Scripts]: ../setup/running-the-example-scripts.md |
| 34 | + |
| 35 | +``` bash |
| 36 | +export ND_DOMAIN=local |
| 37 | +export ND_IP4=10.1.1.1 |
| 38 | +export ND_PASSWORD=MySecret |
| 39 | +export ND_USERNAME=admin |
| 40 | +./fabric_create.py --config config/config_fabric_create.yaml |
| 41 | +# output not shown |
| 42 | +``` |
| 43 | + |
| 44 | +## Example output |
| 45 | + |
| 46 | +### Fabrics created successfully |
| 47 | + |
| 48 | +``` bash title="Fabrics create success" |
| 49 | +(.venv) AROBEL-M-G793% ./fabric_create.py --config prod/config_fabric_create.yaml |
| 50 | +{ |
| 51 | + "changed": true, |
| 52 | + "diff": [ |
| 53 | + { |
| 54 | + "BGP_AS": 65002, |
| 55 | + "FABRIC_NAME": "MyFabric", |
| 56 | + "REPLICATION_MODE": "Ingress", |
| 57 | + "VRF_VLAN_RANGE": "2000-2299", |
| 58 | + "sequence_number": 1 |
| 59 | + }, |
| 60 | + { |
| 61 | + "FABRIC_NAME": "YourFabric", |
| 62 | + "sequence_number": 2 |
| 63 | + } |
| 64 | + ], |
| 65 | + "failed": false, |
| 66 | + "metadata": [ |
| 67 | + { |
| 68 | + "action": "fabric_create", |
| 69 | + "check_mode": false, |
| 70 | + "sequence_number": 1, |
| 71 | + "state": "merged" |
| 72 | + }, |
| 73 | + { |
| 74 | + "action": "fabric_create", |
| 75 | + "check_mode": false, |
| 76 | + "sequence_number": 2, |
| 77 | + "state": "merged" |
| 78 | + } |
| 79 | + ], |
| 80 | + "response": [ |
| 81 | + { |
| 82 | + "DATA": { |
| 83 | + "removed": "for brevity" |
| 84 | + }, |
| 85 | + "MESSAGE": "OK", |
| 86 | + "METHOD": "POST", |
| 87 | + "REQUEST_PATH": "https://10.1.1.1/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/MyFabric/Easy_Fabric", |
| 88 | + "RETURN_CODE": 200, |
| 89 | + "sequence_number": 1 |
| 90 | + }, |
| 91 | + { |
| 92 | + "DATA": { |
| 93 | + "removed": "for brevity" |
| 94 | + }, |
| 95 | + "MESSAGE": "OK", |
| 96 | + "METHOD": "POST", |
| 97 | + "REQUEST_PATH": "https://10.1.1.1/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/YourFabric/LAN_Classic", |
| 98 | + "RETURN_CODE": 200, |
| 99 | + "sequence_number": 2 |
| 100 | + } |
| 101 | + ], |
| 102 | + "result": [ |
| 103 | + { |
| 104 | + "changed": true, |
| 105 | + "sequence_number": 1, |
| 106 | + "success": true |
| 107 | + }, |
| 108 | + { |
| 109 | + "changed": true, |
| 110 | + "sequence_number": 2, |
| 111 | + "success": true |
| 112 | + } |
| 113 | + ] |
| 114 | +} |
| 115 | +(.venv) AROBEL-M-G793% |
| 116 | +``` |
| 117 | + |
| 118 | +### Fabrics already exist, and no changes are required |
| 119 | + |
| 120 | +``` bash title="Fabrics do not require changes" |
| 121 | +(.venv) AROBEL-M-G793% ./fabric_create.py --ansible-vault $HOME/.ansible/vault --config prod/config_fabric_create.yaml |
| 122 | +Vault password: |
| 123 | +{ |
| 124 | + "changed": false, |
| 125 | + "diff": [ |
| 126 | + { |
| 127 | + "sequence_number": 1 |
| 128 | + } |
| 129 | + ], |
| 130 | + "failed": false, |
| 131 | + "metadata": [ |
| 132 | + { |
| 133 | + "action": "fabric_update", |
| 134 | + "check_mode": false, |
| 135 | + "sequence_number": 1, |
| 136 | + "state": "merged" |
| 137 | + } |
| 138 | + ], |
| 139 | + "response": [ |
| 140 | + { |
| 141 | + "MESSAGE": "No fabrics to update for merged state.", |
| 142 | + "RETURN_CODE": 200, |
| 143 | + "sequence_number": 1 |
| 144 | + } |
| 145 | + ], |
| 146 | + "result": [ |
| 147 | + { |
| 148 | + "changed": false, |
| 149 | + "sequence_number": 1, |
| 150 | + "success": true |
| 151 | + } |
| 152 | + ] |
| 153 | +} |
| 154 | +(.venv) AROBEL-M-G793% |
| 155 | +``` |
| 156 | + |
| 157 | +### Fabric already exists, but requires changes to align with user's config |
| 158 | + |
| 159 | +Below, we have changed ``REPLICATION_MODE`` and `BGP_AS` for fabric `MyFabric` |
| 160 | +Since `SITE_ID`, by default, is assigned the value of `BGP_AS`, we need to change |
| 161 | +it as well if we want it to be in sync with `BGP_AS` |
| 162 | + |
| 163 | +``` yaml title="config/config_fabric_create.yaml" |
| 164 | +--- |
| 165 | +config: |
| 166 | + - FABRIC_NAME: MyFabric |
| 167 | + FABRIC_TYPE: VXLAN_EVPN |
| 168 | + BGP_AS: 65004 |
| 169 | + SITE_ID: 65004 |
| 170 | + REPLICATION_MODE: Multicast |
| 171 | + VRF_VLAN_RANGE: 2000-2299 |
| 172 | + - FABRIC_NAME: YourFabric |
| 173 | + FABRIC_TYPE: LAN_Classic |
| 174 | + BGP_AS: 65003 |
| 175 | +``` |
| 176 | + |
| 177 | +``` bash title="User config changed some MyFabric parameters" |
| 178 | +{ |
| 179 | + "changed": true, |
| 180 | + "diff": [ |
| 181 | + { |
| 182 | + "BGP_AS": "65004", |
| 183 | + "FABRIC_NAME": "MyFabric", |
| 184 | + "REPLICATION_MODE": "Multicast", |
| 185 | + "SITE_ID": "65004", |
| 186 | + "sequence_number": 1 |
| 187 | + }, |
| 188 | + { |
| 189 | + "sequence_number": 2 |
| 190 | + }, |
| 191 | + { |
| 192 | + "sequence_number": 3 |
| 193 | + } |
| 194 | + ], |
| 195 | + "failed": false, |
| 196 | + "metadata": [ |
| 197 | + { |
| 198 | + "action": "fabric_update", |
| 199 | + "check_mode": false, |
| 200 | + "sequence_number": 1, |
| 201 | + "state": "merged" |
| 202 | + }, |
| 203 | + { |
| 204 | + "action": "config_save", |
| 205 | + "check_mode": false, |
| 206 | + "sequence_number": 2, |
| 207 | + "state": "merged" |
| 208 | + }, |
| 209 | + { |
| 210 | + "action": "config_deploy", |
| 211 | + "check_mode": false, |
| 212 | + "sequence_number": 3, |
| 213 | + "state": "merged" |
| 214 | + } |
| 215 | + ], |
| 216 | + "response": [ |
| 217 | + { |
| 218 | + "DATA": { |
| 219 | + "removed": "for_brevity" |
| 220 | + }, |
| 221 | + "MESSAGE": "OK", |
| 222 | + "METHOD": "PUT", |
| 223 | + "REQUEST_PATH": "https://10.1.1.1/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/MyFabric/Easy_Fabric", |
| 224 | + "RETURN_CODE": 200, |
| 225 | + "sequence_number": 1 |
| 226 | + }, |
| 227 | + { |
| 228 | + "MESSAGE": "Fabric MyFabric DEPLOY is False or None. Skipping config-save.", |
| 229 | + "RETURN_CODE": 200, |
| 230 | + "sequence_number": 2 |
| 231 | + }, |
| 232 | + { |
| 233 | + "MESSAGE": "FabricConfigDeploy._can_fabric_be_deployed: Fabric MyFabric DEPLOY is False or None. Skipping config-deploy.", |
| 234 | + "RETURN_CODE": 200, |
| 235 | + "sequence_number": 3 |
| 236 | + } |
| 237 | + ], |
| 238 | + "result": [ |
| 239 | + { |
| 240 | + "changed": true, |
| 241 | + "sequence_number": 1, |
| 242 | + "success": true |
| 243 | + }, |
| 244 | + { |
| 245 | + "changed": true, |
| 246 | + "sequence_number": 2, |
| 247 | + "success": true |
| 248 | + }, |
| 249 | + { |
| 250 | + "changed": true, |
| 251 | + "sequence_number": 3, |
| 252 | + "success": true |
| 253 | + } |
| 254 | + ] |
| 255 | +} |
| 256 | +``` |
0 commit comments