# Managing switches Managing Switches is an essential part of MetalSoft. MetalSoft will automatically configure switch ports depending on the intent expressed by the user in the infrastructure editor. For that to happen the switches must be added in the MetalSoft database. The process of adding the switches to the MetalSoft database can be either automatic via ZTP or manual via the UI or the CLI. This guide describes the process of manually adding switches to the database via the CLI. To get details on how to enable ZTP on the switches consult [Registering switches using ZTP](/content/overview/installation/registering_switches_using_ztp.md). > Note that via this CLI-based process the system only touches the ports towards the servers and the SVIs that will act as gateways but will not configure BGP sessions towards the spine network or routing tables. Those must be created manually configured on the switches prior or after adding the switches in the database but before provisioning on those switches. If the BGP session configuration is needed please use the ZTP process. ## Getting switch details using the CLI To get some basic details about a switch use the following command. You can use both the switch id or the switch label (which is usually the same as the switch hostname). ``` metalcloud-cli switch get -id sw1-env2 +-------------+-------------------+ | KEY | VALUE | +-------------+-------------------+ | ID | 4 | | HOSTNAME | sw1-env2 | | DATACENTER | us02-chi-qts01-dc | | DRIVER | os_10 | | PROVISIONER | evpnvxlanl2 | | MGMT IP | 10.0.5.6 | +-------------+-------------------+ ``` To get the switch configuration use the yaml format: ``` metalcloud-cli switch get -id sw1-env2 --format yaml --raw id: 4 identifierString: sw1-env2 datacenterName: us02-chi-qts01-dc provisionerType: evpnvxlanl2 provisionerPosition: leaf driver: os_10 managementUsername: admin managementAddress: 1.0.5.6 managementPort: 22 managementProtocol: ssh managementMACAddress: "00:00:00:00:00:00" primaryWANIPv4SubnetPrefixSize: 22 primaryWANIPv6SubnetPoolID: 3 primarySANSubnetPrefixSize: 21 quarantineSubnetStart: 1.168.254.0 quarantineSubnetEnd: 1.168.254.255 quarantineSubnetPrefixSize: 24 quarantineSubnetGateway: 1.168.254.1 description: OS10 Enterprise. OS Version requiresOSInstall: false isBorderDevice: false isStorageSwitch: true networkTypesAllowed: - wan - quarantine - san managementPassword: "" primaryWANIPv6SubnetPool: "" primaryWANIPv6SubnetPrefixSize: 0 ``` ## Adding a switch using the CLI To add a switch to the database using the CLI create a configuration file `leaf_switch.yaml`: ```yaml identifierString: iad1-bm-sw-01 datacenterName: test-datacenter provisionerType: evpnvxlanl2 provisionerPosition: leaf driver: junos18 managementUsername: metalsoft managementAddress: 10.72.0.61 managementPort: 22 managementProtocol: ssh managementMACAddress: "00:00:00:00:00:00" primaryWANIPv4SubnetPool: 192.168.253.0 primaryWANIPv4SubnetPrefixSize: 24 primaryWANIPv6SubnetPoolID: 3 primaryWANIPv6SubnetCIDR: fd9f:1a77:a3a0:0000:0000:0000:0000:0000/48 primarySANSubnetPool: 100.64.0.1 primarySANSubnetPrefixSize: 21 quarantineSubnetStart: 10.73.254.0 quarantineSubnetEnd: 10.73.254.63 quarantineSubnetPrefixSize: 26 quarantineSubnetGateway: 10.73.254.2 requiresOSInstall: false isBorderDevice: true isStorageSwitch: false networkTypesAllowed: - wan - lan - quarantine managementPassword: "" primaryWANIPv6SubnetPool: "" primaryWANIPv6SubnetPrefixSize: 0 ``` Add the new switch by running: ```bash $ metalcloud-cli switch create --raw-config leaf_switch.yaml --format yaml ``` Notes on parameters: * `management*`: These properties must be set to allow MetalSoft access to the respective switch. * `provisionerType`: can be one of `evpnvxlanl2`, `vlan`, `vpls`,`lan`. * `isBorderDevice`: If set to true this switch can be used as part of an external connection * `isStorageSwitch`: If set to true this switch can be used as part of SAN networks. * `quarantineSubnet*`: These properties only apply if the legacy provisioning mode (PXE) is required. These define which subnet to use for the transient provisioning network. Refer to [deploying metalsoft to support legacy deployments](/content/overview/installation/deploying_metalsoft_to_support_legacy_deployments) for more information. * `primaryWANIP*`: These properties control the default WAN subnet that will be used. If one does not exist it will be created upon the creation of the switch. * `primarySAN*`: These properties control the default SAN subnet that will be used. If one does not exist it will be created upon the creation of the switch. ## Listing switches using the CLI ``` metalcloud-cli switch list +-------+------------+-------------------+-------+-------------+----------+ | ID | IDENTIFIER | DATACENTER | DRIVER| PROVISIONER | MGMT IP | +-------+------------+-------------------+-------+-------------+----------+ | 4 | sw1-env2 | us02-chi-qts01-dc | os_10 | evpnvxlanl2 | 10.0.5.6 | | 5 | sw2-env2 | us02-chi-qts01-dc | os_10 | evpnvxlanl2 | 10.0.5.7 | +-------+------------+-------------------+-------+-------------+----------+ Total: 2 Switches ``` ## Editing switch configurations using the CLI 1. Retrieve the current switch configuration and place it in a file ``` metalcloud-cli switch get -id 4 --format yaml --raw > switch.yaml ``` 2. Edit the configuration file `switch.yaml` 3. Reconfigure the switch ``` metalcloud-cli switch edit --raw-config switch.yaml --format yaml ``` ## Deleting a switch using the CLI 1. If the switch is part of a pair first delete the pair. Refer to [managing switch pairs](/content/configuration/network/managing_switch_pairs) for instructions. 2. Delete the switch ``` metalcloud-cli switch delete --id 4 ``` ## Creating switch pairs To enable multi-chassis link aggregation on the switches, switch pairs must be created. Refer to [managing switch pairs](/content/configuration/network/managing_switch_pairs) for more details. ## Operating without switches MetalSoft can operate in mode where a "dummy" switch driver is used instead of a real one. This mode is sometimes called "BigLAN" mode as it expects everything to be part of the same pre-created LAN network. Refer to [deploying Metalsoft without switches](/content/overview/installation/deploying_metalsoft_without_switches) for more information.