When invoking the ipmitool command, if an IPMI privilege level is not
specified, the default is 'ADMINISTRATOR'. In installations where the
IPMI user does not have this privilege level, this will cause IPMI
requests to fail. This change updates the remote installer's
invocations of ipmitool to pass a configured privilege level. If a
privilege level is not supplied in the host configuration, the code
defaults to 'ADMINISTRATOR' to mirror the ipmitool behavior.
Previous changes added this functionality to the config-manager
components; this change brings the remote installer into line
with those components.
signed-off-by: dave kormann <davek@research.att.com>
Change-Id: I752e53e0289b919430c2478bb1303f85e70f80ae
- 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._host = host
self._user = user
self._passwd = passwd
+ self._priv_level = priv_level
if log_path:
self._log_path = log_path
else:
if log_path:
self._log_path = log_path
else:
def get_passwd(self):
return self._passwd
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())
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):
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()
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)
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.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)
- 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):
def attach_virtual_cd(self, nfs_host, nfs_mount, boot_iso_filename):
for _ in range(2):
- 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)
def _set_boot_from_virtual_media(self):
logging.debug('Set boot from floppy (%s), and boot after that', self._host)
- 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
def _clear_ris_configuration(self):
# Clear RIS configuration
- 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)
def _set_boot_from_virtual_media(self):
logging.debug('Set boot from floppy (%s), and boot after that', self._host)
pass
class CatFile(object):
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._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
self._sol = None
self._login_user = login_user
logging.info('Open SOL console')
logging.debug('deactivate sol')
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)
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
logfile = open(log, 'wb')
self._sol.logfile_read = logfile
self._sol.terminate()
logging.debug('deactivate sol')
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):
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('-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')
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)
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__":
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_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.set_host_name(hw)
return bmc
bmc_host = bmc.get_host()
bmc_user = bmc.get_user()
bmc_passwd = bmc.get_passwd()
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:
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.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):
cat_file.cat('/srv/deployment/log/bootstrap.log', log_file)
def get_logs(self, admin_passwd):