3 # Copyright (c) 2016 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 parser = argparse.ArgumentParser()
20 parser.add_argument("ip", help="CIMC IP address")
21 parser.add_argument("-u", "--username", help="CIMC username (admin)",
23 parser.add_argument("-p", "--password", help="CIMC password (cisco123)",
25 parser.add_argument("-d", "--debug", help="Enable debugging", action="count",
28 parser.add_argument("-i", "--initialize",
29 help="Initialize args.ip: Power-Off, reset BIOS defaults, Enable console redir, get LOM MAC addr",
31 parser.add_argument("-s", "--set",
32 help="Set specific BIOS settings", action='append')
33 parser.add_argument("--wipe", help="Delete all virtual drives",
35 parser.add_argument("-r", "--raid", help="Create RAID array",
37 parser.add_argument("-rl", "--raid-level", help="RAID level", default='10')
38 parser.add_argument("-rs", "--raid-size", help="RAID size", default=3*571250)
39 parser.add_argument("-rd", "--raid-disks",
40 help="RAID disks ('[1,2][3,4][5,6]')",
41 default='[1,2][3,4][5,6]')
42 parser.add_argument("-pxe", "--boot-pxe", help="Reboot using PXE",
44 parser.add_argument("-hdd", "--boot-hdd", help="Boot using HDD on next boot",
46 parser.add_argument("-poff", "--power-off", help="Power Off",
48 parser.add_argument("-pon", "--power-on", help="Power On", action='store_true')
49 parser.add_argument("-m", "--mac-table",
50 help="Show interface MAC address table",
53 args = parser.parse_args()
55 cookie = cimclib.login(args.ip, args.username, args.password)
58 cimclib.deleteAllVirtualDrives(args.ip, cookie, args.debug)
61 cimclib.createRaid(args.ip, cookie, "raid-virl", args.raid_level, args.raid_size, args.raid_disks, args.debug)
64 cimclib.powerOff(args.ip, cookie)
65 cimclib.restoreBiosDefaultSettings(args.ip, cookie, args.debug)
66 cimclib.enableConsoleRedir(args.ip, cookie, args.debug)
67 cimclib.powerOn(args.ip, cookie, args.debug)
68 cimclib.bootIntoUefi(args.ip, cookie, args.debug)
69 lom_mac = cimclib.getLOMMacAddress(args.ip, cookie, args.debug)
70 print "Host {} LOM MAC address: {}".format(args.ip, lom_mac)
73 cimclib.setBiosSettings(args.ip, cookie, args.set, args.debug)
76 cimclib.bootPXE(args.ip, cookie, args.debug)
79 cimclib.bootHDDPXE(args.ip, cookie, args.debug)
82 cimclib.powerOff(args.ip, cookie, args.debug)
85 cimclib.powerOn(args.ip, cookie, args.debug)
88 maclist = cimclib.getMacAddresses(args.ip, cookie, args.debug)
90 for k in sorted(maclist.keys()):
92 for p in sorted(maclist[k].keys()):
93 print " {} - {}".format(p, maclist[k][p])
95 cimclib.logout(args.ip, cookie)