-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issu sw install #606
Issu sw install #606
Conversation
1 similar comment
package_name=remote_package, **kwargs).getparent() | ||
rc = int(rsp.findtext('package-result')) | ||
if rc != 0: | ||
self.log("software validation message: %s" % rsp.findtext('output')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest unconditionally logging this message, instead of just logging if there's a failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care. Thanks
package_name=remote_package, **kwargs).getparent() | ||
rc = int(rsp.findtext('package-result')) | ||
if rc != 0: | ||
self.log("software validation message: %s" % rsp.findtext('output')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some cases where the RPC reply contains more than one <output>
element.
In those cases, rsp.findtext('output')
will only return the first <output>
element's text.
Probably need something like this instead:
for output in rsp.findall('output'):
self.log("software validation message: %s" % (output.text))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care. Thanks
v_ok = self.validate(remote_package, dev_timeout=timeout) | ||
if v_ok is not True: | ||
return v_ok # will be the string of output | ||
v_ok = self.validate(remote_package, issu, dev_timeout=timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a general comment on how the timeout
argument is handled in the install()
method and isn't really specific to this commit...
Should we subtract the time spent in each of the steps (safe_copy()
, validate()
, and pkg_add()
) from timeout
? Otherwise the total time spent on the software upgrade could be greater than the timeout
value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not change this. Timeout in general meant for per rpc. So it should be individual for each function call internally too, which is happening as of today.
# return True if rc == 0 else got.findtext('output').strip() | ||
return True if rc == 0 else False | ||
if rc != 0: | ||
self.log("software pkgadd message: %s" % got.findtext('output')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest unconditionally logging this message, instead of just logging if there's a failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care. Thanks
if v_ok is not True: | ||
return v_ok | ||
|
||
if issu is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ISSU and NSSU only make sense when self._multi_RE is True
. Currently the code tries them even if self._multi_RE is False
. Maybe this is OK because the RPCs themselves will likely fail in this case. However, I'm wondering if it makes more sense for us to only attempt ISSU/NSSU when self._multi_RE is True
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am adding this. The plus point I saw by not putting that condition was even when the device was connected using gather_facts as False or facts gathering failed, this would work perfectly fine. I have added the check for now.
1 similar comment
sample example: import time
from jnpr.junos import Device
from pprint import pprint
from jnpr.junos.utils.sw import SW
from jnpr.junos.utils.config import Config
from lxml import etree
with Device(host='xxxx’, user=’xxxx’, password=’xxx’) as dev:
pprint(dev.facts)
facts = dev.facts
# dev.facts_refresh(exception_on_failure=True)
if not facts['version_RE0'] == facts['version_RE1']:
raise Exception('Not compatible for ISSU upgrade')
# Inspired from
# http://www.juniper.net/documentation/en_US/junos16.1/topics/task/installation/issu-upgrading.html#test1
set_commands = """
set chassis redundancy graceful-switchover
set routing-options nonstop-routing
set system commit synchronize"""
# this would take care of lock and unlock
with Config(dev, mode='exclusive') as cu:
cu.load(set_commands)
cu.commit()
# Verify that NSR is configured on the master Routing Engine (re0) by using the show task replication command.
op = dev.rpc.get_routing_task_replication_state()
if not op.findtext('task-gres-state') == 'Enabled' and not op.findtext('') == 'Master':
raise Exception('"show task replication" is not as per ISSU requirement')
# Verify that GRES is enabled on the backup Routing Engine (re1) by using the show system switchover command.
# As I know backup name, below code will work, otherwise I can use startShell to go from master to backup
with Device(host='xxxx1’, user=’xxxx’, password=’xxx’, gather_facts=False) as dev1:
op = dev1.rpc.get_switchover_information()
if op.findtext('switchover-state').strip().lower() != 'on':
raise Exception('"switchover-state is not On')
# Adjusting Timers and Changing Feature-Specific Configuration
# I am not handling this. Do we need to check this too?
sw = SW(dev)
try:
ok = sw.install(package='junos-install-mx-x86-64-16.1-20160925.0.tgz', issu=True,
no_copy=True, validate=True, progress=True)
if ok is True:
# below steps is only required you we want to reboot the old master re only
sw.reboot(all_re=False)
# device might be pingable for few seconds before it goes for reboot.
time.sleep(30)
if dev.probe(1200, 5):
print "old master is rebooted and is now up"
dev.open(gather_facts=False)
#time.sleep(300) # without sleep we get message "Not ready for mastership switch, try after 239 secs."
print dev.cli("request chassis routing-engine master acquire", warning=False)
print "Device is UP & ISSU upgrade Done"
else:
print "old master is not pingable even after 1200 sec after reboot"
else:
"sw.install returned False"
except Exception as ex:
print "ERROR: %s" % ex.message |
No description provided.