idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
38,700
def create_iplist_with_data ( name , iplist ) : iplist = IPList . create ( name = name , iplist = iplist ) return iplist
Create an IPList with initial list contents .
38,701
def enable ( self , ospf_profile = None , router_id = None ) : ospf_profile = element_resolver ( ospf_profile ) if ospf_profile else OSPFProfile ( 'Default OSPFv2 Profile' ) . href self . data . update ( enabled = True , ospfv2_profile_ref = ospf_profile , router_id = router_id )
Enable OSPF on this engine . For master engines enable OSPF on the virtual firewall .
38,702
def create ( cls , name , interface_settings_ref = None , area_id = 1 , area_type = 'normal' , outbound_filters = None , inbound_filters = None , shortcut_capable_area = False , ospfv2_virtual_links_endpoints_container = None , ospf_abr_substitute_container = None , comment = None , ** kwargs ) : interface_settings_ref...
Create a new OSPF Area
38,703
def create ( cls , name , dead_interval = 40 , hello_interval = 10 , hello_interval_type = 'normal' , dead_multiplier = 1 , mtu_mismatch_detection = True , retransmit_interval = 5 , router_priority = 1 , transmit_delay = 1 , authentication_type = None , password = None , key_chain_ref = None ) : json = { 'name' : name ...
Create custom OSPF interface settings profile
38,704
def create ( cls , name , key_chain_entry ) : key_chain_entry = key_chain_entry or [ ] json = { 'name' : name , 'ospfv2_key_chain_entry' : key_chain_entry } return ElementCreator ( cls , json )
Create a key chain with list of keys
38,705
def create ( cls , name , abr_type = 'cisco' , auto_cost_bandwidth = 100 , deprecated_algorithm = False , initial_delay = 200 , initial_hold_time = 1000 , max_hold_time = 10000 , shutdown_max_metric_lsa = 0 , startup_max_metric_lsa = 0 ) : json = { 'name' : name , 'abr_type' : abr_type , 'auto_cost_bandwidth' : auto_co...
Create custom Domain Settings
38,706
def exception ( function ) : @ functools . wraps ( function ) def wrapper ( * exception , ** kwargs ) : result = function ( ** kwargs ) if exception : result . exception = exception [ 0 ] return result return wrapper
If exception was specified for prepared_request inject this into SMCRequest so it can be used for return if needed .
38,707
def create ( cls , name , mgmt_ip , mgmt_network , mgmt_interface = 0 , inline_interface = '1-2' , logical_interface = 'default_eth' , log_server_ref = None , domain_server_address = None , zone_ref = None , enable_antivirus = False , enable_gti = False , comment = None ) : interfaces = [ ] interface_id , second_interf...
Create a single layer 2 firewall with management interface and inline pair
38,708
def create ( cls , name , master_type , mgmt_ip , mgmt_network , mgmt_interface = 0 , log_server_ref = None , zone_ref = None , domain_server_address = None , enable_gti = False , enable_antivirus = False , comment = None ) : interface = { 'interface_id' : mgmt_interface , 'interfaces' : [ { 'nodes' : [ { 'address' : m...
Create a Master Engine with management interface
38,709
def create ( cls , name , master_type , macaddress , nodes , mgmt_interface = 0 , log_server_ref = None , domain_server_address = None , enable_gti = False , enable_antivirus = False , comment = None , ** kw ) : primary_mgt = primary_heartbeat = mgmt_interface interface = { 'interface_id' : mgmt_interface , 'interfaces...
Create Master Engine Cluster
38,710
def get_all_loopbacks ( engine ) : data = [ ] if 'fw_cluster' in engine . type : for cvi in engine . data . get ( 'loopback_cluster_virtual_interface' , [ ] ) : data . append ( LoopbackClusterInterface ( cvi , engine ) ) for node in engine . nodes : for lb in node . data . get ( 'loopback_node_dedicated_interface' , [ ...
Get all loopback interfaces for a given engine
38,711
def add ( self , interface_id , virtual_mapping = None , virtual_resource_name = None , zone_ref = None , comment = None ) : interface = Layer3PhysicalInterface ( engine = self . _engine , interface_id = interface_id , zone_ref = zone_ref , comment = comment , virtual_resource_name = virtual_resource_name , virtual_map...
Add single physical interface with interface_id . Use other methods to fully add an interface configuration based on engine type . Virtual mapping and resource are only used in Virtual Engines .
38,712
def add_layer3_vlan_cluster_interface ( self , interface_id , vlan_id , nodes = None , cluster_virtual = None , network_value = None , macaddress = None , cvi_mode = 'packetdispatch' , zone_ref = None , comment = None , ** kw ) : interfaces = { 'nodes' : nodes if nodes else [ ] , 'cluster_virtual' : cluster_virtual , '...
Add IP addresses to VLANs on a firewall cluster . The minimum params required are interface_id and vlan_id . To create a VLAN interface with a CVI specify cluster_virtual cluster_mask and macaddress .
38,713
def add_dhcp_interface ( self , interface_id , dynamic_index , zone_ref = None , vlan_id = None , comment = None ) : _interface = { 'interface_id' : interface_id , 'interfaces' : [ { 'nodes' : [ { 'dynamic' : True , 'dynamic_index' : dynamic_index } ] , 'vlan_id' : vlan_id } ] , 'comment' : comment , 'zone_ref' : zone_...
Add a DHCP interface on a single FW
38,714
def add_cluster_interface_on_master_engine ( self , interface_id , macaddress , nodes , zone_ref = None , vlan_id = None , comment = None ) : _interface = { 'interface_id' : interface_id , 'macaddress' : macaddress , 'interfaces' : [ { 'nodes' : nodes if nodes else [ ] , 'vlan_id' : vlan_id } ] , 'zone_ref' : zone_ref ...
Add a cluster address specific to a master engine . Master engine clusters will not use CVI interfaces like normal layer 3 FW clusters instead each node has a unique address and share a common macaddress . Adding multiple addresses to an interface is not supported with this method .
38,715
def add_tunnel_interface ( self , interface_id , address , network_value , zone_ref = None , comment = None ) : interfaces = [ { 'nodes' : [ { 'address' : address , 'network_value' : network_value } ] } ] interface = { 'interface_id' : interface_id , 'interfaces' : interfaces , 'zone_ref' : zone_ref , 'comment' : comme...
Creates a tunnel interface for a virtual engine .
38,716
def transform_login ( config ) : verify = True if config . pop ( 'smc_ssl' , None ) : scheme = 'https' verify = config . pop ( 'ssl_cert_file' , None ) if config . pop ( 'verify_ssl' , None ) : if not verify : verify = False else : verify = False else : scheme = 'http' config . pop ( 'verify_ssl' , None ) config . pop ...
Parse login data as dict . Called from load_from_file and also can be used when collecting information from other sources as well .
38,717
def download ( self , timeout = 5 , wait_for_finish = False ) : return Task . execute ( self , 'download' , timeout = timeout , wait_for_finish = wait_for_finish )
Download Package or Engine Update
38,718
def activate ( self , resource = None , timeout = 3 , wait_for_finish = False ) : return Task . execute ( self , 'activate' , json = { 'resource' : resource } , timeout = timeout , wait_for_finish = wait_for_finish )
Activate this package on the SMC
38,719
def create ( cls , name , sandbox_data_center , portal_username = None , comment = None ) : json = { 'name' : name , 'sandbox_data_center' : element_resolver ( sandbox_data_center ) , 'portal_username' : portal_username if portal_username else '' , 'comment' : comment } return ElementCreator ( cls , json )
Create a Sandbox Service element
38,720
def available_api_versions ( base_url , timeout = 10 , verify = True ) : try : r = requests . get ( '%s/api' % base_url , timeout = timeout , verify = verify ) if r . status_code == 200 : j = json . loads ( r . text ) versions = [ ] for version in j [ 'version' ] : versions . append ( version [ 'rel' ] ) return version...
Get all available API versions for this SMC
38,721
def get_api_version ( base_url , api_version = None , timeout = 10 , verify = True ) : versions = available_api_versions ( base_url , timeout , verify ) newest_version = max ( [ float ( i ) for i in versions ] ) if api_version is None : api_version = newest_version else : if api_version not in versions : api_version = ...
Get the API version specified or resolve the latest version
38,722
def _register ( self , session ) : if session . session_id : self . _sessions [ session . name ] = session
Register a session
38,723
def _deregister ( self , session ) : if session in self : self . _sessions . pop ( self . _get_session_key ( session ) , None )
Deregister a session .
38,724
def login ( self , url = None , api_key = None , login = None , pwd = None , api_version = None , timeout = None , verify = True , alt_filepath = None , domain = None , ** kwargs ) : params = { } if not url or ( not api_key and not ( login and pwd ) ) : try : params = load_from_file ( alt_filepath ) if alt_filepath is ...
Login to SMC API and retrieve a valid session . Sessions use a pool connection manager to provide dynamic scalability during times of increased load . Each session is managed by a global session manager making it possible to have more than one session per interpreter .
38,725
def _build_auth_request ( self , verify = False , ** kwargs ) : json = { 'domain' : self . domain } credential = self . credential params = { } if credential . provider_name . startswith ( 'lms' ) : params = dict ( login = credential . _login , pwd = credential . _pwd ) else : json . update ( authenticationkey = creden...
Build the authentication request to SMC
38,726
def add ( self , data ) : if self . is_none or self . is_any : self . clear ( ) self . data [ self . typeof ] = [ ] try : self . get ( self . typeof ) . append ( element_resolver ( data ) ) except ElementNotFound : pass
Add a single entry to field .
38,727
def all ( self ) : if not self . is_any and not self . is_none : return [ Element . from_href ( href ) for href in self . get ( self . typeof ) ] return [ ]
Return all destinations for this rule . Elements returned are of the object type for the given element for further introspection .
38,728
def create ( cls , name , user = None , network_element = None , domain_name = None , zone = None , executable = None ) : ref_list = [ ] if user : pass if network_element : ref_list . append ( network_element . href ) if domain_name : ref_list . append ( domain_name . href ) if zone : ref_list . append ( zone . href ) ...
Create a match expression
38,729
def enable ( self ) : self . update ( antivirus_enabled = True , virus_mirror = 'update.nai.com/Products/CommonUpdater' if not self . get ( 'virus_mirror' ) else self . virus_mirror , antivirus_update_time = self . antivirus_update_time if self . get ( 'antivirus_update_time' ) else 21600000 )
Enable antivirus on the engine
38,730
def disable ( self ) : self . engine . data . update ( sandbox_type = 'none' ) self . pop ( 'cloud_sandbox_settings' , None ) self . pop ( 'sandbox_settings' , None )
Disable the sandbox on this engine .
38,731
def bind_license ( self , license_item_id = None ) : params = { 'license_item_id' : license_item_id } self . make_request ( LicenseError , method = 'create' , resource = 'bind' , params = params )
Auto bind license uses dynamic if POS is not found
38,732
def initial_contact ( self , enable_ssh = True , time_zone = None , keyboard = None , install_on_server = None , filename = None , as_base64 = False ) : result = self . make_request ( NodeCommandFailed , method = 'create' , raw_result = True , resource = 'initial_contact' , params = { 'enable_ssh' : enable_ssh } ) if r...
Allows to save the initial contact for for the specified node
38,733
def go_offline ( self , comment = None ) : self . make_request ( NodeCommandFailed , method = 'update' , resource = 'go_offline' , params = { 'comment' : comment } )
Executes a Go - Offline operation on the specified node
38,734
def lock_online ( self , comment = None ) : self . make_request ( NodeCommandFailed , method = 'update' , resource = 'lock_online' , params = { 'comment' : comment } )
Executes a Lock - Online operation on the specified node
38,735
def reset_user_db ( self , comment = None ) : self . make_request ( NodeCommandFailed , method = 'update' , resource = 'reset_user_db' , params = { 'comment' : comment } )
Executes a Send Reset LDAP User DB Request operation on this node .
38,736
def reboot ( self , comment = None ) : self . make_request ( NodeCommandFailed , method = 'update' , resource = 'reboot' , params = { 'comment' : comment } )
Send reboot command to this node .
38,737
def ssh ( self , enable = True , comment = None ) : self . make_request ( NodeCommandFailed , method = 'update' , resource = 'ssh' , params = { 'enable' : enable , 'comment' : comment } )
Enable or disable SSH
38,738
def change_ssh_pwd ( self , pwd = None , comment = None ) : self . make_request ( NodeCommandFailed , method = 'update' , resource = 'change_ssh_pwd' , params = { 'comment' : comment } , json = { 'value' : pwd } )
Executes a change SSH password operation on the specified node
38,739
def create ( cls , name , entries = None , comment = None , ** kw ) : access_list_entry = [ ] if entries : for entry in entries : access_list_entry . append ( { '{}_entry' . format ( cls . typeof ) : entry } ) json = { 'name' : name , 'entries' : access_list_entry , 'comment' : comment } json . update ( kw ) return Ele...
Create an Access List Entry .
38,740
def add_entry ( self , ** kw ) : self . data . setdefault ( 'entries' , [ ] ) . append ( { '{}_entry' . format ( self . typeof ) : kw } )
Add an entry to an AccessList . Use the supported arguments for the inheriting class for keyword arguments .
38,741
def remove_entry ( self , ** field_value ) : field , value = next ( iter ( field_value . items ( ) ) ) self . data [ 'entries' ] [ : ] = [ entry for entry in self . data . get ( 'entries' ) if entry . get ( '{}_entry' . format ( self . typeof ) ) . get ( field ) != str ( value ) ]
Remove an AccessList entry by field specified . Use the supported arguments for the inheriting class for keyword arguments .
38,742
def update_status ( self ) : task = self . make_request ( TaskRunFailed , href = self . href ) return Task ( task )
Gets the current status of this task and returns a new task object .
38,743
def add_done_callback ( self , callback ) : if self . _done is None or self . _done . is_set ( ) : raise ValueError ( 'Task has already finished' ) if callable ( callback ) : self . callbacks . append ( callback )
Add a callback to run after the task completes . The callable must take 1 argument which will be the completed Task .
38,744
def wait ( self , timeout = None ) : if self . _thread is None : return self . _thread . join ( timeout = timeout )
Blocking wait for task status .
38,745
def last_message ( self , timeout = 5 ) : if self . _thread is not None : self . _thread . join ( timeout = timeout ) return self . _task . last_message
Wait a specified amount of time and return the last message from the task
38,746
def stop ( self ) : if self . _thread is not None and self . _thread . isAlive ( ) : self . _done . set ( )
Stop the running task
38,747
def save_to_file ( filename , content ) : import os . path path = os . path . abspath ( filename ) with open ( path , "w" ) as text_file : text_file . write ( "{}" . format ( content ) )
Save content to file . Used by node initial contact but can be used anywhere .
38,748
def merge_dicts ( dict1 , dict2 , append_lists = False ) : for key in dict2 : if isinstance ( dict2 [ key ] , dict ) : if key in dict1 and key in dict2 : merge_dicts ( dict1 [ key ] , dict2 [ key ] , append_lists ) else : dict1 [ key ] = dict2 [ key ] elif isinstance ( dict2 [ key ] , list ) and append_lists : if key i...
Merge the second dict into the first Not intended to merge list of dicts .
38,749
def bytes_to_unicode ( s , encoding = 'utf-8' , errors = 'replace' ) : if compat . PY3 : return str ( s , 'utf-8' ) if isinstance ( s , bytes ) else s return s if isinstance ( s , unicode ) else s . decode ( encoding , errors )
Helper to convert byte string to unicode string for user based input
38,750
def iterator ( self , ** kwargs ) : cls_name = '{0}Collection' . format ( self . _cls . __name__ ) collection_cls = type ( str ( cls_name ) , ( ElementCollection , ) , { } ) params = { 'filter_context' : self . _cls . typeof } params . update ( kwargs ) return collection_cls ( ** params )
Return an iterator from the collection manager . The iterator can be re - used to chain together filters each chaining event will be it s own unique element collection .
38,751
def object_types ( ) : types = [ element . rel for element in entry_point ( ) ] types . extend ( list ( CONTEXTS ) ) return types
Show all available entry points available for searching . An entry point defines a uri that provides unfiltered access to all elements of the entry point type .
38,752
def create_ospf_area_with_message_digest_auth ( ) : OSPFKeyChain . create ( name = 'secure-keychain' , key_chain_entry = [ { 'key' : 'fookey' , 'key_id' : 10 , 'send_key' : True } ] ) key_chain = OSPFKeyChain ( 'secure-keychain' ) OSPFInterfaceSetting . create ( name = 'authenicated-ospf' , authentication_type = 'messa...
If you require message - digest authentication for your OSPFArea you must create an OSPF key chain configuration .
38,753
def create_ospf_profile ( ) : OSPFDomainSetting . create ( name = 'custom' , abr_type = 'cisco' ) ospf_domain = OSPFDomainSetting ( 'custom' ) ospf_profile = OSPFProfile . create ( name = 'myospfprofile' , domain_settings_ref = ospf_domain . href ) print ( ospf_profile )
An OSPF Profile contains administrative distance and redistribution settings . An OSPF Profile is applied at the engine level . When creating an OSPF Profile you must reference a OSPFDomainSetting .
38,754
def create ( cls , name , vss_def = None ) : vss_def = { } if vss_def is None else vss_def json = { 'master_type' : 'dcl2fw' , 'name' : name , 'vss_isc' : vss_def } return ElementCreator ( cls , json )
Create a VSS Container . This maps to the Service Manager within NSX .
38,755
def vss_contexts ( self ) : 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 [ ]
Return all virtual contexts for this VSS Container .
38,756
def remove_security_group ( self , name ) : for group in self . security_groups : if group . isc_name == name : group . delete ( )
Remove a security group from container
38,757
def create ( cls , name , gateway , network , input_speed = None , output_speed = None , domain_server_address = None , provider_name = None , probe_address = None , standby_mode_period = 3600 , standby_mode_timeout = 30 , active_mode_period = 5 , active_mode_timeout = 1 , comment = None ) : json = { 'name' : name , 'g...
Create a new StaticNetlink to be used as a traffic handler .
38,758
def create ( cls , name , input_speed = None , learn_dns_automatically = True , output_speed = None , provider_name = None , probe_address = None , standby_mode_period = 3600 , standby_mode_timeout = 30 , active_mode_period = 5 , active_mode_timeout = 1 , comment = None ) : json = { 'name' : name , 'input_speed' : inpu...
Create a Dynamic Netlink .
38,759
def fetch_meta_by_name ( name , filter_context = None , exact_match = True ) : result = SMCRequest ( params = { 'filter' : name , 'filter_context' : filter_context , 'exact_match' : exact_match } ) . read ( ) if not result . json : result . json = [ ] return result
Find the element based on name and optional filters . By default the name provided uses the standard filter query . Additional filters can be used based on supported collections in the SMC API .
38,760
def references_by_element ( self , element_href ) : result = self . make_request ( method = 'create' , resource = 'references_by_element' , json = { 'value' : element_href } ) return result
Return all references to element specified .
38,761
def export_elements ( self , filename = 'export_elements.zip' , typeof = 'all' ) : valid_types = [ 'all' , 'nw' , 'ips' , 'sv' , 'rb' , 'al' , 'vpn' ] if typeof not in valid_types : typeof = 'all' return Task . download ( self , 'export_elements' , filename , params = { 'recursive' : True , 'type' : typeof } )
Export elements from SMC .
38,762
def _create ( self , common_name , public_key_algorithm = 'rsa' , signature_algorithm = 'rsa_sha_512' , key_length = 2048 , signing_ca = None ) : if signing_ca is None : signing_ca = VPNCertificateCA . objects . filter ( 'Internal RSA' ) . first ( ) cert_auth = element_resolver ( signing_ca ) return ElementCreator ( Ga...
Internal method called as a reference from the engine . vpn node
38,763
def create ( cls , name , min_dst_port , max_dst_port = None , min_src_port = None , max_src_port = None , protocol_agent = None , comment = None ) : max_dst_port = max_dst_port if max_dst_port is not None else '' json = { 'name' : name , 'min_dst_port' : min_dst_port , 'max_dst_port' : max_dst_port , 'min_src_port' : ...
Create the TCP service
38,764
def create ( cls , name , protocol_number , protocol_agent = None , comment = None ) : json = { 'name' : name , 'protocol_number' : protocol_number , 'protocol_agent_ref' : element_resolver ( protocol_agent ) or None , 'comment' : comment } return ElementCreator ( cls , json )
Create the IP Service
38,765
def create ( cls , name , frame_type = 'eth2' , value1 = None , comment = None ) : json = { 'frame_type' : frame_type , 'name' : name , 'value1' : int ( value1 , 16 ) , 'comment' : comment } return ElementCreator ( cls , json )
Create an ethernet service
38,766
def pem_as_string ( cert ) : if hasattr ( cert , 'read' ) : return cert cert = cert . encode ( 'utf-8' ) if isinstance ( cert , unicode ) else cert if re . match ( _PEM_RE , cert ) : return True return False
Only return False if the certificate is a file path . Otherwise it is a file object or raw string and will need to be fed to the file open context .
38,767
def send_message ( self , message ) : if self . connected : self . send ( json . dumps ( message . request ) )
Send a message down the socket . The message is expected to have a request attribute that holds the message to be serialized and sent .
38,768
def receive ( self ) : try : itr = 0 while self . connected : r , w , e = select . select ( ( self . sock , ) , ( ) , ( ) , 10.0 ) if r : message = json . loads ( self . recv ( ) ) if 'fetch' in message : self . fetch_id = message [ 'fetch' ] if 'failure' in message : raise InvalidFetch ( message [ 'failure' ] ) if 're...
Generator yielding results from the web socket . Results will come as they are received . Even though socket select has a timeout the SMC will not reply with a message more than every two minutes .
38,769
def ElementCreator ( cls , json , ** kwargs ) : if 'exception' not in kwargs : kwargs . update ( exception = CreateElementFailed ) href = kwargs . pop ( 'href' ) if 'href' in kwargs else cls . href result = SMCRequest ( href = href , json = json , ** kwargs ) . create ( ) element = cls ( name = json . get ( 'name' ) , ...
Helper method for creating elements . If the created element type is a SubElement class type provide href value as kwargs since that class type does not have a direct entry point . This is a lazy load that will provide only the meta for the element . Additional attribute access will load the full data .
38,770
def etag ( self , href ) : if self and self . _etag is None : self . _etag = LoadElement ( href , only_etag = True ) return self . _etag
ETag can be None if a subset of element json is using this container such as the case with Routing .
38,771
def get_link ( self , rel ) : if rel in self . links : return self . links [ rel ] raise ResourceNotFound ( 'Resource requested: %r is not available ' 'on this element.' % rel )
Return link for specified resource
38,772
def add_category ( self , category ) : assert isinstance ( category , list ) , 'Category input was expecting list.' from smc . elements . other import Category for tag in category : category = Category ( tag ) try : category . add_element ( self . href ) except ElementNotFound : Category . create ( name = tag ) categor...
Category Tags are used to characterize an element by a type identifier . They can then be searched and returned as a group of elements . If the category tag specified does not exist it will be created . This change will take effect immediately .
38,773
def export ( self , filename = 'element.zip' ) : from smc . administration . tasks import Task return Task . download ( self , 'export' , filename )
Export this element .
38,774
def referenced_by ( self ) : 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 } ) ]
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 .
38,775
def flush_parent_cache ( node ) : if node . _parent is None : node . _del_cache ( ) return node . _del_cache ( ) flush_parent_cache ( node . _parent )
Flush parent cache will recurse back up the tree and wipe the cache from each parent node reference on the given element . This allows the objects to be reused and a clean way to force the object to update itself if attributes or methods are referenced after update .
38,776
def route_level ( root , level ) : def recurse ( nodes ) : for node in nodes : if node . level == level : routing_node . append ( node ) else : recurse ( node ) routing_node = [ ] recurse ( root ) return routing_node
Helper method to recurse the current node and return the specified routing node level .
38,777
def get ( self , interface_id ) : for interface in self : if interface . nicid == str ( interface_id ) or interface . dynamic_nicid == str ( interface_id ) : return interface raise InterfaceNotFound ( 'Specified interface {} does not exist on ' 'this engine.' . format ( interface_id ) )
Obtain routing configuration for a specific interface by ID .
38,778
def add_ospf_area ( self , ospf_area , ospf_interface_setting = None , network = None , communication_mode = 'NOT_FORCED' , unicast_ref = None ) : communication_mode = communication_mode . upper ( ) destinations = [ ] if not ospf_interface_setting else [ ospf_interface_setting ] if communication_mode == 'UNICAST' and u...
Add OSPF Area to this routing node .
38,779
def create ( cls , name , address = None , ipv6_address = None , secondary = None , comment = None ) : address = address if address else None ipv6_address = ipv6_address if ipv6_address else None secondaries = [ ] if secondary is None else secondary json = { 'name' : name , 'address' : address , 'ipv6_address' : ipv6_a...
Create the host element
38,780
def create ( cls , name , ip_range , comment = None ) : json = { 'name' : name , 'ip_range' : ip_range , 'comment' : comment } return ElementCreator ( cls , json )
Create an AddressRange element
38,781
def create ( cls , name , ipv4_network = None , ipv6_network = None , comment = None ) : ipv4_network = ipv4_network if ipv4_network else None ipv6_network = ipv6_network if ipv6_network else None json = { 'name' : name , 'ipv4_network' : ipv4_network , 'ipv6_network' : ipv6_network , 'comment' : comment } return Eleme...
Create the network element
38,782
def create ( cls , name , ne_ref = None , operator = 'exclusion' , sub_expression = None , comment = None ) : sub_expression = [ ] if sub_expression is None else [ sub_expression ] json = { 'name' : name , 'operator' : operator , 'ne_ref' : ne_ref , 'sub_expression' : sub_expression , 'comment' : comment } return Eleme...
Create the expression
38,783
def download ( self , filename = None , as_type = 'zip' ) : headers = None if as_type in [ 'zip' , 'txt' , 'json' ] : if as_type == 'zip' : if filename is None : raise MissingRequiredInput ( 'Filename must be specified when ' 'downloading IPList as a zip file.' ) filename = '{}' . format ( filename ) elif as_type == 't...
Download the IPList . List format can be either zip text or json . For large lists it is recommended to use zip encoding . Filename is required for zip downloads .
38,784
def upload ( self , filename = None , json = None , as_type = 'zip' ) : headers = { 'content-type' : 'multipart/form-data' } params = None files = None if filename : files = { 'ip_addresses' : open ( filename , 'rb' ) } if as_type == 'json' : headers = { 'accept' : 'application/json' , 'content-type' : 'application/jso...
Upload an IPList to the SMC . The contents of the upload are not incremental to what is in the existing IPList . So if the intent is to add new entries you should first retrieve the existing and append to the content then upload . The only upload type that can be done without loading a file as the source is as_type = j...
38,785
def resolve ( self , engine ) : if not self . resolved_value : result = self . make_request ( ElementNotFound , href = self . get_relation ( 'resolve' ) , params = { 'for' : engine } ) self . resolved_value = result . get ( 'resolved_value' ) return self . resolved_value
Resolve this Alias to a specific value . Specify the engine by name to find it s value .
38,786
def name ( self ) : return self . _meta . name if self . _meta . name else 'Rule @%s' % self . tag
Name attribute of rule element
38,787
def create ( self , name , sources = None , destinations = None , services = None , action = 'allow' , log_options = None , authentication_options = None , connection_tracking = None , is_disabled = False , vpn_policy = None , mobile_vpn = False , add_pos = None , after = None , before = None , sub_policy = None , comm...
Create a layer 3 firewall rule
38,788
def create ( self , name , sources = None , destinations = None , services = None , action = 'allow' , is_disabled = False , logical_interfaces = None , add_pos = None , after = None , before = None , comment = None ) : rule_values = self . update_targets ( sources , destinations , services ) rule_values . update ( nam...
Create an Ethernet rule
38,789
def download ( self , filename = None ) : if not filename : filename = '{}{}' . format ( self . name , '.zip' ) try : self . make_request ( EngineCommandFailed , resource = 'content' , filename = filename ) except IOError as e : raise EngineCommandFailed ( "Snapshot download failed: {}" . format ( e ) )
Download snapshot to filename
38,790
def create ( cls , name , nat = False , mobile_vpn_toplogy_mode = None , vpn_profile = None ) : vpn_profile = element_resolver ( vpn_profile ) or VPNProfile ( 'VPN-A Suite' ) . href json = { 'mobile_vpn_topology_mode' : mobile_vpn_toplogy_mode , 'name' : name , 'nat' : nat , 'vpn_profile' : vpn_profile } try : return E...
Create a new policy based VPN
38,791
def enable_disable_nat ( self ) : if self . nat : self . data [ 'nat' ] = False else : self . data [ 'nat' ] = True
Enable or disable NAT on this policy . If NAT is disabled it will be enabled and vice versa .
38,792
def update_members ( self , members , append_lists = False , remove_members = False ) : if members : elements = [ element_resolver ( element ) for element in members ] if remove_members : element = [ e for e in self . members if e not in elements ] if set ( element ) == set ( self . members ) : remove_members = element...
Update group members with member list . Set append = True to append to existing members or append = False to overwrite .
38,793
def create ( cls , name , members = None , comment = None ) : element = [ ] if members is None else element_resolver ( members ) json = { 'name' : name , 'element' : element , 'comment' : comment } return ElementCreator ( cls , json )
Create the TCP Service group
38,794
def create_gre_tunnel_no_encryption ( cls , name , local_endpoint , remote_endpoint , mtu = 0 , pmtu_discovery = True , ttl = 0 , enabled = True , comment = None ) : return cls . create_gre_tunnel_mode ( name , local_endpoint , remote_endpoint , policy_vpn = None , mtu = mtu , pmtu_discovery = pmtu_discovery , ttl = tt...
Create a GRE Tunnel with no encryption . See create_gre_tunnel_mode for constructor descriptions .
38,795
def set_auth_request ( self , interface_id , address = None ) : self . interface . set_auth_request ( interface_id , address ) self . _engine . update ( )
Set the authentication request field for the specified engine .
38,796
def name ( self ) : name = super ( Interface , self ) . name return name if name else self . data . get ( 'name' )
Read only name tag
38,797
def _add_interface ( self , interface_id , ** kw ) : base_interface = ElementCache ( ) base_interface . update ( interface_id = str ( interface_id ) , interfaces = [ ] ) if 'zone_ref' in kw : zone_ref = kw . pop ( 'zone_ref' ) base_interface . update ( zone_ref = zone_helper ( zone_ref ) if zone_ref else None ) if 'com...
Create a tunnel interface . Kw argument list is as follows
38,798
def _add_interface ( self , interface_id , mgt = None , ** kw ) : _kw = copy . deepcopy ( kw ) mgt = mgt if mgt else { } if 'cvi_mode' in _kw : self . data . update ( cvi_mode = _kw . pop ( 'cvi_mode' ) ) if 'macaddress' in _kw : self . data . update ( macaddress = _kw . pop ( 'macaddress' ) ) if 'cvi_mode' not in self...
Add the Cluster interface . If adding a cluster interface to an existing node retrieve the existing interface and call this method . Use the supported format for defining an interface .
38,799
def create ( cls , name , port = 179 , external_distance = 20 , internal_distance = 200 , local_distance = 200 , subnet_distance = None ) : json = { 'name' : name , 'external' : external_distance , 'internal' : internal_distance , 'local' : local_distance , 'port' : port } if subnet_distance : d = [ { 'distance' : dist...
Create a custom BGP Profile