diff --git a/acitoolkit/acisession.py b/acitoolkit/acisession.py index f9d98c97..949b6ff6 100755 --- a/acitoolkit/acisession.py +++ b/acitoolkit/acisession.py @@ -659,6 +659,7 @@ def login(self, timeout=None): resp = requests.Response() resp.status_code = 404 resp._content = '{"error": "Could not relogin to APIC due to ConnectionError"}' + return resp if (self.appcenter_user and self._subscription_enabled) or not self.cert_auth: self.login_thread.daemon = True self.login_thread.start() diff --git a/applications/lint/acilint.py b/applications/lint/acilint.py index 04fa5c80..029742f7 100755 --- a/applications/lint/acilint.py +++ b/applications/lint/acilint.py @@ -217,6 +217,7 @@ def warning_010(self): """ provide_db = {} for tenant in self.tenants: + # TODO: Need code to deal with imported contracts. for app in tenant.get_children(AppProfile): for epg in app.get_children(EPG): if epg.has_bd(): @@ -231,6 +232,16 @@ def warning_010(self): provide_db[tenant.name][contract.name] = [] if context.name not in provide_db[tenant.name][contract.name]: provide_db[tenant.name][contract.name].append(context.name) + for l3out in tenant.get_children(OutsideL3): + for epg in l3out.get_children(OutsideEPG): + provided = epg.get_all_provided() + for contract in provided: + if tenant.name not in provide_db: + provide_db[tenant.name] = {} + if contract.name not in provide_db[tenant.name]: + provide_db[tenant.name][contract.name] = [] + if context.name not in provide_db[tenant.name][contract.name]: + provide_db[tenant.name][contract.name].append(context.name) for tenant in self.tenants: if tenant.name not in provide_db: @@ -248,14 +259,34 @@ def warning_010(self): context = bd.get_context() consumed = epg.get_all_consumed() for contract in consumed: - if contract.name not in provide_db[tenant.name]: + if contract.name in provide_db[tenant.name]: + if context.name not in provide_db[tenant.name][contract.name]: + self.output_handler("Warning 010: Contract '%s' not provided in context '%s' " + "where it is being consumed for" + " tenant '%s'" % (contract.name, context.name, tenant.name)) + elif (tenant.name != 'common') and (contract.name in provide_db['common']): + if context.name not in provide_db['common'][contract.name]: + self.output_handler("Warning 010: Contract '%s' not provided in context '%s' " + "where it is being consumed for" + " tenant '%s'" % (contract.name, context.name, tenant.name)) + elif tenant.name == 'common': self.output_handler("Warning 010: Contract '%s' not provided " "within the same tenant " "'%s'" % (contract.name, tenant.name)) - elif context.name not in provide_db[tenant.name][contract.name]: - self.output_handler("Warning 010: Contract '%s' not provided in context '%s' " - "where it is being consumed for" - " tenant '%s'" % (contract.name, context.name, tenant.name)) + else: + self.output_handler("Warning 010: Contract '%s' not provided " + "within the same tenant " + "'%s' or 'common'" % (contract.name, tenant.name)) + #if contract.name not in provide_db[tenant.name].keys() + provide_db['common'].keys(): + # self.output_handler("Warning 010: Contract '%s' not provided " + # "within the same tenant " + # "'%s'" % (contract.name, tenant.name)) + ##elif context.name not in provide_db[tenant.name][contract.name] + provide_db['common'][contract.name]: + #elif (contract.name in provide_db[tenant.name] and context.name not in provide_db[tenant.name][contract.name]) \ + # or (contract.name in provide_db['common'] and context.name not in provide_db['common'][contract.name]): + # self.output_handler("Warning 010: Contract '%s' not provided in context '%s' " + # "where it is being consumed for" + # " tenant '%s'" % (contract.name, context.name, tenant.name)) @staticmethod def subj_matches_proto(filterlist, protocol): @@ -393,6 +424,7 @@ def warning_014(self): self.output_handler("Warning 014: In tenant '%s' contract " "'%s' subject '%s' has no Filters." % ( tenant.name, contract.name, subject.name)) + missing_filter = False def error_001(self): """