def getDomainTemplates(self, predicate=None): ''' Query API and get the list of domain templates under the enterprise specified in the constructor. If a predicate is passed, pass predicate to API to filter results :param predicate: The predicate to run filtering logic against :type predicate: str :returns templates: A list of L3 domain templates ''' #Fetch enterprises entParse = EnterpriseParser(user=self.__user, password=self.__password, api_url=self.__api_url, enterprise=self.__enterprise,current_session=self.__session) predicateString = 'name == "%s"' % self.__enterprise enterprises = entParse.getEnterprises(predicate = predicateString) #entParse.printEnterprises(enterprises) parentEnterprise = enterprises[0] if(predicate is None): parentEnterprise.domain_templates.fetch() return parentEnterprise.domain_templates else: parentEnterprise.domain_templates.fetch(filter=predicate) return parentEnterprise.domain_templates
def get_zones(self,predicate=None): ''' Query API and get the list of domains under the enterprise specified in the constructor. If a predicate is passed, pass predicate to API to filter results :param predicate: The predicate to run filtering logic against :type predicate: str :returns zones: A list of zones in a L3 domain template. ''' #Fetch enterprises entParse = EnterpriseParser(user=self.__user, password=self.__password, api_url=self.__api_url, enterprise=self.__enterprise,current_session=self.__session) predicateString = 'name == "%s"' % self.__enterprise enterprises = entParse.getEnterprises(predicate = predicateString) #entParse.printEnterprises(enterprises) #print len(enterprises) parentEnterprise = enterprises[0] domainPredicateString = 'name == "%s"' % self.__domain parentEnterprise.domains.fetch(filter=domainPredicateString) domains = parentEnterprise.domains #print len(domains) # for dom in domains: # print dom.name # print "1" domain = domains[0] if predicate is None: domain.zones.fetch() return domain.zones else: domain.zones.fetch(filter=predicate) return domain.zones
def get_vlans(self, predicate=None): #Fetch enterprises entParse = EnterpriseParser(user=self.__user, password=self.__password, api_url=self.__api_url, enterprise=self.__enterprise,current_session=self.__session) predicateString = 'name == "%s"' % self.__enterprise enterprises = entParse.getEnterprises(predicate = predicateString) #entParse.printEnterprises(enterprises) #print len(enterprises) parent_enterprise = enterprises[0] nsg_predicate_string = 'name == "%s"' % self.__nsg parent_enterprise.ns_gateways.fetch(filter=nsg_predicate_string) nsgs = parent_enterprise.ns_gateways nsg = nsgs[0] #Fetch port port_predicate = 'name == "%s"' % self.__port nsg.ns_ports.fetch(filter = port_predicate) ports = nsg.ns_ports port = ports[0] if predicate is None: port.vlans.fetch() vlans = port.vlans return vlans else: port.vlans.fetch(filter=predicate) vlans = port.vlans return vlans