Exemplo n.º 1
0
Arquivo: vsx.py Projeto: aruba/pyaoscx
    def apply(self):
        '''
        Main method used to either create or update an existing VSX configuration.
        Checks whether the VSX configuration exists in the switch
        Calls self.update() if VSX configuration being updated
        Calls self.create() if a new VSX configuration is being created

        :return modified: Boolean, True if object was created or modified
            False otherwise
        '''

        # Verify ISL port is materialized inside switch and has NO-routing
        # status
        if not self.isl_port.materialized or self.isl_port.routing:
            raise VerificationError(
                'Interface', 'Object not materialized--or--routing enabled')
        # Verify that VRF is materialized inside switch
        if not self.keepalive_vrf.materialized:
            raise VerificationError('VRF', 'Object not materialized')

        modified = False
        if self.materialized:
            modified = self.update()
        else:
            modified = self.create()
        # Set internal attribute
        self.__modified = modified
        return modified
Exemplo n.º 2
0
    def upload_switch_config(self,
                             config_name=None,
                             config_file=None,
                             config_json=None,
                             vrf=None,
                             remote_file_tftp_path=None):
        '''
        Uploads configuration from a configuration file.
        :param config_name:  String with the Config file or checkpoint to be uploaded to.
            When using TFTP only running-config or startup-config can be used.
            Default: None.
        :param config_file: String with the File name and path for locally downloading
            configuration, only JSON version of configuration will be downloaded.
            Default: None.
        :param config_json: String with the JSON file name and path for locally uploading configuration,
            only JSON version of configuration can be uploaded.
            Default: None.
        :param vrf: String for VRF to be used to contact TFTP server, required if
            remote_output_file_tftp_path is provided.
            Default: None.
        :param remote_file_tftp_path: String for TFTP server address and path for copying off
            configuration, must be reachable through provided vrf.
            Default: None.
        :return success: Return boolean True if response is successful or False if it was not.
        '''

        success = False

        if remote_file_tftp_path is not None:
            if vrf is None:
                raise VerificationError(
                    "Upload Config",
                    "VRF needs to be provided in order to TFTP "
                    "the configuration onto the switch")

            tftp_path_encoded = utils._replace_special_characters(
                remote_file_tftp_path)

            if config_name != 'running-config' and config_name != 'startup-config':
                raise VerificationError(
                    "Upload Config",
                    "Only running-config or startup-config "
                    "can be uploaded using TFTP")

            success = self.tftp_switch_config_from_remote_location(
                tftp_path_encoded, config_name, vrf)

        else:

            success = self.upload_switch_config_from_local(
                config_json, config_file, config_name)

        return success
Exemplo n.º 3
0
    def backup_configuration(self, config_name, output_file=None,
                             vrf=None, config_type='json',
                             remote_file_tftp_path=None):
        '''
        Obtains the switch's full config in json format and saves it to a local file
        or a remote location over TFTP
        :param config_name:  String with the config file or checkpoint to be
            downloaded. When using TFTP
            only running-config or startup-config can be used
        :param output_file: String with the File name and path for locally
            downloading configuration, only JSON version of configuration will
            be downloaded
        :param vrf: VRF to be used to contact TFTP server
        :param config_type: Configuration type to be downloaded, JSON or CLI
            version of the config. 'json' or 'cli'
            Defaults to json
        :param remote_file_tftp_path: TFTP server address and path for
            copying off configuration, must be reachable through provided vrf
        :return bool: True if success

        '''
        success = False

        if remote_file_tftp_path is not None:
            tftp_path = remote_file_tftp_path
            if vrf is None:
                raise VerificationError(
                    'Backup Config',
                    "VRF needs to be provided in order to TFTP "
                    "the configuration from the switch")

            tftp_path_encoded = utils._replace_special_characters(tftp_path)

            if config_name != 'running-config' and \
                    config_name != 'startup-config':
                raise VerificationError(
                    'Backup Config',
                    "Only running-config or " +
                    "startup-config can be backed-up using TFTP")
            success = self.copy_switch_config_to_remote_location(
                config_name, config_type, tftp_path_encoded, vrf)
        else:
            config_json = self.get_full_config()
            with open(output_file, 'w') as to_file:
                formatted_file = json.dumps(config_json, indent=4)
                to_file.write(formatted_file)

            success = True

        # Return result
        return success
Exemplo n.º 4
0
    def delete_address_family(self, family_type="ipv4_unicast"):
        """
        Given a address family type, delete that address from the current
        Vrf object.

        :param family_type: Alphanumeric type of the Address Family.
            The options are 'ipv4_unicast' and 'ipv6_unicast'.
            A VrfAddressFamily object is accepted.
            The default value is set to 'ipv4_unicast'.

        """

        if not self.materialized:
            raise VerificationError('VRF {}'.format(self.name),
                                    'Object not materialized')

        # Verify if incoming address is a object
        if isinstance(family_type, VrfAddressFamily):
            # Obtain address
            family_type = family_type.address_family

        # Iterate through every address inside interface
        for add_family_obj in self.address_families:
            if add_family_obj.address_family == family_type:
                # Removing address does an internal delete
                self.address_families.remove(add_family_obj)
Exemplo n.º 5
0
    def boot_firmware(self, partition_name='primary'):
        '''
        Perform a POST request to Boot the AOS-CX switch with image present
            to the specified partition
        :param partition_name: String name of the partition for device to boot to.

        :return bool: True if success

        '''
        # Lower case for partition name
        partition_name = partition_name.lower()
        if partition_name not in ['primary', 'secondary']:
            raise VerificationError('Boot Firmware', 'Bad partition name')

        success = False
        uri = '{base_url}boot?image={part}'.format(
            base_url=self.session.base_url,
            part=partition_name)

        try:
            self.session.s.post(
                uri, verify=False,
                proxies=self.session.proxy)

        except Exception as e:
            raise ResponseError('POST', e)

        success = True

        # Return result
        return success
Exemplo n.º 6
0
    def create(self):
        '''
        Perform a POST call to create a new  OSPF Router table entry
        Only returns if an exception is not raise

        :return modified: True if entry was created

        '''

        ospf_router_data = {}

        ospf_router_data = utils.get_attrs(self, self.config_attrs)
        ospf_router_data['instance_tag'] = self.instance_tag

        # Set passive_interfaces into correct form
        if hasattr(self, 'passive_interfaces') \
                and self.passive_interfaces is not None:
            formated_interfaces = {}

            # Set interfaces into correct form
            for element in self.passive_interfaces:
                # Verify object is materialized
                if not element.materialized:
                    raise VerificationError(
                        'Interface {}'.format(element.name),
                        'Object inside passive_interfaces not materialized')
                formated_element = element.get_info_format()
                formated_interfaces.update(formated_element)

            # Set values in correct form
            ospf_router_data["passive_interfaces"] = formated_interfaces

        uri = "{base_url}{class_uri}".format(base_url=self.session.base_url,
                                             class_uri=self.base_uri)
        post_data = json.dumps(ospf_router_data, sort_keys=True, indent=4)

        try:
            response = self.session.s.post(uri,
                                           verify=False,
                                           data=post_data,
                                           proxies=self.session.proxy)

        except Exception as e:
            raise ResponseError('POST', e)

        if not utils._response_ok(response, "POST"):
            raise GenericOperationError(response.text, response.status_code)

        else:
            logging.info("SUCCESS: Adding OSPF table entry {} succeeded\
                ".format(self.instance_tag))

        # Get all object's data
        self.get()
        # Object was created
        return True
Exemplo n.º 7
0
    def delete(self):
        '''
        Perform DELETE call to delete Interface.

        '''
        if not self.__is_special_type:
            raise VerificationError('Interface', "Can't be deleted")

        # Delete Interface via a DELETE request to Ports Table
        uri = "{base_url}{class_uri}/{id}".format(
            base_url=self.session.base_url,
            class_uri=Interface.base_uri_ports,
            id=self.name
        )

        try:
            response = self.session.s.delete(
                uri, verify=False, proxies=self.session.proxy)

        except Exception as e:
            raise ResponseError('DELETE', e)

        if not utils._response_ok(response, "DELETE"):
            raise GenericOperationError(response.text, response.status_code)

        # DELETE Interface via DELETE request to Interface Table
        # Check if port is a LAG
        # If not, DELETE request to Interface Table
        if self.type != 'lag':
            uri_interfaces = "{base_url}{class_uri}".format(
                base_url=self.session.base_url,
                class_uri=Interface.base_uri_interface
            )

            try:
                response_ints = self.session.s.delete(
                    uri_interfaces, verify=False, proxies=self.session.proxy)

            except Exception as e:
                raise ResponseError('DELETE', e)

            if not utils._response_ok(response_ints, "DELETE"):
                raise GenericOperationError(
                    response_ints.text,
                    response_ints.status_code)

        # Clean LAG from interfaces
        # Delete interface references
        for interface in self.__prev_interfaces:
            # If interface name is not the same as the current one
            if interface.name != self.name and self.type == 'lag':
                interface.__delete_lag(self)

        # Delete object attributes
        utils.delete_attrs(self, self.config_attrs)
Exemplo n.º 8
0
    def create(self):
        '''
        Perform a POST call to create a new BGP Neighbor table entry
        Only returns if an exception is not raise

        :return modified: Boolean, True if entry was created

        '''

        bgp_neighbor_data = {}

        bgp_neighbor_data = utils.get_attrs(self, self.config_attrs)
        bgp_neighbor_data['ip_or_ifname_or_group_name'] = \
            self.ip_or_ifname_or_group_name

        if hasattr(self, 'local_interface'):

            # If local interface is NOT a string
            if not isinstance(self.local_interface, str):
                if not self.local_interface.materialized:
                    raise VerificationError('Local Interface',
                                            'Object not materialized')

                # Get ISL port uri
                bgp_neighbor_data["local_interface"] = \
                    self.local_interface.get_info_format()

        uri = "{base_url}{class_uri}".format(base_url=self.session.base_url,
                                             class_uri=self.base_uri)
        post_data = json.dumps(bgp_neighbor_data, sort_keys=True, indent=4)

        try:
            response = self.session.s.post(uri,
                                           verify=False,
                                           data=post_data,
                                           proxies=self.session.proxy)

        except Exception as e:
            raise ResponseError('POST', e)

        if not utils._response_ok(response, "POST"):
            raise GenericOperationError(response.text, response.status_code)

        else:
            logging.info("SUCCESS: Adding BGP table entry {} succeeded".format(
                self.ip_or_ifname_or_group_name))

        # Get all object's data
        self.get()

        # Object was modified, as it was created inside Device
        return True
Exemplo n.º 9
0
    def apply(self):
        '''
        Main method used to update System Attributes
        Checks whether the System is materialized
        Calls self.update() if the configuration is being updated

        :return modified: Boolean, True if object was modified
        '''
        modified = False
        if self.materialized:
            modified = self.update()
        else:
            raise VerificationError("Device", "Not materialized")
        return modified
Exemplo n.º 10
0
    def add_address_family(self,
                           family_type="ipv4_unicast",
                           export_target=[],
                           import_targets=[]):
        """
        Add a VRF Address Family to the current Vrf object

        :param family_type: Alphanumeric type of the Address Family.
            The options are 'ipv4_unicast' and 'ipv6_unicast'.
            The default value is set to 'ipv4_unicast'.
        :param export_target: Optional list of export route targets.
        :param import_targets: Optional list of import route targets

        :return address_family: VrfAddressFamily Object
        """

        if not self.materialized:
            raise VerificationError('VRF {}'.format(self.name),
                                    'Object not materialized')

        # Verify if incoming address is a string
        if isinstance(family_type, str):
            # Create Vrf_Family_Address object -- add it to it's internal
            # address_families
            vrf_address_family = self.session.api_version.get_module(
                self.session,
                'VrfAddressFamily',
                family_type,
                parent_vrf=self,
                export_route_targets=export_target,
                import_route_targets=import_targets,
                route_map={})
            # Try to get data, if non existent create
            try:
                # Try to obtain vrf_address_family address data
                vrf_address_family.get()
            # If vrf_address_family object is non existent, create it
            except GenericOperationError:
                # Create vrf_address_family inside switch
                vrf_address_family.apply()

        # Apply changes inside switch
        self.apply()

        return vrf_address_family
Exemplo n.º 11
0
    def update(self):
        '''
        Perform a PUT call to apply changes to an existing OSPF Router table entry

        :return modified: True if Object was modified and a PUT request was made.
            False otherwise
        '''

        ospf_router_data = {}

        ospf_router_data = utils.get_attrs(self, self.config_attrs)

        # Set passive_interfaces into correct form
        if hasattr(self, 'passive_interfaces') and \
                self.passive_interfaces is not None:
            formated_interfaces = {}

            # Set interfaces into correct form
            for element in self.passive_interfaces:
                # Verify object is materialized
                if not element.materialized:
                    raise VerificationError(
                        'Interface {}'.format(element.name),
                        'Object inside passive_interfaces not materialized')
                formated_element = element.get_info_format()
                formated_interfaces.update(formated_element)

            # Set values in correct form
            ospf_router_data["passive_interfaces"] = formated_interfaces

        uri = "{base_url}{class_uri}/{instance_tag}".format(
            base_url=self.session.base_url,
            class_uri=self.base_uri,
            instance_tag=self.instance_tag)

        # Compare dictionaries
        if ospf_router_data == self.__original_attributes:
            # Object was not modified
            modified = False

        else:
            post_data = json.dumps(ospf_router_data, sort_keys=True, indent=4)

            try:
                response = self.session.s.put(uri,
                                              verify=False,
                                              data=post_data,
                                              proxies=self.session.proxy)

            except Exception as e:
                raise ResponseError('PUT', e)

            if not utils._response_ok(response, "PUT"):
                raise GenericOperationError(response.text,
                                            response.status_code)

            else:
                logging.info(
                    "SUCCESS: Update  OSPF Router table entry {} succeeded\
                    ".format(self.instance_tag))
            # Set new original attributes
            self.__original_attributes = ospf_router_data
            # Object was modified
            modified = True
        return modified
Exemplo n.º 12
0
    def create_bgp_neighbors(self, group_ip, family_type="l2vpn_evpn",
                             reflector=False, send_community=False,
                             local_interface=""):
        """
        Perform a POST call to create BGP Neighbors to the associated current
        BGP Router - ASN.
        With l2vpn_evpn being True, this will also apply EVPN settings to the
        BGP neighbor configurations.

        :param group_ip: IPv4 address or name of group of the neighbors that
            functions as the BGP Router link.
            Example IPv4:
                10.10.12.11/255.255.255.255
        :param family_type: Alphanumeric to specify what type of neighbor
            settings to configure. The options are 'l2vpn-evpn',
            'ipv4-unicast', or 'ipv6-unicast'. When setting to l2vpn-evpn,
            the neighbor configurations also will add
            route-reflector-client and send-community settings.
            Defaults to "l2vpn_evpn"
        :param reflector: Boolean value to determine whether this neighbor has
            route reflector enabled.  Default is False.
        :param send_community: Boolean value to determine whether this
            neighbor has send-community enabled.  Default is False.
        :param local_interface: Optional alphanumeric to specify which
            interface the neighbor will apply to.
            Defaults to ""
        :return bgp_neighbor_obj: BgpRouter object
        """

        if not self.materialized:
            raise VerificationError(
                'VRF {}'.format(self.name),
                'Object not materialized')

        if local_interface != "":
            if isinstance(local_interface, str):
                local_interface = self.session.api_version.get_module(
                    self.session, 'Interface', local_interface)

        # Set values needed
        activate = {
            "ipv4-unicast": False,
            "ipv6-unicast": False,
            "l2vpn-evpn": False
        }

        next_hop_unchanged = {
            "l2vpn-evpn": False
        }

        route_reflector_client = {
            "ipv4-unicast": False,
            "ipv6-unicast": False,
            "l2vpn-evpn": False
        }

        send_community_data = {
            "ipv4-unicast": "none",
            "ipv6-unicast": "none",
            "l2vpn-evpn": "none"
        }

        activate[family_type] = True

        if send_community:
            send_community_data[family_type] = "both"

        if reflector:
            route_reflector_client[family_type] = reflector

        bgp_neighbor_obj = self.session.api_version.get_module(
            self.session, 'BgpNeighbor', group_ip,
            parent_bgp_router=self, is_peer_group=False,
            remote_as=self.asn, shutdown=False,
            local_interface=local_interface,
            activate=activate, next_hop_unchanged=next_hop_unchanged,
            route_reflector_client=route_reflector_client,
            send_community=send_community_data
        )

        # Try to obtain data; if not, create
        try:
            bgp_neighbor_obj.get()
        except GenericOperationError:
            # Create object inside switch
            bgp_neighbor_obj.apply()

        return bgp_neighbor_obj
Exemplo n.º 13
0
Arquivo: vsx.py Projeto: aruba/pyaoscx
    def create(self):
        '''
        Perform a POST call to create a new VSX
        Only returns if an exception is not raise

        return: True if entry was created
        '''

        vsx_data = {}
        vsx_data = utils.get_attrs(self, self.config_attrs)

        # Verify Keepalive is created
        if hasattr(self, 'keepalive_vrf'):
            if not self.keepalive_vrf.materialized:
                raise VerificationError('Keepalive Vrf',
                                        'Object not materialized')

            # Get VRF uri
            vsx_data["keepalive_vrf"] = self.keepalive_vrf.get_info_format()

        if hasattr(self, 'isl_port'):
            if not self.isl_port.materialized:
                raise VerificationError('Isl Port ', 'Object not materialized')

            # Get ISL port uri
            vsx_data["isl_port"] = self.isl_port.get_info_format()

        if hasattr(self, 'keepalive_peer') and \
                hasattr(self, 'keepalive_src') and \
                self.keepalive_src is not None and \
                self.keepalive_src is not None:

            ip_src_subnet = self.keepalive_src.find('/')
            ip_peer_subnet = self.keepalive_peer.find('/')

            if ip_src_subnet >= 0:
                self.keepalive_src = self.keepalive_src[0:ip_src_subnet]

            if ip_peer_subnet >= 0:
                self.keepalive_peer = self.keepalive_peer[0:ip_peer_subnet]

            vsx_data["keepalive_peer_ip"] = self.keepalive_peer
            vsx_data["keepalive_src_ip"] = self.keepalive_src

        if hasattr(self, 'system_mac') and self.system_mac is not None:
            vsx_data["system_mac"] = self.system_mac

        uri = "{base_url}{class_uri}".format(base_url=self.session.base_url,
                                             class_uri=Vsx.base_uri)

        post_data = json.dumps(vsx_data, sort_keys=True, indent=4)

        try:
            response = self.session.s.post(uri,
                                           verify=False,
                                           data=post_data,
                                           proxies=self.session.proxy)

        except Exception as e:
            raise ResponseError('POST', e)

        if not utils._response_ok(response, "POST"):
            raise GenericOperationError(response.text, response.status_code)

        else:
            logging.info("SUCCESS: Adding VSX table entry succeeded")

        # Get all objects data
        self.get()
        # Object was modified
        return True
Exemplo n.º 14
0
    def upload_firmware_http(self, remote_firmware_file_path,
                             vrf,
                             partition_name='primary'):
        '''
        Perform a PUT request to upload a firmware image given
        a http_request

        :param remote_firmware_file_path: "HTTP server address and path for
            uploading firmware image, must be reachable through provided vrf
            ex: http://192.168.1.2:8000/TL_10_04_0030A.swi"
        :param vrf: VRF to be used to contact HTTP server, required if
            remote_firmware_file_path is provided
        :param partition_name: Name of the partition for the
            image to be uploaded to.
        :return bool: True if success
        '''
        http_path = remote_firmware_file_path
        unsupported_versions = [
            "10.00",
            "10.01",
            "10.02",
            "10.03",
        ]
        # Verify Version
        for version in unsupported_versions:
            if version in self.firmware_version:
                raise VerificationError(
                    'Upload Firmware through HTTPs',
                    "Minimum supported firmware version is 10.04 for" +
                    " remote firmware upload, your version is {firmware}"
                    .format(firmware=self.firmware_version))
        # Verify VRF
        if vrf is None:
            raise VerificationError(
                'VRF',
                "VRF needs to be provided in order" +
                " to upload firmware from HTTP server")
        http_path_encoded = utils._replace_special_characters(http_path)

        # Build URI
        uri = '{base_url}firmware?image={part}&from={path}&vrf={vrf}'\
            .format(
                base_url=self.session.base_url,
                part=partition_name,
                path=http_path_encoded,
                vrf=vrf)

        # PUT for a HTTP Request
        try:
            response = self.session.s.put(
                uri, verify=False,
                proxies=self.session.proxy)

        except Exception as e:
            raise ResponseError('PUT', e)

        if not utils._response_ok(response, "PUT"):
            raise GenericOperationError(
                response.text, response.status_code)

        # True if successful
        return True
Exemplo n.º 15
0
    def update(self):
        '''
        Perform a PUT call to update data for a Port and Interface table entry

        :return modified: True if Object was modified and a PUT request was made.
            False otherwise
        '''
        # Flag used to determine if Object was modified
        modified_port = True
        modified_int = True
        # Check if Object is a LAG
        if self.type != 'lag':
            uri_interfaces = "{base_url}{class_uri}/{name}".format(
                base_url=self.session.base_url,
                class_uri=Interface.base_uri_interface,
                name=self.percents_name
            )
            # get Interface data related to configuration
            int_data = utils.get_attrs(self, self.config_attrs_int)
            # Remove type
            if 'type' in int_data:
                int_data.pop('type')
            if 'type' in self.__original_attributes_int:
                self.__original_attributes_int.pop('type')
            # Set put_int_data
            put_int_data = json.dumps(int_data, sort_keys=True, indent=4)
            # Compare dictionaries
            if int_data == self.__original_attributes_int:
                # Object was not modified
                modified_port = False
            else:
                # Bring Interface information
                try:
                    response_ints = self.session.s.put(
                        uri_interfaces, verify=False,
                        data=put_int_data, proxies=self.session.proxy)

                except Exception as e:
                    raise ResponseError('PUT', e)

                if not utils._response_ok(response_ints, "PUT"):
                    raise GenericOperationError(
                        response_ints.text,
                        response_ints.status_code)

                # Set new original attributes
                self.__original_attributes_int = int_data

        uri_ports = "{base_url}{class_uri}/{name}".format(
            base_url=self.session.base_url,
            class_uri=Interface.base_uri_ports,
            name=self.percents_name
        )

        # get Port data related to configuration
        port_data = utils.get_attrs(self, self.config_attrs)

        # Check for Ipv4
        try:
            if self.ip4_address is not None:
                port_data['ip4_address'] = self.ip4_address
        except AttributeError:
            pass
        # Check if vrf is inside the data related to Port
        if "vrf" in port_data:
            # Set VRF in the correct format for PUT
            port_data['vrf'] = self.vrf.get_info_format()

        # Check if vlan_tag is inside the data related to Port
        if "vlan_tag" in port_data:
            # Set VLAN in the correct format for PUT
            port_data["vlan_tag"] = self.vlan_tag.get_info_format()

        # Set interfaces into correct form
        if "interfaces" in port_data:
            # Check for interfaces no longer in LAG
            if self.__is_special_type and self.type == 'lag':
                for element in self.__prev_interfaces:
                    # If element was deleted from interfaces
                    if element not in self.interfaces:
                        # Delete element reference to current LAG
                        element.__delete_lag(self)

            # Set prev interfaces with current ones
            # Copies interfaces
            self.__prev_interfaces = list(self.interfaces)

            formated_interfaces = []
            # Set interfaces into correct form
            for element in self.interfaces:
                # If element is the same as current, ignore
                if element.name == self.name and self.type == 'lag':
                    pass
                else:
                    # Verify object is materialized
                    if not element.materialized:
                        raise VerificationError(
                            'Interface {}'.format(element.name),
                            'Object inside interfaces not materialized')
                    # Only in V1 get_uri() is used,
                    # In any other version, element.get_info_format()
                    # is used
                    formated_element = element.get_uri(True)
                    formated_interfaces.append(formated_element)

                    if self.type == 'lag':
                        # New element being added to LAG
                        element.__add_member_to_lag(self)

            # Set values in correct form
            port_data["interfaces"] = formated_interfaces

        # Set VLANs into correct form
        if "vlan_trunks" in port_data:
            formated_vlans = []
            # Set interfaces into correct form
            for element in self.vlan_trunks:
                # Verify object is materialized
                if not element.materialized:
                    raise VerificationError(
                        'Vlan {}'.format(element),
                        'Object inside vlan trunks not materialized')
                formated_element = element.get_info_format()
                formated_vlans.append(formated_element)

            # Set values in correct form
            port_data["vlan_trunks"] = formated_vlans

        # Set all ACLs
        if "aclmac_in_cfg" in port_data and self.aclmac_in_cfg is not None:
            # Set values in correct form
            port_data["aclmac_in_cfg"] = self.aclmac_in_cfg.get_info_format()

        if "aclmac_out_cfg" in port_data and self.aclmac_out_cfg is not None:
            # Set values in correct form
            port_data["aclmac_out_cfg"] = self.aclmac_out_cfg.get_info_format()

        if "aclv4_in_cfg" in port_data and self.aclv4_in_cfg is not None:
            # Set values in correct form
            port_data["aclv4_in_cfg"] = self.aclv4_in_cfg.get_info_format()

        if "aclv4_out_cfg" in port_data and self.aclv4_out_cfg is not None:
            # Set values in correct form
            port_data["aclv4_out_cfg"] = self.aclv4_out_cfg.get_info_format()

        if "aclv4_routed_in_cfg" in port_data and self.aclv4_routed_in_cfg is not None:
            # Set values in correct form
            port_data["aclv4_routed_in_cfg"] = self.aclv4_routed_in_cfg.get_info_format()

        if "aclv4_routed_out_cfg" in port_data and self.aclv4_routed_out_cfg is not None:
            # Set values in correct form
            port_data["aclv4_routed_out_cfg"] = self.aclv4_routed_out_cfg.get_info_format()

        if "aclv6_in_cfg" in port_data and self.aclv6_in_cfg is not None:
            # Set values in correct form
            port_data["aclv6_in_cfg"] = self.aclv6_in_cfg.get_info_format()

        if "aclv6_out_cfg" in port_data and self.aclv6_out_cfg is not None:
            # Set values in correct form
            port_data["aclv6_out_cfg"] = self.aclv6_out_cfg.get_info_format()

        if "aclv6_routed_in_cfg" in port_data and self.aclv6_routed_in_cfg is not None:
            # Set values in correct form
            port_data["aclv6_routed_in_cfg"] = self.aclv6_routed_in_cfg.get_info_format()

        if "aclv6_routed_out_cfg" in port_data and self.aclv6_routed_out_cfg is not None:
            # Set values in correct form
            port_data["aclv6_routed_out_cfg"] = self.aclv6_routed_out_cfg.get_info_format()

        # Set addresses the correct way
        if self.ip6_addresses is not None:
            ip6_addresses_dict = {}

            for ip in self.ip6_addresses:
                ip6_addresses_dict[ip.address] = ip.get_uri()

            # Set values in correct form
            port_data["ip6_addresses"] = ip6_addresses_dict

        # Delete type from Port data
        if 'type' in port_data:
            port_data.pop('type')

        if 'type' in self.__original_attributes_port:
            self.__original_attributes_port.pop('type')
        # Special case, if dictionary is empty
        if port_data["ip6_addresses"] == {}:
            self.__original_attributes_port["ip6_addresses"] = {}

        # Compare dictionaries
        if port_data == self.__original_attributes_port:
            # Object was not modified
            modified_int = False

        else:

            # Set put_port_data
            put_port_data = json.dumps(port_data, sort_keys=True, indent=4)

            # Bring Port information
            try:
                response_ports = self.session.s.put(
                    uri_ports, verify=False,
                    data=put_port_data, proxies=self.session.proxy)

            except Exception as e:
                raise ResponseError('PUT', e)

            if not utils._response_ok(response_ports, "PUT"):
                raise GenericOperationError(
                    response_ports.text,
                    response_ports.status_code)
            # Set new original attributes
            self.__original_attributes_port = port_data

        return modified_int or modified_port