// 2020 Rackspace, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"): you may // not use this file except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. package shutdown import ( "github.com/jokelyo/argparse" "github.rackspace.com/DCM/gomigrate/core" ) const ( argDevice = "device" argFullConfig = "full-config" argLiveConfig = "live-config" argMgmtIP = "mgmt-ip" argOutputFile = "output" argSkipBackup = "skip-backup" argSkipRevert = "skip-revert" argTest = "test" argUpdate = "update" argVerifyOnly = "verify-only" ) var ( args = map[string]interface{}{ argDevice: nil, argSkipBackup: nil, argSkipRevert: nil, } ) // Plugin function will return a argparse.Command type back to the parent parser // nolint:typecheck func Plugin(p *core.Parser) core.Plugin { // Create a argument for the DCX Translations logic cmd := p.NewCommand("shutdown", "Prep netdevice for shutdown.") args[argDevice] = cmd.Int("d", argDevice, &argparse.Options{Required: true, Help: "device core ID"}) args[argFullConfig] = cmd.Flag("f", argFullConfig, &argparse.Options{Help: "return full netdevice config"}) args[argLiveConfig] = cmd.Flag("l", argLiveConfig, &argparse.Options{Help: "use live config rather than torq backup"}) args[argMgmtIP] = cmd.String("m", argMgmtIP, &argparse.Options{Help: "use this mgmt IP for device access"}) args[argOutputFile] = cmd.String("o", argOutputFile, &argparse.Options{Help: "output full config to filename (default: -config.txt)"}) args[argSkipBackup] = cmd.Flag("b", argSkipBackup, &argparse.Options{Help: "skip backup of netdevice config"}) args[argSkipRevert] = cmd.Flag("r", argSkipRevert, &argparse.Options{Help: "skip revert of netdevice config"}) args[argTest] = cmd.Flag("t", argTest, &argparse.Options{Help: "print payload and exit"}) args[argUpdate] = cmd.Flag("u", argUpdate, &argparse.Options{Help: "update startup config on netdevice"}) args[argVerifyOnly] = cmd.Flag("v", argVerifyOnly, &argparse.Options{Help: "only verify the netdevice config changes"}) return core.Plugin{CMD: cmd, Func: pluginFunc} }