pass
class BMC(object):
- def __init__(self, host, user, passwd, log_path=None):
+ def __init__(self, host, user, passwd, priv_level='ADMINISTRATOR', log_path=None):
self._host = host
self._user = user
self._passwd = passwd
+ self._priv_level = priv_level
if log_path:
self._log_path = log_path
else:
def get_passwd(self):
return self._passwd
+ def get_priv_level(self):
+ return self._priv_level
+
def reset(self):
logging.info('Reset BMC of %s: %s', self.get_host_name(), self.get_host())
return ''.join('{}'.format(c.decode('hex')) for c in hex_string)
def _execute_ipmitool_command(self, ipmi_command):
- command = 'ipmitool -I lanplus -H {} -U {} -P {} {}'.format(self._host, self._user, self._passwd, ipmi_command)
+ command = 'ipmitool -I lanplus -H {} -U {} -P {} -L {} {}'.format(self._host, self._user, self._passwd, self._priv_level, ipmi_command)
p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = p.communicate()
def _open_console(self):
logging.debug('Open SOL console (log in %s)', self._log_path)
- expect_session = pexpect.spawn('ipmitool -I lanplus -H {} -U {} -P {} sol deactivate'.format(self._host, self._user, self._passwd))
+ expect_session = pexpect.spawn('ipmitool -I lanplus -H {} -U {} -P {} -L {} sol deactivate'.format(self._host, self._user, self._passwd, self._priv_level))
expect_session.expect(pexpect.EOF)
logfile = open(self._log_path, 'ab')
- expect_session = pexpect.spawn('ipmitool -I lanplus -H {} -U {} -P {} sol activate'.format(self._host, self._user, self._passwd), timeout=None, logfile=logfile)
+ expect_session = pexpect.spawn('ipmitool -I lanplus -H {} -U {} -P {} -L {} sol activate'.format(self._host, self._user, self._passwd, self._priv_level), timeout=None, logfile=logfile)
return expect_session
pass
class HW17(BMC):
- def __init__(self, host, user, passwd, log_path=None):
- super(HW17, self).__init__(host, user, passwd, log_path)
+ def __init__(self, host, user, passwd, priv_level='ADMINISTRATOR', log_path=None):
+ super(HW17, self).__init__(host, user, passwd, priv_level, log_path)
def attach_virtual_cd(self, nfs_host, nfs_mount, boot_iso_filename):
for _ in range(2):
pass
class OE19(OR18):
- def __init__(self, host, user, passwd, log_path=None):
- super(OE19, self).__init__(host, user, passwd, log_path)
+ def __init__(self, host, user, passwd, priv_level='ADMINISTRATOR', log_path=None):
+ super(OE19, self).__init__(host, user, passwd, priv_level, log_path)
def _set_boot_from_virtual_media(self):
logging.debug('Set boot from floppy (%s), and boot after that', self._host)
pass
class OR18(BMC):
- def __init__(self, host, user, passwd, log_path=None):
- super(OR18, self).__init__(host, user, passwd, log_path)
+ def __init__(self, host, user, passwd, priv_level='ADMINISTRATOR', log_path=None):
+ super(OR18, self).__init__(host, user, passwd, priv_level, log_path)
def _clear_ris_configuration(self):
# Clear RIS configuration
pass
class RM18(OR18):
- def __init__(self, host, user, passwd, log_path=None):
- super(RM18, self).__init__(host, user, passwd, log_path)
+ def __init__(self, host, user, passwd, priv_level='ADMINISTRATOR', log_path=None):
+ super(RM18, self).__init__(host, user, passwd, priv_level, log_path)
def _set_boot_from_virtual_media(self):
logging.debug('Set boot from floppy (%s), and boot after that', self._host)
pass
class CatFile(object):
- def __init__(self, bmc_host, bmc_user, bmc_password, login_user, login_password):
+ def __init__(self, bmc_host, bmc_user, bmc_password, bmc_priv_level='ADMINISTRATOR', login_user, login_password):
self._host = bmc_host
self._user = bmc_user
self._password = bmc_password
+ self._priv_level = bmc_priv_level
self._sol = None
self._login_user = login_user
logging.info('Open SOL console')
logging.debug('deactivate sol')
- expect_session = pexpect.spawn('ipmitool -I lanplus -H {} -U {} -P {} sol deactivate'.format(self._host, self._user, self._password))
+ expect_session = pexpect.spawn('ipmitool -I lanplus -H {} -U {} -P {} -L {} sol deactivate'.format(self._host, self._user, self._password, self._priv_level))
expect_session.expect(pexpect.EOF)
logging.debug('activate sol, output will go to %s', log)
- self._sol = pexpect.spawn('ipmitool -I lanplus -H {} -U {} -P {} sol activate'.format(self._host, self._user, self._password), timeout=None)
+ self._sol = pexpect.spawn('ipmitool -I lanplus -H {} -U {} -P {} -L {} sol activate'.format(self._host, self._user, self._password, self._priv_level), timeout=None)
logfile = open(log, 'wb')
self._sol.logfile_read = logfile
self._sol.terminate()
logging.debug('deactivate sol')
- session = pexpect.spawn('ipmitool -I lanplus -H {} -U {} -P {} sol deactivate'.format(self._host, self._user, self._password))
+ session = pexpect.spawn('ipmitool -I lanplus -H {} -U {} -P {} -L {} sol deactivate'.format(self._host, self._user, self._password, self._priv_level))
session.expect(pexpect.EOF)
def _expect_cmd_prompt(self):
parser.add_argument('-H', '--bmc_host', required=True, help='BMC host')
parser.add_argument('-U', '--bmc_user', required=True, help='BMC user')
parser.add_argument('-P', '--bmc_password', required=True, help='BMC user password')
+ parser.add_argument('-L', '--bmc_priv_level', required=False, default='ADMINISTRATOR', help='BMC user privilege level')
parser.add_argument('-u', '--user', required=True, help='Login user')
parser.add_argument('-p', '--password', required=True, help='Login user password')
parser.add_argument('-f', '--file', required=True, help='File path to cat')
logging.basicConfig(level=logging.DEBUG)
- cat_file = CatFile(args.bmc_host, args.bmc_user, args.bmc_password, args.user, args.password)
+ cat_file = CatFile(args.bmc_host, args.bmc_user, args.bmc_password, args.user, bmc_priv_level, args.password)
cat_file.cat(args.file, args.output_file, args.password)
if __name__ == "__main__":
bmc_mod_name = 'remoteinstaller.installer.bmc_management.{}'.format(hw_data['product_family'].lower())
bmc_mod = importlib.import_module(bmc_mod_name)
bmc_class = getattr(bmc_mod, hw_data['product_family'])
- bmc = bmc_class(host, user, passwd, bmc_log_path)
+ bmc = bmc_class(host, user, passwd, priv_level, bmc_log_path)
bmc.set_host_name(hw)
return bmc
bmc_host = bmc.get_host()
bmc_user = bmc.get_user()
bmc_passwd = bmc.get_passwd()
-
+ bmc_priv_level = bmc.get_priv_level()
+
log_file = '{}/cat_bootstrap.log'.format(self._logdir)
try:
- cat_file = CatFile(bmc_host, bmc_user, bmc_passwd, admin_user, admin_passwd)
+ cat_file = CatFile(bmc_host, bmc_user, bmc_passwd, bmc_priv_level, admin_user, admin_passwd)
cat_file.cat('/srv/deployment/log/bootstrap.log', log_file)
except CatFileException as ex:
logging.info('Could not cat file from console: %s', str(ex))
- cat_file = CatFile(bmc_host, bmc_user, bmc_passwd, 'root', 'root')
+ cat_file = CatFile(bmc_host, bmc_user, bmc_passwd, bmc_priv_level, 'root', 'root')
cat_file.cat('/srv/deployment/log/bootstrap.log', log_file)
def get_logs(self, admin_passwd):