def __present(self, data):
        ethernet_network = self.__get_by_name(data)

        changed = False

        if "newName" in data:
            data["name"] = data.pop("newName")

        bandwidth = data.pop('bandwidth', None)

        if not ethernet_network:
            ethernet_network = self.oneview_client.ethernet_networks.create(data)
            changed = True
            msg = ETHERNET_NETWORK_CREATED
        else:
            merged_data = ethernet_network.copy()
            merged_data.update(data)

            if not resource_compare(ethernet_network, merged_data):
                ethernet_network = self.oneview_client.ethernet_networks.update(merged_data)
                changed = True
                msg = ETHERNET_NETWORK_UPDATED
            else:
                msg = ETHERNET_NETWORK_ALREADY_EXIST

        if bandwidth:
            if self.__update_connection_template(ethernet_network, bandwidth)[0]:
                if not changed:
                    changed = True
                    msg = ETHERNET_NETWORK_UPDATED

        return changed, msg, dict(ethernet_network=ethernet_network)
    def __present(self, data, resource):
        changed = False

        if "newName" in data:
            data["name"] = data.pop("newName")

        self.__replace_name_by_uris(data)

        if not resource:
            resource = self.i3s_client.deployment_plans.create(data)
            msg = DEPLOYMENT_PLAN_CREATED
            changed = True
        else:
            merged_data = resource.copy()
            merged_data.update(data)

            if not resource_compare(resource, merged_data):
                # update resource
                resource = self.i3s_client.deployment_plans.update(merged_data)
                changed = True
                msg = DEPLOYMENT_PLAN_UPDATED
            else:
                msg = DEPLOYMENT_PLAN_ALREADY_UPDATED

        return changed, msg, dict(deployment_plan=resource)
Exemple #3
0
    def __present(self, data):
        resource = self.__get_by_name(data)
        changed = False

        if "newName" in data:
            data["name"] = data["newName"]
            del data["newName"]

        if not resource:
            resource = self.oneview_client.fcoe_networks.create(data)
            msg = FCOE_NETWORK_CREATED
            changed = True
        else:
            merged_data = resource.copy()
            merged_data.update(data)

            if resource_compare(resource, merged_data):
                msg = FCOE_NETWORK_ALREADY_EXIST
            else:
                resource = self.oneview_client.fcoe_networks.update(
                    merged_data)
                changed = True
                msg = FCOE_NETWORK_UPDATED

        return changed, msg, dict(fcoe_network=resource)
Exemple #4
0
    def __present(self, data, resource):

        changed = False
        msg = ''

        if "newName" in data:
            data["name"] = data.pop("newName")

        self.__replace_name_by_uris(data)

        if not resource:
            resource = self.oneview_client.logical_switch_groups.create(data)
            changed = True
            msg = LOGICAL_SWITCH_GROUP_CREATED
        else:
            merged_data = resource.copy()
            merged_data.update(data)

            if not resource_compare(resource, merged_data):
                # update resource
                changed = True
                resource = self.oneview_client.logical_switch_groups.update(merged_data)
                msg = LOGICAL_SWITCH_GROUP_UPDATED
            else:
                msg = LOGICAL_SWITCH_GROUP_ALREADY_UPDATED

        return changed, msg, dict(logical_switch_group=resource)
Exemple #5
0
    def __present(self, data):
        resource = self.__get_resource(data)
        changed = False
        msg = ''

        if not resource:
            if 'credentials' not in data:
                raise HPOneViewValueError(STORAGE_SYSTEM_CREDENTIALS_MANDATORY)
            resource = self.oneview_client.storage_systems.add(
                data['credentials'])
            changed = True
            msg = STORAGE_SYSTEM_ADDED

        merged_data = resource.copy()
        merged_data.update(data)

        if 'credentials' in merged_data and 'password' in merged_data[
                'credentials']:
            # remove password, it cannot be used in comparison
            del merged_data['credentials']['password']

        if not resource_compare(resource, merged_data):
            # update the resource
            resource = self.oneview_client.storage_systems.update(merged_data)
            if not changed:
                changed = True
                msg = STORAGE_SYSTEM_UPDATED
        else:
            msg = STORAGE_SYSTEM_ALREADY_UPDATED

        return changed, msg, dict(storage_system=resource)
Exemple #6
0
    def __present(self, data, resource):

        changed = False

        if "newName" in data:
            data["name"] = data.pop("newName")

        if not resource:
            resource = self.oneview_client.power_devices.add(data)
            changed = True
            msg = POWER_DEVICE_ADDED
        else:
            merged_data = resource.copy()
            merged_data.update(data)

            if not resource_compare(resource, merged_data):
                # update resource
                changed = True
                resource = self.oneview_client.power_devices.update(
                    merged_data)
                msg = POWER_DEVICE_UPDATED
            else:
                msg = POWER_DEVICE_ALREADY_PRESENT

        return changed, msg, dict(power_device=resource)
    def __present(self, data, resource):

        changed = False
        msg = ''

        if "newName" in data:
            data["name"] = data.pop("newName")

        self.__replace_name_by_uris(data)

        if not resource:
            resource = self.oneview_client.datacenters.add(data)

            changed = True
            msg = DATACENTER_ADDED
        else:
            merged_data = resource.copy()
            merged_data.update(data)

            if not resource_compare(resource, merged_data):
                # update resource
                changed = True
                resource = self.oneview_client.datacenters.update(merged_data)
                msg = DATACENTER_UPDATED
            else:
                msg = DATACENTER_ALREADY_UPDATED

        return changed, msg, dict(datacenter=resource)
Exemple #8
0
    def __present(self, resource, data):

        self.__replace_names_by_uris(data)

        changed = False

        if "newName" in data:
            data["name"] = data.pop("newName")

        if not resource:
            resource = self.oneview_client.os_deployment_servers.add(data)
            changed = True
            msg = self.DEPLOYMENT_SERVER_CREATED
        else:
            appliance_uri = data.pop('applianceUri', '')
            if appliance_uri:
                data['primaryActiveAppliance'] = appliance_uri

            merged_data = resource.copy()
            merged_data.update(data)

            if not resource_compare(resource, merged_data):
                resource = self.oneview_client.os_deployment_servers.update(merged_data)
                changed = True
                msg = self.DEPLOYMENT_SERVER_UPDATED
            else:
                msg = self.DEPLOYMENT_SERVER_ALREADY_EXIST

        return changed, msg, dict(os_deployment_server=resource)
 def test_comparison_false_and_none(self):
     dict1 = {
         "name": "name",
         "values": False
     }
     dict2 = {
         "name": "name",
         "values": None
     }
     self.assertTrue(resource_compare(dict1, dict2))
 def test_comparison_none_and_dict_level_1(self):
     dict1 = {
         "name": "name",
         "value": None
     }
     dict2 = {
         "name": "name",
         "value": {"name": "subresource"}
     }
     self.assertFalse(resource_compare(dict1, dict2))
 def test_comparison_none_and_empty_list(self):
     dict1 = {
         "name": "name",
         "values": None
     }
     dict2 = {
         "name": "name",
         "values": []
     }
     self.assertTrue(resource_compare(dict1, dict2))
 def test_comparison_none_and_list_level_1(self):
     dict1 = {
         "name": "name",
         "value": None
     }
     dict2 = {
         "name": "name",
         "value": [{"name": "item1"},
                   {"name": "item2"}]
     }
     self.assertFalse(resource_compare(dict1, dict2))
    def test_comparison_with_different_float_values(self):
        dict1 = {
            "name": "name",
            "lvalue": 10.2
        }

        dict2 = {
            "name": "name",
            "lvalue": float(10.1)
        }
        self.assertFalse(resource_compare(dict1, dict2))
    def test_comparison_with_str_and_float(self):
        dict1 = {
            "name": "name",
            "lvalue": '10.1'
        }

        dict2 = {
            "name": "name",
            "lvalue": float(10.1)
        }
        self.assertTrue(resource_compare(dict1, dict2))
    def test_comparison_true_and_true(self):
        dict1 = {
            "name": "name",
            "values": True
        }

        dict2 = {
            "name": "name",
            "values": True
        }
        self.assertTrue(resource_compare(dict1, dict2))
Exemple #16
0
 def test_comparison_none_and_list_level_1(self):
     dict1 = {"name": "name", "value": None}
     dict2 = {
         "name": "name",
         "value": [{
             "name": "item1"
         }, {
             "name": "item2"
         }]
     }
     self.assertFalse(resource_compare(dict1, dict2))
    def test_comparison_with_int_and_float(self):
        dict1 = {
            "name": "name",
            "lvalue": int(10)
        }

        dict2 = {
            "name": "name",
            "lvalue": float(10)
        }
        self.assertTrue(resource_compare(dict1, dict2))
    def test_comparison_list_and_dict(self):
        dict1 = {
            "name": "name",
            "value": [1, 2, 3]
        }

        dict2 = {
            "name": "name",
            "value": {"id": 123}
        }
        self.assertFalse(resource_compare(dict1, dict2))
    def test_resource_compare_with_double_level_list_different(self):
        dict1 = {list: [
            [1, 2, 3],
            [4, 5, 6]
        ]}

        dict2 = {list: [
            [1, 2, 3],
            [4, 5, "7"]
        ]}

        self.assertFalse(resource_compare(dict1, dict2))
    def test_resource_compare_with_double_level_list(self):
        dict1 = {list: [
            [1, 2, 3],
            [4, 5, 6]
        ]}

        dict2 = {list: [
            [1, 2, 3],
            [4, 5, "6"]
        ]}

        self.assertTrue(resource_compare(dict1, dict2))
 def test_comparison_list_and_none_level_2(self):
     dict1 = {
         "name": "name",
         "value": {"name": "subresource",
                   "list": ["item1", "item2"]}
     }
     dict2 = {
         "name": "name",
         "value": {"name": "subresource",
                   "list": None}
     }
     self.assertFalse(resource_compare(dict1, dict2))
Exemple #22
0
    def __update(self, data, existent_resource):
        if 'newName' in data:
            data['name'] = data.pop('newName')

        resource_to_update = existent_resource.copy()
        resource_to_update.update(data)

        if resource_compare(existent_resource, resource_to_update):
            return False, UPLINK_SET_ALREADY_EXIST, existent_resource
        else:
            updated_uplink = self.oneview_client.uplink_sets.update(
                resource_to_update)
            return True, UPLINK_SET_UPDATED, updated_uplink
Exemple #23
0
    def __update_settings(self, resource, data):
        self.__validate_settings(data)

        ethernet_settings_merged = self.__merge_network_settings(
            'ethernetSettings', resource, data)
        fcoe_settings_merged = self.__merge_network_settings(
            'fcoeSettings', resource, data)

        if resource_compare(resource['ethernetSettings'], ethernet_settings_merged) and \
                resource_compare(resource['fcoeSettings'], fcoe_settings_merged):

            return False, LOGICAL_INTERCONNECT_NO_CHANGES_PROVIDED, dict(
                logical_interconnect=resource)
        else:
            settings = {
                'ethernetSettings': ethernet_settings_merged,
                'fcoeSettings': fcoe_settings_merged
            }
            li = self.oneview_client.logical_interconnects.update_settings(
                resource['uri'], settings)
            return True, LOGICAL_INTERCONNECT_SETTINGS_UPDATED, dict(
                logical_interconnect=li)
Exemple #24
0
    def __update(self, data, resource):
        merged_data = resource.copy()
        merged_data.update(data)

        changed = False
        msg = RACK_ALREADY_EXIST

        if not resource_compare(resource, merged_data):
            resource = self.oneview_client.racks.update(merged_data)
            changed = True
            msg = RACK_UPDATED

        return changed, msg, resource
Exemple #25
0
    def __update(self, data, resource):
        if "newName" in data:
            data['name'] = data.pop('newName')

        merged_data = resource.copy()
        merged_data.update(data)

        is_equal = resource_compare(resource, merged_data)

        if not is_equal:
            return True, UNMANAGED_DEVICE_UPDATED, self.resource_client.update(merged_data)
        else:
            return False, NOTHING_TO_DO, resource
Exemple #26
0
    def __update_port_monitor(self, uri, data):
        self.__validate_options('portMonitor', data)

        monitor_config = self.__get_port_monitor_configuration(uri)
        monitor_config_merged = self.__merge_options(data['portMonitor'],
                                                     monitor_config)

        if resource_compare(monitor_config_merged, monitor_config):
            return False, LOGICAL_INTERCONNECT_NO_CHANGES_PROVIDED, None
        else:
            monitor_config_updated = self.oneview_client.logical_interconnects.update_port_monitor(
                uri, monitor_config_merged)
            result = dict(port_monitor=monitor_config_updated)
            return True, LOGICAL_INTERCONNECT_PORT_MONITOR_UPDATED, result
Exemple #27
0
    def __update_ethernet_settings(self, resource, data):
        self.__validate_options('ethernetSettings', data)

        ethernet_settings_merged = resource['ethernetSettings'].copy()
        ethernet_settings_merged.update(data['ethernetSettings'])

        if resource_compare(resource['ethernetSettings'],
                            ethernet_settings_merged):
            return False, LOGICAL_INTERCONNECT_NO_CHANGES_PROVIDED, dict()
        else:
            li = self.oneview_client.logical_interconnects.update_ethernet_settings(
                resource['uri'], ethernet_settings_merged)
            return True, LOGICAL_INTERCONNECT_ETH_SETTINGS_UPDATED, dict(
                logical_interconnect=li)
Exemple #28
0
    def __update_qos_configuration(self, uri, data):
        self.__validate_options('qosConfiguration', data)

        qos_config = self.__get_qos_aggregated_configuration(uri)
        qos_config_merged = self.__merge_options(data['qosConfiguration'],
                                                 qos_config)

        if resource_compare(qos_config_merged, qos_config):
            return False, LOGICAL_INTERCONNECT_NO_CHANGES_PROVIDED, dict()
        else:
            qos_config_updated = self.oneview_client.logical_interconnects.update_qos_aggregated_configuration(
                uri, qos_config_merged)

            return True, LOGICAL_INTERCONNECT_QOS_UPDATED, dict(
                qos_configuration=qos_config_updated)
    def test_comparison_list_when_dict_has_diff_key(self):
        dict1 = {
            "name": "name",
            "value": [{'name': 'value1'},
                      {'name': 'value2'},
                      {'name': 3}]
        }

        dict2 = {
            "name": "name",
            "value": [{'count': 3},
                      {'name': 'value1'},
                      {'name': 'value2'}]
        }
        self.assertFalse(resource_compare(dict1, dict2))
    def __update_connection_template(self, ethernet_network, bandwidth):

        if 'connectionTemplateUri' not in ethernet_network:
            return False, None

        connection_template = self.oneview_client.connection_templates.get(ethernet_network['connectionTemplateUri'])

        merged_data = connection_template.copy()
        merged_data.update({'bandwidth': bandwidth})

        if not resource_compare(connection_template, merged_data):
            connection_template = self.oneview_client.connection_templates.update(merged_data)
            return True, connection_template
        else:
            return False, None
    def __update(self, data, resource):
        if resource is None:
            resource = self.__get_by_name(data['newName'])
        data["name"] = data.pop("newName")
        merged_data = resource.copy()
        merged_data.update(data)

        if not resource_compare(resource, merged_data):
            resource = self.i3s_client.artifact_bundles.update(merged_data)
            changed = True
            msg = ARTIFACT_BUNDLE_UPDATED
        else:
            changed = False
            msg = ARTIFACT_BUNDLE_ALREADY_EXIST
        return changed, msg, dict(artifact_bundle=resource)
Exemple #32
0
    def __update_snmp_configuration(self, uri, data):
        self.__validate_options('snmpConfiguration', data)

        snmp_config = self.__get_snmp_configuration(uri)
        snmp_config_merged = self.__merge_options(data['snmpConfiguration'],
                                                  snmp_config)

        if resource_compare(snmp_config_merged, snmp_config):

            return False, LOGICAL_INTERCONNECT_NO_CHANGES_PROVIDED, None
        else:
            snmp_config_updated = self.oneview_client.logical_interconnects.update_snmp_configuration(
                uri, snmp_config_merged)

            return True, LOGICAL_INTERCONNECT_SNMP_UPDATED, dict(
                snmp_configuration=snmp_config_updated)
Exemple #33
0
 def test_comparison_list_and_none_level_2(self):
     dict1 = {
         "name": "name",
         "value": {
             "name": "subresource",
             "list": ["item1", "item2"]
         }
     }
     dict2 = {
         "name": "name",
         "value": {
             "name": "subresource",
             "list": None
         }
     }
     self.assertFalse(resource_compare(dict1, dict2))
    def __update(self, data, resource):
        merged_data = resource.copy()
        merged_data.update(data)
        changed = False

        if resource_compare(resource, merged_data):
            changed = False
            msg = MANAGED_SAN_NO_CHANGES_PROVIDED
        else:
            changed = True
            resource = self.oneview_client.managed_sans.update(
                resource['uri'], data)
            msg = MANAGED_SAN_UPDATED

        return dict(changed=changed,
                    msg=msg,
                    ansible_facts=dict(managed_san=resource))
Exemple #35
0
    def __update(self, data, resource):
        if 'newName' in data:
            data['name'] = data.pop('newName')

        merged_data = resource.copy()
        merged_data.update(data)

        if resource_compare(resource, merged_data):
            self.module.exit_json(changed=False,
                                  msg=SCOPE_ALREADY_EXIST,
                                  ansible_facts=dict(scope=resource))

        else:
            scope_updated = self.oneview_client.scopes.update(merged_data)
            self.module.exit_json(changed=True,
                                  msg=SCOPE_UPDATED,
                                  ansible_facts=dict(scope=scope_updated))
Exemple #36
0
    def __present(self, data, resource):

        server_template_name = data.pop('server_template', '')
        server_hardware_name = data.pop('server_hardware', '')
        server_template = None
        changed = False
        created = False

        ServerProfileReplaceNamesByUris().replace(self.oneview_client, data)

        if server_hardware_name:
            selected_server_hardware = self.__get_server_hardware_by_name(
                server_hardware_name)
            if not selected_server_hardware:
                raise HPOneViewValueError(
                    HARDWARE_NOT_FOUND.format(server_hardware_name))
            data['serverHardwareUri'] = selected_server_hardware['uri']

        if server_template_name:
            server_template = self.oneview_client.server_profile_templates.get_by_name(
                server_template_name)
            if not server_template:
                raise HPOneViewValueError(
                    TEMPLATE_NOT_FOUND.format(server_template_name))
            data['serverProfileTemplateUri'] = server_template['uri']
        elif data.get('serverProfileTemplateUri'):
            server_template = self.oneview_client.server_profile_templates.get(
                data['serverProfileTemplateUri'])

        if not resource:
            resource = self.__create_profile(data, server_template)
            changed = True
            created = True
            msg = SERVER_PROFILE_CREATED
        else:
            merged_data = ServerProfileMerger().merge_data(resource, data)

            if not resource_compare(resource, merged_data):
                resource = self.__update_server_profile(merged_data)
                changed = True
                msg = SERVER_PROFILE_UPDATED
            else:
                msg = SERVER_ALREADY_UPDATED

        return created, changed, msg, resource
Exemple #37
0
 def test_comparison_dict_and_none_level_2(self):
     dict1 = {
         "name": "name",
         "value": {
             "name": "subresource",
             "value": {
                 "name": "sub-sub-resource"
             }
         }
     }
     dict2 = {
         "name": "name",
         "value": {
             "name": "subresource",
             "value": None
         }
     }
     self.assertFalse(resource_compare(dict1, dict2))
    def __update(self, data, resource):
        merged_data = resource.copy()
        merged_data.update(data)

        if resource_compare(resource, merged_data):

            self.module.exit_json(changed=False,
                                  msg=FC_NETWORK_ALREADY_EXIST,
                                  ansible_facts=dict(fc_network=resource))

        else:
            updated_fc_network = self.oneview_client.fc_networks.update(
                merged_data)

            self.module.exit_json(
                changed=True,
                msg=FC_NETWORK_UPDATED,
                ansible_facts=dict(fc_network=updated_fc_network))
    def __update(self, data, resource):
        merged_data = resource.copy()
        merged_data.update(data)

        if resource_compare(resource, merged_data):

            self.module.exit_json(
                changed=False,
                msg=LIG_ALREADY_EXIST,
                ansible_facts=dict(logical_interconnect_group=resource))

        else:
            updated_lig = self.oneview_client.logical_interconnect_groups.update(
                merged_data)

            self.module.exit_json(
                changed=True,
                msg=LIG_UPDATED,
                ansible_facts=dict(logical_interconnect_group=updated_lig))
Exemple #40
0
    def __update(self, new_data, existent_resource):
        merged_data = existent_resource.copy()
        merged_data.update(new_data)

        changed = False
        if "configurationScript" in merged_data:
            changed = self.__update_script(merged_data)

        if not resource_compare(existent_resource, merged_data):
            # update resource
            changed = True
            existent_resource = self.oneview_client.enclosure_groups.update(
                merged_data)

        self.module.exit_json(
            changed=changed,
            msg=ENCLOSURE_GROUP_UPDATED
            if changed else ENCLOSURE_GROUP_ALREADY_EXIST,
            ansible_facts=dict(enclosure_group=existent_resource))
Exemple #41
0
    def __update(self, resource, data):
        merged_data = resource.copy()
        merged_data.update(data)

        # If connectionInfo is not provided, its removed because the password is required for update.
        if 'connectionInfo' not in data:
            merged_data.pop('connectionInfo')

        if resource_compare(resource, merged_data):

            self.module.exit_json(changed=False,
                                  msg=SAN_MANAGER_ALREADY_EXIST,
                                  ansible_facts=dict(san_manager=resource))
        else:
            san_manager = self.oneview_client.san_managers.update(
                resource=merged_data, id_or_uri=resource['uri'])

            self.module.exit_json(changed=True,
                                  msg=SAN_MANAGER_UPDATED,
                                  ansible_facts=dict(san_manager=san_manager))
    def __present(self, data, resource):
        changed = False

        if "newName" in data:
            data["name"] = data.pop("newName")

        if not resource:
            resource = self.i3s_client.plan_scripts.create(data)
            msg = PLAN_SCRIPT_CREATED
            changed = True
        else:
            merged_data = resource.copy()
            merged_data.update(data)

            if not resource_compare(resource, merged_data):
                # update resource
                resource = self.i3s_client.plan_scripts.update(merged_data)
                changed = True
                msg = PLAN_SCRIPT_UPDATED
            else:
                msg = PLAN_SCRIPT_ALREADY_UPDATED

        return changed, msg, dict(plan_script=resource)
Exemple #43
0
    def __present(self, data, resource):

        changed = False
        msg = ''

        if not resource:
            resource = self.oneview_client.storage_volume_templates.create(data)
            changed = True
            msg = STORAGE_VOLUME_TEMPLATE_CREATED
        else:

            merged_data = resource.copy()
            merged_data.update(data)

            if not resource_compare(resource, merged_data):
                # update resource
                changed = True
                resource = self.oneview_client.storage_volume_templates.update(merged_data)
                msg = STORAGE_VOLUME_TEMPLATE_UPDATED
            else:
                msg = STORAGE_VOLUME_TEMPLATE_ALREADY_UPDATED

        return changed, msg, dict(storage_volume_template=resource)
    def test_resource_compare_missing_entry_in_second(self):
        dict2 = self.DICT_EQUAL_ORIGINAL.copy()
        del dict2['state']

        self.assertFalse(resource_compare(self.DICT_ORIGINAL, self.DICT_DIF_ORIGINAL_LV3))
 def test_resource_compare_equals_with_empty_eq_none_inverse(self):
     self.assertTrue(resource_compare(self.DICT_EMPTY_NONE2, self.DICT_EMPTY_NONE1))
 def test_resource_compare_equals_with_empty_eq_none_different(self):
     self.assertFalse(resource_compare(self.DICT_EMPTY_NONE3, self.DICT_EMPTY_NONE1))
    def test_resource_compare_missing_entry_in_first(self):
        dict1 = self.DICT_ORIGINAL.copy()
        del dict1['state']

        self.assertFalse(resource_compare(dict1, self.DICT_EQUAL_ORIGINAL))
 def test_resource_compare_equals(self):
     self.assertTrue(resource_compare(self.DICT_ORIGINAL, self.DICT_EQUAL_ORIGINAL))
    def test_comparison_list_of_dicts_with_diff_order(self):
        resource1 = {'connections': [
            {
                u'allocatedMbps': 0,
                u'networkUri': u'/rest/fc-networks/617a2c3b-1505-4369-a0a5-4c169183bf9d',
                u'requestedMbps': u'2500',
                u'portId': u'None',
                u'name': u'connection2',
                u'maximumMbps': 0,
                u'wwpnType': u'Virtual',
                u'deploymentStatus': u'Reserved',
                u'boot': {
                    u'priority': u'NotBootable',
                    u'chapLevel': u'None',
                    u'initiatorNameSource': u'ProfileInitiatorName'
                },
                u'wwnn': u'10:00:c2:54:96:f0:00:03',
                u'mac': u'46:E0:32:50:00:01',
                u'macType': u'Virtual',
                u'wwpn': u'10:00:c2:54:96:f0:00:02',
                u'interconnectUri': None,
                u'requestedVFs': None,
                u'functionType': u'FibreChannel',
                u'id': 2,
                u'allocatedVFs': None
            },
            {
                u'allocatedMbps': 1000,
                u'networkUri': u'/rest/ethernet-networks/7704a66f-fa60-4375-8e9d-e72111bf4b3a',
                u'requestedMbps': u'1000',
                u'portId': u'Flb 1:1-a',
                u'name': u'connection3',
                u'maximumMbps': 1000,
                u'wwpnType': u'Virtual',
                u'deploymentStatus': u'Deployed',
                u'boot': {
                    u'priority': u'NotBootable',
                    u'chapLevel': u'None',
                    u'initiatorNameSource': u'ProfileInitiatorName'
                },
                u'wwnn': None,
                u'mac': u'46:E0:32:50:00:02',
                u'macType': u'Virtual',
                u'wwpn': None,
                u'interconnectUri': u'/rest/interconnects/6930962f-8aba-42ac-8bbc-3794890ea945',
                u'requestedVFs': u'Auto',
                u'functionType': u'Ethernet',
                u'id': 3,
                u'allocatedVFs': None
            },
            {
                u'allocatedMbps': 1000,
                u'networkUri': u'/rest/ethernet-networks/7704a66f-fa60-4375-8e9d-e72111bf4b3a',
                u'requestedMbps': u'1000',
                u'portId': u'Flb 1:2-a',
                u'name': u'connection4',
                u'maximumMbps': 1000,
                u'wwpnType': u'Virtual',
                u'deploymentStatus': u'Deployed',
                u'boot': {
                    u'priority': u'NotBootable',
                    u'chapLevel': u'None',
                    u'initiatorNameSource': u'ProfileInitiatorName'
                },
                u'wwnn': None,
                u'mac': u'46:E0:32:50:00:03',
                u'macType': u'Virtual',
                u'wwpn': None,
                u'interconnectUri': u'/rest/interconnects/a3c936f2-2993-4779-a6e3-dc302b6f1bc6',
                u'requestedVFs': u'Auto',
                u'functionType': u'Ethernet',
                u'id': 4,
                u'allocatedVFs': None
            },
            {
                u'allocatedMbps': 2500,
                u'networkUri': u'/rest/fc-networks/179222e0-d59e-4898-b2bf-5c053c872ee6',
                u'requestedMbps': u'2500',
                u'portId': u'Flb 1:1-b',
                u'name': u'connection1',
                u'maximumMbps': 10000,
                u'wwpnType': u'Virtual',
                u'deploymentStatus': u'Deployed',
                u'boot': {
                    u'priority': u'NotBootable',
                    u'chapLevel': u'None',
                    u'initiatorNameSource': u'ProfileInitiatorName'
                },
                u'wwnn': u'10:00:c2:54:96:f0:00:01',
                u'mac': u'46:E0:32:50:00:00',
                u'macType': u'Virtual',
                u'wwpn': u'10:00:c2:54:96:f0:00:00',
                u'interconnectUri': u'/rest/interconnects/6930962f-8aba-42ac-8bbc-3794890ea945',
                u'requestedVFs': None,
                u'functionType': u'FibreChannel',
                u'id': 1,
                u'allocatedVFs': None
            }
        ]
        }

        resource2 = {'connections': [
            {
                u'requestedMbps': 1000,
                u'deploymentStatus': u'Deployed',
                u'networkUri': u'/rest/ethernet-networks/7704a66f-fa60-4375-8e9d-e72111bf4b3a',
                u'mac': u'46:E0:32:50:00:02',
                u'wwpnType': u'Virtual',
                u'id': 3,
                u'macType': u'Virtual',
                u'allocatedMbps': 1000,
                u'wwnn': None,
                u'maximumMbps': 1000,
                u'portId': u'Flb 1:1-a',
                u'name': 'connection3',
                u'functionType': 'Ethernet',
                u'boot': {
                    u'priority': 'NotBootable',
                    u'chapLevel': u'None',
                    u'initiatorNameSource': u'ProfileInitiatorName'
                },
                u'allocatedVFs': None,
                u'wwpn': None,
                u'interconnectUri': u'/rest/interconnects/6930962f-8aba-42ac-8bbc-3794890ea945',
                u'requestedVFs': u'Auto'
            },
            {
                u'requestedMbps': 1000,
                u'deploymentStatus': u'Deployed',
                u'networkUri': u'/rest/ethernet-networks/7704a66f-fa60-4375-8e9d-e72111bf4b3a',
                u'mac': u'46:E0:32:50:00:03',
                u'wwpnType': u'Virtual',
                u'id': 4,
                u'macType': u'Virtual',
                u'allocatedMbps': 1000,
                u'wwnn': None,
                u'maximumMbps': 1000,
                u'portId': u'Flb 1:2-a',
                u'name': 'connection4',
                u'functionType': 'Ethernet',
                u'boot': {
                    u'priority': 'NotBootable',
                    u'chapLevel': u'None',
                    u'initiatorNameSource': u'ProfileInitiatorName'
                },
                u'allocatedVFs': None,
                u'wwpn': None,
                u'interconnectUri': u'/rest/interconnects/a3c936f2-2993-4779-a6e3-dc302b6f1bc6',
                u'requestedVFs': u'Auto'
            },
            {
                u'requestedMbps': 2500,
                u'deploymentStatus': u'Deployed',
                u'networkUri': u'/rest/fc-networks/179222e0-d59e-4898-b2bf-5c053c872ee6',
                u'mac': u'46:E0:32:50:00:00',
                u'wwpnType': u'Virtual',
                u'id': 1,
                u'macType': u'Virtual',
                u'allocatedMbps': 2500,
                u'wwnn': u'10:00:c2:54:96:f0:00:01',
                u'maximumMbps': 10000,
                u'portId': u'Flb 1:1-b',
                u'name': 'connection1',
                u'functionType': 'FibreChannel',
                u'boot': {
                    u'priority': 'NotBootable',
                    u'chapLevel': u'None',
                    u'initiatorNameSource': u'ProfileInitiatorName'
                },
                u'allocatedVFs': None,
                u'wwpn': u'10:00:c2:54:96:f0:00:00',
                u'interconnectUri': u'/rest/interconnects/6930962f-8aba-42ac-8bbc-3794890ea945',
                u'requestedVFs': None
            },
            {
                u'requestedMbps': 2500,
                u'deploymentStatus': u'Reserved',
                u'networkUri': u'/rest/fc-networks/617a2c3b-1505-4369-a0a5-4c169183bf9d',
                u'mac': u'46:E0:32:50:00:01',
                u'wwpnType': u'Virtual',
                u'id': 2,
                u'macType': u'Virtual',
                u'allocatedMbps': 0,
                u'wwnn': u'10:00:c2:54:96:f0:00:03',
                u'maximumMbps': 0,
                u'portId': 'None',
                u'name': 'connection2',
                u'functionType': 'FibreChannel',
                u'boot': {
                    u'priority': 'NotBootable',
                    u'chapLevel': u'None',
                    u'initiatorNameSource': u'ProfileInitiatorName'
                },
                u'allocatedVFs': None,
                u'wwpn': u'10:00:c2:54:96:f0:00:02',
                u'interconnectUri': None,
                u'requestedVFs': None
            }
        ]
        }

        self.assertTrue(resource_compare(resource1, resource2))
 def test_resource_compare_different_on_level3(self):
     self.assertFalse(resource_compare(self.DICT_ORIGINAL, self.DICT_DIF_ORIGINAL_LV3))