def search_duplicate(): """ Search for duplicate IP address elements. It is also possible to filter the search by name, comment, or IP address :return: list of dict items holding href,type and name """ return element_by_href_as_json(fetch_entry_point('search_duplicate'))
def __get__(self, instance, cls=None): # Does the instance already have meta data if instance is not None and instance._meta: return instance._meta.href else: if hasattr(cls, 'typeof'): if instance is not None: element = fetch_href_by_name( instance.name, filter_context=instance.typeof) if element.json: instance._meta = Meta(**element.json[0]) return instance._meta.href raise ElementNotFound( 'Cannot find specified element: {}, type: {}'.format( unicode_to_bytes(instance.name), instance.typeof)) else: try: element = fetch_entry_point(cls.typeof) except UnsupportedEntryPoint as e: raise ElementNotFound(e) return element else: raise ElementNotFound( 'This class does not have the required attribute ' 'and cannot be referenced directly, type: {}'.format( instance))
def element_references_as_smcresult(element_href): """ Return references for an element given the element href. The return is the full SMCResult object. :param str element_href: element reference :return: :py:class:`smc.api.web.SMCResult` """ href = fetch_entry_point('references_by_element') return fetch_json_by_post(href=href, json={'value': element_href})
def vss_contexts(self): """ Return all virtual contexts for this VSS Container. :return list VSSContext """ result = self.make_request( href=fetch_entry_point('visible_virtual_engine_mapping'), params={'filter': self.name}) if result.get('mapping', []): return [Element.from_href(ve) for ve in result['mapping'][0].get('virtual_engine', [])] return []
def element_references(element_href): """ Return references for an element given the element href. The result is filtered based on the SMCResult. If error, empty list is returned :param str element_href: element reference :return: list list of references where element is used """ href = fetch_entry_point('references_by_element') result = fetch_json_by_post(href=href, json={'value': element_href}) if result.json: return result.json return []
def referenced_by(self): """ Show all references for this element. A reference means that this element is being used, for example, in a policy rule, as a member of a group, etc. :return: list referenced elements :rtype: list(Element) """ href = fetch_entry_point('references_by_element') return [ Element.from_meta(**ref) for ref in self.make_request( method='create', href=href, json={'value': self.href}) ]
def element_entry_point(name): """ Get specified element from cache based on the entry point verb from SMC api To get the entry points available, you can call web_api.get_all_entry_points() For example:: element_entry_point('log_server') :param name: top level entry point name :return: href: else None """ if name: element = fetch_entry_point(name) if element: return element
def element_entry_point(name): """ Get specified element from cache based on the entry point verb from SMC api To get the entry points available, you can call web_api.get_all_entry_points() For example:: element_entry_point('log_server') :param name: top level entry point name :return: href: else None """ if name: try: return fetch_entry_point(name) except UnsupportedEntryPoint: pass
def vss_contexts(self): """ Return all virtual contexts for this VSS Container. :return list VSSContext """ result = self.make_request( href=fetch_entry_point("visible_virtual_engine_mapping"), params={"filter": self.name}) if "mapping" in result: return [ Element.from_href(ve) for ve in result["mapping"][0].get("virtual_engine", []) ] return [] # pre-6.5
def ElementCreator(cls, json): """ Helper method for create classmethods. Returns the href if creation is successful. This is a lazy load that will provide only the meta for the element. Additional attribute access will load the full data. :return: instance of type Element with meta :rtype: Element """ result = SMCRequest(href=fetch_entry_point(cls.typeof), json=json).create() if result.msg: raise CreateElementFailed(result.msg) return cls(json.get('name'), type=cls.typeof, href=result.href)
def search_unused(): """ Search for all unused elements :return: list of dict items holding href,type and name """ return element_by_href_as_json(fetch_entry_point('search_unused'))
def __init__(self): entry = fetch_entry_point('system') super(System, self).__init__(href=entry)
def test_fetch_entry_point_failure(self): self.assertRaises(UnsupportedEntryPoint, lambda: fetch_entry_point('tedgsgshf'))
def __init__(self): entry = fetch_entry_point('system') super(System, self).__init__(href=entry)
def search_duplicate(): """ Search all duplicate elements :return: list of dict items holding href,type and name """ return element_by_href_as_json(fetch_entry_point('search_duplicate'))
def search_unused(): """ Search for all unused elements :return: list of dict items holding href,type and name """ return element_by_href_as_json(fetch_entry_point('search_unused'))