def get_device_info( self, job_ctx, device_uuid, ): try: FilterLog.instance("HitlessUpgradeFilter") self.job_input = FilterModule._validate_job_ctx(job_ctx) self.fabric_uuid = self.job_input['fabric_uuid'] self.vncapi = JobVncApi.vnc_init(job_ctx) self.job_ctx = job_ctx self.ja = JobAnnotations(self.vncapi) self.advanced_parameters = self._get_advanced_params() self._cache_job_input() self.device_uuid = device_uuid device_info = self._get_device_info() return device_info except Exception as ex: errmsg = "Unexpected error getting device info: %s\n%s" % ( str(ex), traceback.format_exc()) _task_error_log(errmsg) return { 'status': 'failure', 'error_msg': errmsg, }
def validate_critical_roles_for_hitless(self, job_ctx, image_upgrade_list): try: FilterLog.instance("HitlessUpgradeFilter") self.job_input = FilterModule._validate_job_ctx(job_ctx) self.fabric_uuid = self.job_input['fabric_uuid'] self.vncapi = JobVncApi.vnc_init(job_ctx) self.job_ctx = job_ctx self.ja = JobAnnotations(self.vncapi) self.advanced_parameters = self._get_advanced_params() self._cache_job_input() self.image_upgrade_list = image_upgrade_list self.device_uuid_list = [] for image_entry in self.image_upgrade_list: device_list = image_entry.get('device_list') image_uuid = image_entry.get('image_uuid') image_obj = self.vncapi.device_image_read(id=image_uuid) for device_uuid in device_list: device_obj = self.vncapi.physical_router_read( id=device_uuid) if image_obj.device_image_os_version !=\ device_obj.physical_router_os_version: self.device_uuid_list.append(device_uuid) results = self._validate_critical_roles_for_hitless_upgrade() return results except Exception as ex: errmsg = "Unexpected error validating: %s\n%s" % ( str(ex), traceback.format_exc()) _task_error_log(errmsg) return { 'status': 'failure', 'error_msg': errmsg, }
def get_hitless_upgrade_plan(self, job_ctx, image_upgrade_list, device_json): try: FilterLog.instance("HitlessUpgradeFilter") self.job_input = FilterModule._validate_job_ctx(job_ctx) self.fabric_uuid = self.job_input['fabric_uuid'] self.vncapi = JobVncApi.vnc_init(job_ctx) self.job_ctx = job_ctx self.ja = JobAnnotations(self.vncapi) self.advanced_parameters = self._get_advanced_params() self._cache_job_input() self.batch_limit = self.advanced_parameters.get( 'bulk_device_upgrade_count') self.image_upgrade_list = image_upgrade_list self.device_json = device_json upgrade_plan = self._get_hitless_upgrade_plan() return upgrade_plan except Exception as ex: errmsg = "Unexpected error: %s\n%s" % (str(ex), traceback.format_exc()) _task_error_log(errmsg) return { 'status': 'failure', 'error_msg': errmsg, }