#!/usr/bin/env python

# Copyright (C) 2017
# ASTRON (Netherlands Institute for Radio Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This file is part of the LOFAR software suite.
# The LOFAR software suite is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# The LOFAR software suite is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.

import unittest
import mock
import datetime
import sys

from lofar.sas.resourceassignment.resourceassigner.assignment import ResourceAssigner
from lofar.parameterset import parameterset

ra_notification_prefix = "ra_notification_prefix"


class TestingResourceAssigner(ResourceAssigner):
    def __init__(self, rarpc, rerpc, otdbrpc, momrpc, curpc, sqrpc, ra_notification_bus):
        # super gets not done to be able to insert mocks as early as possible otherwise the RPC block unittesting
        self.radbrpc = rarpc
        self.rerpc = rerpc
        self.otdbrpc = otdbrpc
        self.momrpc = momrpc
        self.curpc = curpc
        self.sqrpc = sqrpc
        self.ra_notification_bus = ra_notification_bus
        self.ra_notification_prefix = ra_notification_prefix


class ResourceAssignerTest(unittest.TestCase):
    mom_id = 351557
    otdb_id = 1290494
    specification_id = 2323
    state = u'prescheduled'
    task_type = u'pipeline'

    specification_tree = {}

    non_approved_or_prescheduled_status = u'opened'
    non_approved_or_prescheduled_otdb_id = 1

    future_start_time = (datetime.datetime.utcnow() + datetime.timedelta(hours=1)).strftime('%Y-%m-%d %H:%M:%S')
    future_stop_time = (datetime.datetime.utcnow() + datetime.timedelta(hours=2)).strftime('%Y-%m-%d %H:%M:%S')
    task_duration = 3600

    non_approved_or_prescheduled_specification_tree = {
        u'otdb_id': non_approved_or_prescheduled_otdb_id,
        u'task_type': u'pipeline',
        u'state': non_approved_or_prescheduled_status,
        u'specification': {
            u'Observation.startTime': future_start_time,
            u'Observation.stopTime': future_stop_time
        }
    }

    approved_status = u'approved'
    approved_otdb_id = 22
    approved_specification_tree = {
        u'otdb_id': approved_otdb_id,
        u'task_type': u'pipeline',
        u'state': approved_status,
        u'specification': {
            u'Observation.startTime': future_start_time,
            u'Observation.stopTime': future_stop_time
        }
    }

    cep2_specification_tree = {
        u'otdb_id': otdb_id,
        u'task_type': u'pipeline',
        u'state': u'prescheduled',
        u'specification': {
            u'Observation.startTime': future_start_time,
            u'Observation.stopTime': future_stop_time,
            u'Observation.DataProducts.Output_Pulsar.enabled': True,
            u'Observation.DataProducts.Output_Pulsar.storageClusterName': u'CEP2'
        }
    }

    mom_bug_processing_cluster_name = 'CEP2'
    mom_bug_otdb_id = 1234
    mom_bug_specification_tree = {
        u'otdb_id': mom_bug_otdb_id,
        u'task_type': u'pipeline',
        u'state': u'prescheduled',
        u'specification': {
            u'Observation.startTime': future_start_time,
            u'Observation.stopTime': future_stop_time,
            u'Observation.DataProducts.Output_Pulsar.enabled': True,
            u'Observation.DataProducts.Output_Pulsar.storageClusterName': u'CEP4',
            u'Observation.Cluster.ProcessingCluster.clusterName': mom_bug_processing_cluster_name
        }
    }

    maintenance_otdb_id = 5678
    maintenance_specification_tree = {
        u'otdb_id': maintenance_otdb_id,
        u'task_type': u'reservation',
        u'task_subtype': u'maintenance',
        u'state': u'prescheduled',
        u'specification': {
            u'Observation.startTime': future_start_time,
            u'Observation.stopTime': future_stop_time,
            u'Observation.VirtualInstrument.stationList': [u'CS001'],
        }
    }

    projectreservation_otdb_id = 8765
    projectreservation_specification_tree = {
        u'otdb_id': projectreservation_otdb_id,
        u'task_type': u'reservation',
        u'task_subtype': u'project',
        u'state': u'prescheduled',
        u'specification': {
            u'Observation.startTime': future_start_time,
            u'Observation.stopTime': future_stop_time,
            u'Observation.VirtualInstrument.stationList': [u'CS001'],
        }
    }

    task_mom_id = 351543
    task_otdb_id = 1290472
    task_id = 2299
    task_end_time = datetime.datetime(2016, 3, 25, 22, 47, 31)
    task_start_time = datetime.datetime(2016, 3, 25, 21, 47, 31)

    non_existing_task_mom_id = -1

    predecessor_task_mom_id = 1
    predecessor_task_otdb_id = 2
    predecessor_task_id = 3
    predecessor_task = {
        "mom_id": predecessor_task_mom_id,
        "otdb_id": predecessor_task_otdb_id,
        "id": predecessor_task_id,
        "endtime": datetime.datetime(2016, 3, 25, 22, 47, 31),
        "name": "IS HBA_DUAL",
        "predecessor_ids": [],
        "project_mom_id": 2,
        "project_name": "test-lofar",
        "specification_id": 2323,
        "starttime": datetime.datetime(2016, 3, 25, 21, 47, 31),
        "status": "prescheduled",
        "status_id": 350,
        "successor_ids": [],
        "type": "pipeline",
        "type_id": 0
    }

    successor_task_mom_id = 4
    successor_task_otdb_id = 5
    successor_task_id = 6
    successor_task = {
        "mom_id": successor_task_mom_id,
        "otdb_id": successor_task_otdb_id,
        "id": successor_task_id,
        "endtime": datetime.datetime(2016, 3, 25, 22, 47, 31),
        "name": "IS HBA_DUAL",
        "predecessor_ids": [],
        "project_mom_id": 2,
        "project_name": "test-lofar",
        "specification_id": 2323,
        "starttime": datetime.datetime(2016, 3, 25, 21, 47, 31),
        "status": "prescheduled",
        "status_id": 350,
        "successor_ids": [],
        "type": "pipeline",
        "type_id": 0
    }

    resources_with_rcus_otdb_id = 1290495
    resources_with_errors_otdb_id = 1290496
    resource_error1 = "error 1"
    resource_error2 = "error 2"
    unknown_resource_type_name = "fuel"
    unknown_resource_type_otdb_id = 123489

    rerpc_status = 0
    rerpc_needed_claim_for_bandwidth_size = 2
    rerpc_needed_claim_for_bandwidth = {
        'total_size': rerpc_needed_claim_for_bandwidth_size
    }

    rerpc_needed_claim_for_storage_output_files = {
        'uv': {
            'nr_of_uv_files': 481,
            'uv_file_size': 1482951104
        },
        'saps': [
            {
                'sap_nr': 0,
                'properties': {
                    'nr_of_uv_files': 319
                }
            },
            {
                'sap_nr': 1,
                'properties': {
                    'nr_of_uv_files': 81,
                }
            },
            {
                'sap_nr': 2,
                'properties': {
                    'nr_of_uv_files': 81
                }
            }
        ]
    }
    rerpc_needed_claim_for_storage_size = 2
    rerpc_needed_claim_for_storage = {
        'total_size': rerpc_needed_claim_for_storage_size,
        'output_files': rerpc_needed_claim_for_storage_output_files
    }
    rerpc_replymessage = {
        str(otdb_id): {
            'pipeline': {
                'errors': [],
                'estimates': [{
                    'resource_types': {'bandwidth': 2, 'storage': 2},
                    'resource_count': 2, 'root_resource_group': 'CEP4',
                    'output_files': {
                        'uv': [{'sap_nr': 0, 'identifications': [],
                                'properties': {'uv_file_size': 1073741824, 'nr_of_uv_files': 1, 'start_sb_nr': 0}
                               }]
                    }
                }]
            }
        },
        str(resources_with_rcus_otdb_id): {
            'observation': {
                'errors': [],
                'estimates': [{
                        'resource_types': {'rcu': '111100010111100101101010' },
                        'resource_count': 1,
                        'root_resource_group': 'CS001'
                }]
            }
        },
        str(resources_with_errors_otdb_id): {
            'pipeline': {
                'estimates': [{
                    'resource_types': {'bandwidth': 19021319494, 'storage': 713299481024},
                    'output_files': {
                        'uv': [{'sap_nr': 0,
                                'properties': {'nr_of_uv_files': 319, 'uv_file_size': 1482951104}
                               },
                               {'sap_nr': 1,
                                'properties': {'nr_of_uv_files': 81, 'uv_file_size': 1482951104}
                               },
                               {'sap_nr': 2,
                                'properties': {'nr_of_uv_files': 81, 'uv_file_size': 1482951104}
                               }]
                     }
                }],
                'errors': [resource_error1, resource_error2]
            }
        },
        str(unknown_resource_type_otdb_id): {
            'pipeline': {
                str(unknown_resource_type_name): {
                }
            }
        },
        str(maintenance_otdb_id): {
            'reservation': {'errors': [],
                  'estimates': [{'resource_count': 1,
                                 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'},
                                 'root_resource_group': 'CS001'},
                                # TODO: I'm leaving this here to check the order issue in the getResourceGroupMemberships.return_value
                                # {'resource_count': 1,
                                #  'resource_types': {'bandwidth': 3000000000,
                                #                     'rsp': 3904},
                                #  'root_resource_group': 'CS001RSP0'},
                                # {'resource_count': 1,
                                #  'resource_types': {'bandwidth': 3000000000,
                                #                     'rsp': 3904},
                                #  'root_resource_group': 'CS001RSP1'},
                                # {'resource_count': 1,
                                #  'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'},
                                #  'root_resource_group': 'CS002'},
                                # {'resource_count': 1,
                                #  'resource_types': {'bandwidth': 3000000000,
                                #                     'rsp': 3904},
                                #  'root_resource_group': 'CS002RSP0'},
                                # {'resource_count': 1,
                                #  'resource_types': {'bandwidth': 3000000000,
                                #                     'rsp': 3904},
                                #  'root_resource_group': 'CS002RSP1'},
                                ]}}
        ,
        str(projectreservation_otdb_id): {
            'reservation': {'errors': [],
                   'estimates': [{'resource_count': 1,
                                 'resource_types': {'rcu': '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'},
                                 'root_resource_group': 'CS001'},
                                ]}}
        }

    cep4bandwidth_resource_id = 116
    cep4storage_resource_id = 117

    storage_claim = {
        'resource_id': cep4storage_resource_id,
	    'resource_type_id': 5,
        'starttime': task_start_time,
        'used_rcus': None,
        'endtime': task_end_time + datetime.timedelta(days=365),
        'status': 'tentative',
        'claim_size': rerpc_needed_claim_for_storage_size,
        'properties': [
            {'io_type': 'output', 'type': 15, 'sap_nr': 0, 'value': 0},
            {'io_type': 'output', 'type': 2, 'sap_nr': 0, 'value': 1},
            {'io_type': 'output', 'type': 10, 'sap_nr': 0, 'value': 1073741824}
        ]
    }

    bandwidth_claim = {
        'resource_id': cep4bandwidth_resource_id,
	    'resource_type_id': 3,
        'starttime': task_start_time,
        'used_rcus': None,
        'endtime': task_end_time,
        'status': 'tentative',
        'claim_size': rerpc_needed_claim_for_bandwidth_size,
        'properties': []
    }

    specification_claims = [bandwidth_claim, storage_claim]

    def reset_specification_tree(self):
        self.specification_tree = {
            u'otdb_id': self.otdb_id,
            u'task_type': self.task_type,
            u'state': self.state,
            u'specification': {
                u'Observation.momID': str(self.mom_id),
                u'Observation.startTime': self.future_start_time,
                u'Observation.stopTime': self.future_stop_time,
                u'Observation.DataProducts.Output_InstrumentModel.enabled': False,
                u'Observation.VirtualInstrument.stationList': [],
                u'Observation.DataProducts.Input_CoherentStokes.enabled': False,
                u'Observation.DataProducts.Output_CoherentStokes.enabled': False,
                u'Observation.DataProducts.Input_Correlated.skip': [0, 0, 0, 0],
                u'Observation.antennaSet': u'LBA_INNER',
                u'Observation.nrBitsPerSample': u'16',
                u'Observation.ObservationControl.PythonControl.LongBaseline.subbandgroups_per_ms': u'2',
                u'Observation.DataProducts.Output_IncoherentStokes.enabled': False,
                u'Observation.DataProducts.Input_IncoherentStokes.enabled': False,
                u'Observation.DataProducts.Input_Correlated.enabled': True,
                u'Observation.DataProducts.Output_Pulsar.enabled': False,
                u'Observation.DataProducts.Input_CoherentStokes.skip': [],
                u'Observation.DataProducts.Output_SkyImage.enabled': False,
                u'Version.number': u'33774',
                u'Observation.ObservationControl.PythonControl.LongBaseline.subbands_per_subbandgroup': u'2',
                u'Observation.nrBeams': u'0',
                u'Observation.DataProducts.Input_IncoherentStokes.skip': [],
                u'Observation.DataProducts.Output_Correlated.enabled': True,
                u'Observation.DataProducts.Output_Correlated.storageClusterName': 'CEP4',
                u'Observation.sampleClock': u'200',
                u'Observation.Cluster.ProcessingCluster.clusterName': 'CEP4'
            },
            u'task_subtype': u'long baseline pipeline',
            u'predecessors': [{
                u'task_subtype': u'averaging pipeline',
                u'specification': {
                    u'Observation.DataProducts.Output_InstrumentModel.enabled': False,
                    u'Observation.stopTime': u'2016-03-25 13:51:05',
                    u'Observation.VirtualInstrument.stationList': [],
                    u'Observation.DataProducts.Input_CoherentStokes.enabled': False,
                    u'Observation.DataProducts.Output_CoherentStokes.enabled': False,
                    u'Observation.DataProducts.Output_SkyImage.enabled': False,
                    u'Observation.DataProducts.Input_Correlated.skip': [0, 0, 0, 0],
                    u'Observation.antennaSet': u'LBA_INNER',
                    u'Observation.nrBitsPerSample': u'16',
                    u'Observation.ObservationControl.PythonControl.LongBaseline.subbandgroups_per_ms': u'1',
                    u'Observation.DataProducts.Output_IncoherentStokes.enabled': False,
                    u'Observation.DataProducts.Input_IncoherentStokes.enabled': False,
                    u'Observation.DataProducts.Input_Correlated.enabled': True,
                    u'Observation.DataProducts.Output_Pulsar.enabled': False,
                    u'Observation.DataProducts.Input_CoherentStokes.skip': [],
                    u'Observation.ObservationControl.PythonControl.DPPP.demixer.demixtimestep': u'10',
                    u'Version.number': u'33774',
                    u'Observation.momID': u'351556',
                    u'Observation.startTime': u'2016-03-25 13:49:55',
                    u'Observation.ObservationControl.PythonControl.LongBaseline.subbands_per_subbandgroup': u'1',
                    u'Observation.nrBeams': u'0',
                    u'Observation.DataProducts.Input_IncoherentStokes.skip': [],
                    u'Observation.ObservationControl.PythonControl.DPPP.demixer.demixfreqstep': u'64',
                    u'Observation.DataProducts.Output_Correlated.enabled': True,
                    u'Observation.sampleClock': u'200'
                },
                u'task_type': u'pipeline',
                u'otdb_id': 1290496,
                u'predecessors': [{
                    u'task_subtype': u'bfmeasurement',
                    u'specification': {
                        u'Observation.DataProducts.Output_InstrumentModel.enabled': False,
                        u'Observation.ObservationControl.OnlineControl.Cobalt.BeamFormer.IncoherentStokes.timeIntegrationFactor': u'1',
                        u'Observation.stopTime': u'2016-03-26 00:33:31',
                        u'Observation.VirtualInstrument.stationList': [u'RS205', u'RS503', u'CS013', u'RS508',
                                                                       u'RS106'],
                        u'Observation.DataProducts.Input_CoherentStokes.enabled': False,
                        u'Observation.DataProducts.Output_CoherentStokes.enabled': False,
                        u'Observation.ObservationControl.OnlineControl.Cobalt.Correlator.nrChannelsPerSubband': u'64',
                        u'Observation.ObservationControl.OnlineControl.Cobalt.BeamFormer.IncoherentStokes.which': u'I',
                        u'Observation.ObservationControl.OnlineControl.Cobalt.BeamFormer.CoherentStokes.which': u'I',
                        u'Observation.Beam[0].subbandList': [100, 101, 102, 103],
                        u'Observation.ObservationControl.OnlineControl.Cobalt.BeamFormer.IncoherentStokes.subbandsPerFile': u'512',
                        u'Observation.DataProducts.Input_Correlated.skip': [],
                        u'Observation.antennaSet': u'HBA_DUAL',
                        u'Observation.nrBitsPerSample': u'8',
                        u'Observation.Beam[0].nrTabRings': u'0',
                        u'Observation.Beam[0].nrTiedArrayBeams': u'0',
                        u'Observation.ObservationControl.OnlineControl.Cobalt.BeamFormer.flysEye': False,
                        u'Observation.nrBeams': u'1',
                        u'Observation.ObservationControl.OnlineControl.Cobalt.Correlator.integrationTime': u'1.0',
                        u'Observation.DataProducts.Output_IncoherentStokes.enabled': False,
                        u'Observation.DataProducts.Input_IncoherentStokes.enabled': False,
                        u'Observation.DataProducts.Input_Correlated.enabled': False,
                        u'Observation.DataProducts.Output_Pulsar.enabled': False,
                        u'Observation.DataProducts.Input_CoherentStokes.skip': [],
                        u'Observation.DataProducts.Output_SkyImage.enabled': False,
                        u'Version.number': u'33774',
                        u'Observation.ObservationControl.OnlineControl.Cobalt.BeamFormer.CoherentStokes.timeIntegrationFactor': u'1',
                        u'Observation.momID': u'351539',
                        u'Observation.startTime': u'2016-03-26 00:31:31',
                        u'Observation.ObservationControl.OnlineControl.Cobalt.BeamFormer.CoherentStokes.subbandsPerFile': u'512',
                        u'Observation.DataProducts.Input_IncoherentStokes.skip': [],
                        u'Observation.DataProducts.Output_Correlated.enabled': True,
                        u'Observation.sampleClock': u'200'
                    },
                    u'task_type': u'observation',
                    u'otdb_id': 1290476,
                    u'predecessors': []
                }]
            }]
        }

    def reset_task(self):
        self.task = {
            "mom_id": self.task_mom_id,
            "otdb_id": self.task_otdb_id,
            "id": self.task_id,
            "endtime": self.task_end_time,
            "name": "IS HBA_DUAL",
            "predecessor_ids": [],
            "project_mom_id": 2,
            "project_name": "test-lofar",
            "specification_id": self.specification_id,
            "starttime": self.task_start_time,
            "status": "prescheduled",
            "status_id": 350,
            "successor_ids": [],
            "type": "pipeline",
            "type_id": 0
        }

    def setUp(self):
        self.reset_task()

        def get_task_side_effect(*args, **kwargs):
            if 'mom_id' in kwargs:
                if kwargs['mom_id'] == self.successor_task_mom_id:
                    return self.successor_task
                elif kwargs['mom_id'] == self.predecessor_task_mom_id:
                    return self.predecessor_task
                elif kwargs['mom_id'] == self.non_existing_task_mom_id:
                    return None
                else:
                    return self.task
            else:
                return self.task

        self.successor_task_mom_ids = [self.successor_task_mom_id]
        self.predecessor_task_mom_ids = [self.predecessor_task_mom_id]

        rarpc_patcher = mock.patch('lofar.sas.resourceassignment.resourceassignmentservice.rpc.RARPC')
        self.addCleanup(rarpc_patcher.stop)
        self.rarpc_mock = rarpc_patcher.start()
        self.rarpc_mock.getTask.side_effect = get_task_side_effect
        self.rarpc_mock.insertSpecificationAndTask.return_value = {
            'inserted': True,
            'specification_id': self.specification_id,
            'task_id': self.task_id
        }
        self.rarpc_mock.getResourceClaimPropertyTypes.return_value = [
            {'id': 0, 'name': 'nr_of_is_files'},
            {'id': 1, 'name': 'nr_of_cs_files'},
            {'id': 2, 'name': 'nr_of_uv_files'},
            {'id': 3, 'name': 'nr_of_im_files'},
            {'id': 4, 'name': 'nr_of_img_files'},
            {'id': 5, 'name': 'nr_of_pulp_files'},
            {'id': 6, 'name': 'nr_of_cs_stokes'},
            {'id': 7, 'name': 'nr_of_is_stokes'},
            {'id': 8, 'name': 'is_file_size'},
            {'id': 9, 'name': 'cs_file_size'},
            {'id': 10, 'name': 'uv_file_size'},
            {'id': 11, 'name': 'im_file_size'},
            {'id': 12, 'name': 'img_file_size'},
            {'id': 13, 'name': 'nr_of_pulp_files'},
            {'id': 14, 'name': 'nr_of_cs_parts'},
            {'id': 15, 'name': 'start_sb_nr'},
            {'id': 16, 'name': 'uv_otdb_id'},
            {'id': 17, 'name': 'cs_otdb_id'},
            {'id': 18, 'name': 'is_otdb_id'},
            {'id': 19, 'name': 'im_otdb_id'},
            {'id': 20, 'name': 'img_otdb_id'},
            {'id': 21, 'name': 'pulp_otdb_id'},
            {'id': 22, 'name': 'is_tab_nr'},
            {'id': 23, 'name': 'start_sbg_nr'},
            {'id': 24, 'name': 'pulp_file_size'}
        ]
        self.rarpc_mock.getResourceTypes.return_value = [
            {'id': 0, 'name': 'rsp', 'unit_id': 0, 'units': 'rsp_channel_bit'},
            {'id': 1, 'name': 'tbb', 'unit_id': 1, 'units': 'bytes'},
            {'id': 2, 'name': 'rcu', 'unit_id': 2, 'units': 'rcu_board'},
            {'id': 3, 'name': 'bandwidth', 'unit_id': 3, 'units': 'bits/second'},
            {'id': 4, 'name': 'processor', 'unit_id': 4, 'units': 'cores'},
            {'id': 5, 'name': 'storage', 'unit_id': 1, 'units': 'bytes'},
        ]
        self.rarpc_mock.insertResourceClaims.return_value = {'ids': [1, 2]}

        self.rarpc_mock.getResourceGroupNames.return_value = [{"name": "CEP4"}, {"name": "DRAGNET"}, {"name": "COBALT"}]

        self.rarpc_mock.getResourceGroupMemberships.return_value = {'groups': [
            {'resource_group_parent_id': None, 'resource_group_parent_name': None, 'resource_group_id': 0,
             'resource_group_name': 'CORE', 'child_ids': [1, 2], 'parent_ids': [], 'resource_ids': [0, 1]},
            {'resource_group_parent_id': None, 'resource_group_parent_name': None, 'resource_group_id': 3,
             'resource_group_name': 'CS001', 'child_ids': [], 'parent_ids': [0], 'resource_ids': [212]},
            {'resource_group_parent_id': None, 'resource_group_parent_name': None, 'resource_group_id': 1,
             'resource_group_name': 'CEP4', 'child_ids': [], 'parent_ids': [0], 'resource_ids': [116, 117]},
            # {'resource_group_parent_id': None, 'resource_group_parent_name': None, 'resource_group_id': 4,   # TODO: WHY DOES ORDER MATTER IN HERE???
            #  'resource_group_name': 'CS002', 'child_ids': [], 'parent_ids': [0], 'resource_ids': [214]},     # TODO: check what happens when this is moved after e.g. CS001; also comment in CS002 in RE response
            ],
            'resources': [{'resource_group_parent_id': 0,
                           'resource_group_parent_name': 'CORE',
                           'resource_id': 0,
                           'resource_name': 'CS001',
                           'parent_group_ids': []},
                          {'resource_group_parent_id': 0,
                           'resource_group_parent_name': 'CORE',
                           'resource_id': 1,
                           'resource_name': 'CS002',
                           'parent_group_ids': []},
                          {'resource_group_parent_id': 1,
                           'resource_group_parent_name': 'CEP4',
                           'resource_id': 2,
                           'resource_name': 'CEP4_storage:/data',
                           'parent_group_ids': []}]}

        # incomplete response but good enough for tests
        self.rarpc_mock.getResources.return_value = [
            {'id': 0, 'name': 'cpunode01_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 1, 'name': 'cpunode01_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 2, 'name': 'cpunode02_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 3, 'name': 'cpunode02_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 4, 'name': 'cpunode03_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 5, 'name': 'cpunode03_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 6, 'name': 'cpunode04_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 7, 'name': 'cpunode04_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 8, 'name': 'cpunode05_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 9, 'name': 'cpunode05_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 10, 'name': 'cpunode06_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 11, 'name': 'cpunode06_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 12, 'name': 'cpunode07_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 13, 'name': 'cpunode07_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 14, 'name': 'cpunode08_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 15, 'name': 'cpunode08_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 16, 'name': 'cpunode09_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 17, 'name': 'cpunode09_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 18, 'name': 'cpunode10_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 19, 'name': 'cpunode10_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 20, 'name': 'cpunode11_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 21, 'name': 'cpunode11_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 22, 'name': 'cpunode12_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 23, 'name': 'cpunode12_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 24, 'name': 'cpunode13_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 25, 'name': 'cpunode13_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 26, 'name': 'cpunode14_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 27, 'name': 'cpunode14_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 28, 'name': 'cpunode15_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 29, 'name': 'cpunode15_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 30, 'name': 'cpunode16_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 31, 'name': 'cpunode16_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 32, 'name': 'cpunode17_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 33, 'name': 'cpunode17_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 34, 'name': 'cpunode18_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 35, 'name': 'cpunode18_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 36, 'name': 'cpunode19_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 37, 'name': 'cpunode19_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 38, 'name': 'cpunode20_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 39, 'name': 'cpunode20_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 40, 'name': 'cpunode21_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 41, 'name': 'cpunode21_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 42, 'name': 'cpunode22_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 43, 'name': 'cpunode22_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 44, 'name': 'cpunode23_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 45, 'name': 'cpunode23_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 46, 'name': 'cpunode24_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 47, 'name': 'cpunode24_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 48, 'name': 'cpunode25_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 49, 'name': 'cpunode25_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 50, 'name': 'cpunode26_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 51, 'name': 'cpunode26_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 52, 'name': 'cpunode27_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 53, 'name': 'cpunode27_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 54, 'name': 'cpunode28_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 55, 'name': 'cpunode28_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 56, 'name': 'cpunode29_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 57, 'name': 'cpunode29_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 58, 'name': 'cpunode30_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 59, 'name': 'cpunode30_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 60, 'name': 'cpunode31_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 61, 'name': 'cpunode31_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 62, 'name': 'cpunode32_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 63, 'name': 'cpunode32_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 64, 'name': 'cpunode33_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 65, 'name': 'cpunode33_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 66, 'name': 'cpunode34_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 67, 'name': 'cpunode34_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 68, 'name': 'cpunode35_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 69, 'name': 'cpunode35_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 70, 'name': 'cpunode36_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 71, 'name': 'cpunode36_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 72, 'name': 'cpunode37_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 73, 'name': 'cpunode37_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 74, 'name': 'cpunode38_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 75, 'name': 'cpunode38_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 76, 'name': 'cpunode39_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 77, 'name': 'cpunode39_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 78, 'name': 'cpunode40_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 79, 'name': 'cpunode40_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 80, 'name': 'cpunode41_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 81, 'name': 'cpunode41_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 82, 'name': 'cpunode42_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 83, 'name': 'cpunode42_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 84, 'name': 'cpunode43_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 85, 'name': 'cpunode43_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 86, 'name': 'cpunode44_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 87, 'name': 'cpunode44_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 88, 'name': 'cpunode45_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 89, 'name': 'cpunode45_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 90, 'name': 'cpunode46_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 91, 'name': 'cpunode46_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 92, 'name': 'cpunode47_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 93, 'name': 'cpunode47_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 94, 'name': 'cpunode48_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 95, 'name': 'cpunode48_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 96, 'name': 'cpunode49_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 97, 'name': 'cpunode49_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 98, 'name': 'cpunode50_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 99, 'name': 'cpunode50_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 100, 'name': 'cbt001_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 101, 'name': 'cbt001_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 102, 'name': 'cbt002_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 103, 'name': 'cbt002_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 104, 'name': 'cbt003_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 105, 'name': 'cbt003_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 106, 'name': 'cbt004_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 107, 'name': 'cbt004_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 108, 'name': 'cbt005_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 109, 'name': 'cbt005_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 110, 'name': 'cbt006_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 111, 'name': 'cbt006_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 112, 'name': 'cbt007_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 113, 'name': 'cbt007_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 114, 'name': 'cbt008_bandwidth', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 115, 'name': 'cbt008_processors', 'type_id': 4, 'type_name': 'processor', 'unit_id': 4,
             'unit': 'cores', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 116, 'name': 'CEP4_bandwidth:/data', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 117, 'name': 'CEP4_storage:/data', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 118, 'name': 'dragproc_bandwidth:/data', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 119, 'name': 'dragproc_storage:/data', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 120, 'name': 'drg01_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 121, 'name': 'drg01_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 122, 'name': 'drg01_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 123, 'name': 'drg01_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 124, 'name': 'drg02_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 125, 'name': 'drg02_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 126, 'name': 'drg02_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 127, 'name': 'drg02_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 128, 'name': 'drg03_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 129, 'name': 'drg03_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 130, 'name': 'drg03_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 131, 'name': 'drg03_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 132, 'name': 'drg04_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 133, 'name': 'drg04_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 134, 'name': 'drg04_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 135, 'name': 'drg04_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 136, 'name': 'drg05_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 137, 'name': 'drg05_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 138, 'name': 'drg05_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 139, 'name': 'drg05_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 140, 'name': 'drg06_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 141, 'name': 'drg06_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 142, 'name': 'drg06_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 143, 'name': 'drg06_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 144, 'name': 'drg07_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 145, 'name': 'drg07_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 146, 'name': 'drg07_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 147, 'name': 'drg07_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 148, 'name': 'drg08_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 149, 'name': 'drg08_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 150, 'name': 'drg08_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 151, 'name': 'drg08_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 152, 'name': 'drg09_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 153, 'name': 'drg09_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 154, 'name': 'drg09_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 155, 'name': 'drg09_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 156, 'name': 'drg10_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 157, 'name': 'drg10_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 158, 'name': 'drg10_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 159, 'name': 'drg10_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 160, 'name': 'drg11_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 161, 'name': 'drg11_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 162, 'name': 'drg11_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 163, 'name': 'drg11_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 164, 'name': 'drg12_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 165, 'name': 'drg12_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 166, 'name': 'drg12_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 167, 'name': 'drg12_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 168, 'name': 'drg13_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 169, 'name': 'drg13_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 170, 'name': 'drg13_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 171, 'name': 'drg13_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 172, 'name': 'drg14_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 173, 'name': 'drg14_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 174, 'name': 'drg14_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 175, 'name': 'drg14_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 176, 'name': 'drg15_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 177, 'name': 'drg15_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 178, 'name': 'drg15_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 179, 'name': 'drg15_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 180, 'name': 'drg16_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 181, 'name': 'drg16_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 182, 'name': 'drg16_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 183, 'name': 'drg16_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 184, 'name': 'drg17_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 185, 'name': 'drg17_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 186, 'name': 'drg17_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 187, 'name': 'drg17_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 188, 'name': 'drg18_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 189, 'name': 'drg18_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 190, 'name': 'drg18_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 191, 'name': 'drg18_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 192, 'name': 'drg19_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 193, 'name': 'drg19_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 194, 'name': 'drg19_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 195, 'name': 'drg19_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 196, 'name': 'drg20_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 197, 'name': 'drg20_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 198, 'name': 'drg20_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 199, 'name': 'drg20_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 200, 'name': 'drg21_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 201, 'name': 'drg21_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 202, 'name': 'drg21_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 203, 'name': 'drg21_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 204, 'name': 'drg22_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 205, 'name': 'drg22_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 206, 'name': 'drg22_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 207, 'name': 'drg22_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 208, 'name': 'drg23_bandwidth:/data1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 209, 'name': 'drg23_bandwidth:/data2', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3,
             'unit': 'bits/second', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 210, 'name': 'drg23_storage:/data1', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 211, 'name': 'drg23_storage:/data2', 'type_id': 5, 'type_name': 'storage', 'unit_id': 1,
             'unit': 'bytes', 'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 212, 'name': 'CS001rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 213, 'name': 'CS001tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 214, 'name': 'CS002rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 215, 'name': 'CS002tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 216, 'name': 'CS003rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 217, 'name': 'CS003tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 218, 'name': 'CS004rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 219, 'name': 'CS004tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 220, 'name': 'CS005rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 221, 'name': 'CS005tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 222, 'name': 'CS006rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 223, 'name': 'CS006tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 224, 'name': 'CS007rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 225, 'name': 'CS007tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 226, 'name': 'CS011rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 227, 'name': 'CS011tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 228, 'name': 'CS013rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 229, 'name': 'CS013tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 230, 'name': 'CS017rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 231, 'name': 'CS017tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 232, 'name': 'CS021rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 233, 'name': 'CS021tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 234, 'name': 'CS024rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 235, 'name': 'CS024tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 236, 'name': 'CS026rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 237, 'name': 'CS026tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 238, 'name': 'CS028rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 239, 'name': 'CS028tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 240, 'name': 'CS030rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 241, 'name': 'CS030tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 242, 'name': 'CS031rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 243, 'name': 'CS031tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 244, 'name': 'CS032rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 245, 'name': 'CS032tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 246, 'name': 'CS101rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 247, 'name': 'CS101tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 248, 'name': 'CS103rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 249, 'name': 'CS103tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 250, 'name': 'CS201rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 251, 'name': 'CS201tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 252, 'name': 'CS301rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 253, 'name': 'CS301tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 254, 'name': 'CS302rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 255, 'name': 'CS302tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 256, 'name': 'CS401rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 257, 'name': 'CS401tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 258, 'name': 'CS501rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 259, 'name': 'CS501tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 260, 'name': 'RS106rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 261, 'name': 'RS106tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 262, 'name': 'RS205rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 263, 'name': 'RS205tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 264, 'name': 'RS208rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 265, 'name': 'RS208tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 266, 'name': 'RS210rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 267, 'name': 'RS210tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 268, 'name': 'RS305rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 269, 'name': 'RS305tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 270, 'name': 'RS306rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 271, 'name': 'RS306tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 272, 'name': 'RS307rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 273, 'name': 'RS307tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 274, 'name': 'RS310rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 275, 'name': 'RS310tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 276, 'name': 'RS406rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 277, 'name': 'RS406tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 278, 'name': 'RS407rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 279, 'name': 'RS407tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 280, 'name': 'RS408rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 281, 'name': 'RS408tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 282, 'name': 'RS409rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 283, 'name': 'RS409tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 284, 'name': 'RS503rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 285, 'name': 'RS503tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 286, 'name': 'RS508rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 287, 'name': 'RS508tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 288, 'name': 'RS509rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 289, 'name': 'RS509tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 290, 'name': 'DE601rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 291, 'name': 'DE601tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 292, 'name': 'DE602rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 293, 'name': 'DE602tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 294, 'name': 'DE603rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 295, 'name': 'DE603tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 296, 'name': 'DE604rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 297, 'name': 'DE604tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 298, 'name': 'DE605rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 299, 'name': 'DE605tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 300, 'name': 'FR606rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 301, 'name': 'FR606tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 302, 'name': 'SE607rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 303, 'name': 'SE607tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 304, 'name': 'UK608rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 305, 'name': 'UK608tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 306, 'name': 'DE609rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 307, 'name': 'DE609tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 308, 'name': 'PL610rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 309, 'name': 'PL610tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 310, 'name': 'PL611rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 311, 'name': 'PL611tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 312, 'name': 'PL612rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 313, 'name': 'PL612tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 314, 'name': 'IE613rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 315, 'name': 'IE613tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 316, 'name': 'IS614rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 317, 'name': 'IS614tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 318, 'name': 'TEST1rcu', 'type_id': 2, 'type_name': 'rcu', 'unit_id': 2, 'unit': 'rcu_board',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 319, 'name': 'TEST1tbb', 'type_id': 1, 'type_name': 'tbb', 'unit_id': 1, 'unit': 'bytes',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 320, 'name': 'CS001chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 321, 'name': 'CS001bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 322, 'name': 'CS001chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 323, 'name': 'CS001bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 324, 'name': 'CS002chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 325, 'name': 'CS002bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 326, 'name': 'CS002chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 327, 'name': 'CS002bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 328, 'name': 'CS003chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 329, 'name': 'CS003bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 330, 'name': 'CS003chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 331, 'name': 'CS003bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 332, 'name': 'CS004chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 333, 'name': 'CS004bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 334, 'name': 'CS004chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 335, 'name': 'CS004bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 336, 'name': 'CS005chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 337, 'name': 'CS005bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 338, 'name': 'CS005chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 339, 'name': 'CS005bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 340, 'name': 'CS006chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 341, 'name': 'CS006bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 342, 'name': 'CS006chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 343, 'name': 'CS006bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 344, 'name': 'CS007chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 345, 'name': 'CS007bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 346, 'name': 'CS007chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 347, 'name': 'CS007bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 348, 'name': 'CS011chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 349, 'name': 'CS011bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 350, 'name': 'CS011chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 351, 'name': 'CS011bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 352, 'name': 'CS013chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 353, 'name': 'CS013bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 354, 'name': 'CS013chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 355, 'name': 'CS013bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 356, 'name': 'CS017chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 357, 'name': 'CS017bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 358, 'name': 'CS017chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 359, 'name': 'CS017bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 360, 'name': 'CS021chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 361, 'name': 'CS021bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 362, 'name': 'CS021chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 363, 'name': 'CS021bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 364, 'name': 'CS024chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 365, 'name': 'CS024bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 366, 'name': 'CS024chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 367, 'name': 'CS024bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 368, 'name': 'CS026chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 369, 'name': 'CS026bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 370, 'name': 'CS026chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 371, 'name': 'CS026bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 372, 'name': 'CS028chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 373, 'name': 'CS028bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 374, 'name': 'CS028chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 375, 'name': 'CS028bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 376, 'name': 'CS030chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 377, 'name': 'CS030bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 378, 'name': 'CS030chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 379, 'name': 'CS030bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 380, 'name': 'CS031chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 381, 'name': 'CS031bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 382, 'name': 'CS031chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 383, 'name': 'CS031bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 384, 'name': 'CS032chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 385, 'name': 'CS032bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 386, 'name': 'CS032chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 387, 'name': 'CS032bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 388, 'name': 'CS101chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 389, 'name': 'CS101bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 390, 'name': 'CS101chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 391, 'name': 'CS101bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 392, 'name': 'CS103chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 393, 'name': 'CS103bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 394, 'name': 'CS103chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 395, 'name': 'CS103bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 396, 'name': 'CS201chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 397, 'name': 'CS201bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 398, 'name': 'CS201chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 399, 'name': 'CS201bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 400, 'name': 'CS301chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 401, 'name': 'CS301bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 402, 'name': 'CS301chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 403, 'name': 'CS301bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 404, 'name': 'CS302chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 405, 'name': 'CS302bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 406, 'name': 'CS302chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 407, 'name': 'CS302bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 408, 'name': 'CS401chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 409, 'name': 'CS401bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 410, 'name': 'CS401chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 411, 'name': 'CS401bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 412, 'name': 'CS501chan0', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 413, 'name': 'CS501bw0', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 414, 'name': 'CS501chan1', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 415, 'name': 'CS501bw1', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 416, 'name': 'RS106chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 417, 'name': 'RS106bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 418, 'name': 'RS205chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 419, 'name': 'RS205bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 420, 'name': 'RS208chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 421, 'name': 'RS208bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 422, 'name': 'RS210chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 423, 'name': 'RS210bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 424, 'name': 'RS305chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 425, 'name': 'RS305bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 426, 'name': 'RS306chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 427, 'name': 'RS306bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 428, 'name': 'RS307chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 429, 'name': 'RS307bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 430, 'name': 'RS310chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 431, 'name': 'RS310bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 432, 'name': 'RS406chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 433, 'name': 'RS406bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 434, 'name': 'RS407chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 435, 'name': 'RS407bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 436, 'name': 'RS408chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 437, 'name': 'RS408bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 438, 'name': 'RS409chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 439, 'name': 'RS409bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 440, 'name': 'RS503chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 441, 'name': 'RS503bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 442, 'name': 'RS508chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 443, 'name': 'RS508bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 444, 'name': 'RS509chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 445, 'name': 'RS509bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 446, 'name': 'DE601chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 447, 'name': 'DE601bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 448, 'name': 'DE602chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 449, 'name': 'DE602bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 450, 'name': 'DE603chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 451, 'name': 'DE603bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 452, 'name': 'DE604chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 453, 'name': 'DE604bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 454, 'name': 'DE605chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 455, 'name': 'DE605bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 456, 'name': 'FR606chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 457, 'name': 'FR606bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 458, 'name': 'SE607chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 459, 'name': 'SE607bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 460, 'name': 'UK608chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 461, 'name': 'UK608bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 462, 'name': 'DE609chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 463, 'name': 'DE609bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 464, 'name': 'PL610chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 465, 'name': 'PL610bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 466, 'name': 'PL611chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 467, 'name': 'PL611bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 468, 'name': 'PL612chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 469, 'name': 'PL612bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 470, 'name': 'IE613chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 471, 'name': 'IE613bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 472, 'name': 'IS614chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 473, 'name': 'IS614bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 474, 'name': 'TEST1chan', 'type_id': 0, 'type_name': 'rsp', 'unit_id': 0, 'unit': 'rsp_channel_bit',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1},
            {'id': 475, 'name': 'TEST1bw', 'type_id': 3, 'type_name': 'bandwidth', 'unit_id': 3, 'unit': 'bits/second',
             'available_capacity': 10, 'used_capacity': 0, 'total_capacity': 10, 'active': 1}
        ]

        self.rarpc_mock.getResourceClaims.return_value = []

        self.rarpc_mock.getResourceAllocationConfig.return_value = [
            {'name': 'max_fill_ratio_CEP4_storage', 'value': 0.85}, {'name': 'claim_timeout', 'value': 172800},
            {'name': 'min_inter_task_delay', 'value': 60}, {'name': 'max_fill_ratio_CEP4_bandwidth', 'value': 0.75}
        ]

        rerpc_patcher = mock.patch('lofar.messaging.RPC')
        self.addCleanup(rerpc_patcher.stop)
        self.rerpc_mock = rerpc_patcher.start()
        self.rerpc_mock.return_value = self.rerpc_replymessage, self.rerpc_status

        otdbrpc_patcher = mock.patch('lofar.sas.otdb.otdbrpc')
        self.addCleanup(otdbrpc_patcher.stop)
        self.otdbrpc_mock = otdbrpc_patcher.start()

        momrpc_patcher = mock.patch('lofar.mom.momqueryservice.momqueryrpc')
        self.addCleanup(momrpc_patcher.stop)
        self.momrpc_mock = momrpc_patcher.start()
        self.momrpc_mock.getPredecessorIds.return_value = {str(self.task_mom_id): self.predecessor_task_mom_ids}
        self.momrpc_mock.getSuccessorIds.return_value = {str(self.task_mom_id): self.successor_task_mom_ids}

        curpc_patcher = mock.patch('lofar.sas.datamanagement.cleanup.rpc')
        self.addCleanup(curpc_patcher.stop)
        self.curpc_mock = curpc_patcher.start()

        sqrpc_patcher = mock.patch('lofar.sas.datamanagement.storagequery.rpc')
        self.addCleanup(sqrpc_patcher.stop)
        self.sqrpc_mock = sqrpc_patcher.start()

        ra_notification_bus_patcher = mock.patch('lofar.messaging.messagebus')
        self.addCleanup(ra_notification_bus_patcher.stop)
        self.ra_notification_bus_mock = ra_notification_bus_patcher.start()

        logger_patcher = mock.patch('lofar.sas.resourceassignment.resourceassigner.assignment.logger')
        self.addCleanup(logger_patcher.stop)
        self.logger_mock = logger_patcher.start()

        # Select logger output to see
        def myprint(s, *args):
            print >>sys.stderr, s % args if args else s

        #self.logger_mock.debug.side_effect = myprint
        self.logger_mock.info.side_effect = myprint
        self.logger_mock.warn.side_effect = myprint
        self.logger_mock.error.side_effect = myprint

        move_pipeline_after_its_predecessors_patcher = mock.patch(
            'lofar.sas.resourceassignment.resourceassigner.assignment.movePipelineAfterItsPredecessors')
        self.addCleanup(move_pipeline_after_its_predecessors_patcher.stop)
        self.movePipelineAfterItsPredecessors_mock = move_pipeline_after_its_predecessors_patcher.start()

        self.resourceAssigner = TestingResourceAssigner(self.rarpc_mock, self.rerpc_mock,
                                                        self.otdbrpc_mock, self.momrpc_mock,
                                                        self.curpc_mock, self.sqrpc_mock,
                                                        self.ra_notification_bus_mock)
        self.reset_specification_tree()

    def assert_all_services_opened(self):
        self.assertTrue(self.rarpc_mock.open.called, "RARPC.open was not called")
        self.assertTrue(self.rerpc_mock.open.called, "RPC.open was not called")
        self.assertTrue(self.otdbrpc_mock.open.called, "OTDBRPC.open was not called")
        self.assertTrue(self.momrpc_mock.open.called, "MOMRPC.open was not called")
        self.assertTrue(self.curpc_mock.open.called, "CURPC.open was not called")
        self.assertTrue(self.ra_notification_bus_mock.open.called, "ra_notification_bus.open was not called")

    def assert_all_services_closed(self):
        self.assertTrue(self.rarpc_mock.close.called, "RARPC.close was not called")
        self.assertTrue(self.rerpc_mock.close.called, "RPC.close was not called")
        self.assertTrue(self.otdbrpc_mock.close.called, "OTDBRPC.close was not called")
        self.assertTrue(self.momrpc_mock.close.called, "MOMRPC.close was not called")
        self.assertTrue(self.curpc_mock.close.called, "CURPC.close was not called")
        self.assertTrue(self.ra_notification_bus_mock.close.called, "ra_notification_bus.close was not called")

    def test_open_opens_all_services(self):
        self.resourceAssigner.open()

        self.assert_all_services_opened()

    def test_close_closes_all_services(self):
        self.resourceAssigner.close()

        self.assert_all_services_closed()

    def test_contextManager_opens_and_closes_all_services(self):
        with TestingResourceAssigner(self.rarpc_mock, self.rerpc_mock,
                                     self.otdbrpc_mock, self.momrpc_mock,
                                     self.curpc_mock, self.sqrpc_mock,
                                     self.ra_notification_bus_mock):
            self.assert_all_services_opened()

        self.assert_all_services_closed()

    def test_do_assignment_logs_specification(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call('doAssignment: specification_tree=%s' % self.specification_tree)

    def test_do_assignment_log_non_approved_or_prescheduled_states(self):
        self.resourceAssigner.doAssignment(self.non_approved_or_prescheduled_specification_tree)

        assignable_task_states_str = "approved, prescheduled"
        self.logger_mock.warn.assert_any_call(
            'skipping specification for task otdb_id=%s, because status=%s (not one of %s)',
            self.non_approved_or_prescheduled_otdb_id, self.non_approved_or_prescheduled_status,
            assignable_task_states_str)

    def test_do_assignment_non_approved_or_prescheduled_states_should_be_skipped(self):
        self.resourceAssigner.doAssignment(self.non_approved_or_prescheduled_specification_tree)

        self.assertEqual(len(self.otdbrpc_mock.method_calls), 0,
                         "OTDBRPC was called for non approved or scheduled specification tree")
        self.assertEqual(len(self.rarpc_mock.method_calls), 0,
                         "RARPC was called for non approved or scheduled specification tree")
        self.assertEqual(len(self.momrpc_mock.method_calls), 0,
                         "MOMRPC was called for non approved or scheduled specification tree")
        self.assertEqual(len(self.rerpc_mock.method_calls), 0,
                         "RERPC was called for non approved or scheduled specification tree")
        self.assertEqual(len(self.curpc_mock.method_calls), 0,
                         "CURPC was called for non approved or scheduled specification tree")
        self.assertEqual(len(self.ra_notification_bus_mock.method_calls), 0,
                         "RA notification bus was called for non approved or scheduled specification tree")

    def test_do_assignment_inserts_specification_and_task_in_radb(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        start_time = datetime.datetime.strptime(self.future_start_time, '%Y-%m-%d %H:%M:%S')
        stop_time = datetime.datetime.strptime(self.future_stop_time, '%Y-%m-%d %H:%M:%S')
        parset = parameterset(self.specification_tree['specification'])

        self.rarpc_mock.insertSpecificationAndTask.assert_any_call(self.mom_id, self.otdb_id, self.state,
                                                                   self.task_type, start_time, stop_time, str(parset),
                                                                   "CEP4")

    def test_do_assignment_logs_when_insertion_of_specification_and_task_in_radb_failed(self):
        return_value = {'inserted': False}

        self.rarpc_mock.insertSpecificationAndTask.return_value = return_value

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call('could not insert specification and task: result = %s', return_value)

    def test_do_assignment_logs_when_no_predecessors_found(self):
        self.momrpc_mock.getPredecessorIds.return_value = {str(self.task_mom_id): []}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call('no predecessors for otdb_id=%s mom_id=%s', self.task_otdb_id,
                                              self.task_mom_id)

    def test_do_assignment_logs_when_predecessors_are_found(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call('processing predecessor mom_ids=%s for mom_id=%s otdb_id=%s',
                                              self.predecessor_task_mom_ids, self.task_mom_id, self.task_otdb_id)

    def test_do_assignment_logs_when_predecessors_are_found_but_its_task_is_missing_in_radb(self):
        self.momrpc_mock.getPredecessorIds.return_value = {str(self.task_mom_id): [self.non_existing_task_mom_id]}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.warning.assert_any_call(
            'could not find predecessor task with mom_id=%s in radb for task otdb_id=%s', self.non_existing_task_mom_id,
            self.task_otdb_id)

    def test_do_assignment_logs_when_predecessors_are_found_that_need_to_be_linked_to_task(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call(
            'connecting predecessor task with mom_id=%s otdb_id=%s to its successor with mom_id=%s otdb_id=%s',
            self.predecessor_task_mom_id,
            self.predecessor_task_otdb_id,
            self.task_mom_id,
            self.task_otdb_id)

    def test_do_assignment_insert_predecessor_into_task_when_not_linked_to_task(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rarpc_mock.insertTaskPredecessor.assert_any_call(self.task_id, self.predecessor_task_id)

    def test_do_assignment_logs_when_no_successors_found(self):
        self.momrpc_mock.getSuccessorIds.return_value = {str(self.task_mom_id): []}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call('no successors for otdb_id=%s mom_id=%s', self.task_otdb_id,
                                              self.task_mom_id)

    def test_do_assignment_logs_when_successors_are_found(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call('processing successor mom_ids=%s for mom_id=%s otdb_id=%s',
                                              self.successor_task_mom_ids, self.task_mom_id, self.task_otdb_id)

    def test_do_assignment_logs_when_successors_are_found_but_its_task_is_missing_in_radb(self):
        self.momrpc_mock.getSuccessorIds.return_value = {str(self.task_mom_id): [self.non_existing_task_mom_id]}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.warning.assert_any_call(
            'could not find successor task with mom_id=%s in radb for task otdb_id=%s',
            self.non_existing_task_mom_id, self.task_otdb_id)

    def test_do_assignment_logs_when_successors_are_found_that_need_to_be_linked_to_task(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call(
            'connecting successor task with mom_id=%s otdb_id=%s to its predecessor with mom_id=%s otdb_id=%s',
            self.successor_task_mom_id,
            self.successor_task_otdb_id,
            self.task_mom_id,
            self.task_otdb_id)

    def test_do_assignment_insert_successor_into_task_when_not_linked_to_task(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rarpc_mock.insertTaskPredecessor.assert_any_call(self.successor_task_id, self.task_id)

    def test_do_assignment_moves_pipeline_of_successor_after_predecessor(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.assertTrue(self.movePipelineAfterItsPredecessors_mock.called)

    def test_do_assignment_logs_mom_bug(self):
        self.resourceAssigner.doAssignment(self.mom_bug_specification_tree)

        self.logger_mock.info.assert_any_call(
            'overwriting and uploading processingClusterName to otdb from \'%s\' to \'%s\' for otdb_id=%s',
            self.mom_bug_processing_cluster_name, 'CEP4', self.mom_bug_otdb_id)

    def test_do_assignment_resets_ProcessingCluster_clusterName_on_mom_bug(self):
        self.resourceAssigner.doAssignment(self.mom_bug_specification_tree)

        self.otdbrpc_mock.taskSetSpecification.assert_any_call(
            self.mom_bug_otdb_id,
            {'LOFAR.ObsSW.Observation.Cluster.ProcessingCluster.clusterName': 'CEP4'})

    @mock.patch('lofar.sas.resourceassignment.resourceassigner.assignment.datetime')
    def test_do_assignment_should_reset_observation_period_when_in_past_without_predecessor_and_duration(
            self, datetime_mock):
        now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
        datetime_mock.utcnow.return_value = now

        new_starttime = now + datetime.timedelta(minutes=3)
        new_endtime = new_starttime + datetime.timedelta(seconds=self.task_duration)

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.warning.assert_any_call(
            'Applying sane defaults (%s, %s) for start/end time from specification for otdb_id=%s',
            new_starttime, new_endtime, self.otdb_id)
        self.logger_mock.info.assert_any_call(
            'uploading auto-generated start/end time  (%s, %s) to otdb for otdb_id=%s',
            new_starttime,
            new_endtime,
            self.otdb_id)
        self.otdbrpc_mock.taskSetSpecification.assert_any_call(
            self.otdb_id,
            {
                'LOFAR.ObsSW.Observation.startTime': new_starttime.strftime('%Y-%m-%d %H:%M:%S'),
                'LOFAR.ObsSW.Observation.stopTime': new_endtime.strftime('%Y-%m-%d %H:%M:%S')
            })

    @mock.patch('lofar.sas.resourceassignment.resourceassigner.assignment.datetime')
    def test_do_assignment_should_reset_observation_period_when_in_past_with_predecessor_in_future(self, datetime_mock):
        now = self.freeze_time_one_day_in_the_future(datetime_mock)

        future_predecessor_stop_time = now + datetime.timedelta(hours=1)
        self.specification_tree['predecessors'][0]['specification']['Observation.stopTime'] = \
            future_predecessor_stop_time.strftime('%Y-%m-%d %H:%M:%S')

        new_starttime = future_predecessor_stop_time + datetime.timedelta(minutes=3)
        new_endtime = new_starttime + datetime.timedelta(seconds=self.task_duration)

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.warning.assert_any_call(
            'Applying sane defaults (%s, %s) for start/end time from specification for otdb_id=%s',
            new_starttime, new_endtime, self.otdb_id)
        self.logger_mock.info.assert_any_call(
            'uploading auto-generated start/end time  (%s, %s) to otdb for otdb_id=%s',
            new_starttime,
            new_endtime,
            self.otdb_id)
        self.otdbrpc_mock.taskSetSpecification.assert_any_call(
            self.otdb_id,
            {
                'LOFAR.ObsSW.Observation.startTime': new_starttime.strftime('%Y-%m-%d %H:%M:%S'),
                'LOFAR.ObsSW.Observation.stopTime': new_endtime.strftime('%Y-%m-%d %H:%M:%S')
            })

    def freeze_time_one_day_in_the_future(self, datetime_mock):
        now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
        now = self._strip_ms(now)
        datetime_mock.utcnow.return_value = now
        datetime_mock.strptime.side_effect = \
            lambda date_string, format_string: datetime.datetime.strptime(date_string, format_string)
        return now

    def _strip_ms(self, now):
        return datetime.datetime.strptime(now.strftime('%Y-%m-%d %H:%M:%S'), '%Y-%m-%d %H:%M:%S')

    @mock.patch('lofar.sas.resourceassignment.resourceassigner.assignment.datetime')
    def test_do_assignment_should_reset_observation_period_when_in_past(self, datetime_mock):
        now = datetime.datetime.utcnow() + datetime.timedelta(days=1)

        datetime_mock.utcnow.return_value = now

        new_starttime = now + datetime.timedelta(minutes=3)
        new_endtime = new_starttime + datetime.timedelta(seconds=self.task_duration)

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.warning.assert_any_call(
            'Applying sane defaults (%s, %s) for start/end time from specification for otdb_id=%s',
            new_starttime, new_endtime, self.otdb_id)
        self.logger_mock.info.assert_any_call(
            'uploading auto-generated start/end time  (%s, %s) to otdb for otdb_id=%s',
            new_starttime,
            new_endtime,
            self.otdb_id)
        self.otdbrpc_mock.taskSetSpecification.assert_any_call(
            self.otdb_id,
            {
                'LOFAR.ObsSW.Observation.startTime': new_starttime.strftime('%Y-%m-%d %H:%M:%S'),
                'LOFAR.ObsSW.Observation.stopTime': new_endtime.strftime('%Y-%m-%d %H:%M:%S')
            })

    def test_do_assignment_should_log_insertion_of_specification_and_task(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call(
            'doAssignment: insertSpecification momId=%s, otdb_id=%s, status=%s, taskType=%s, startTime=%s, endTime=%s'
            ' cluster=%s' %
            (self.mom_id, self.otdb_id, self.state, self.task_type, self.future_start_time, self.future_stop_time,
             "CEP4"))

    def test_do_assignment_should_log_when_insertion_of_specification_and_task_is_done(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call('doAssignment: inserted specification (id=%s) and task (id=%s)' %
                                              (self.specification_id, self.task_id))

    def test_do_assignment_should_not_claim_resources_on_CEP2_tasks(self):
        self.resourceAssigner.doAssignment(self.cep2_specification_tree)

        self.rarpc_mock.insertResourceClaims.assert_not_called()

    def test_do_assignment_should_not_claim_resources_on_non_presceduled_cep4_tasks(self):
        self.resourceAssigner.doAssignment(self.non_approved_or_prescheduled_specification_tree)

        self.rarpc_mock.insertResourceClaims.assert_not_called()

    def test_do_assginement_should_request_needed_resources(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rerpc_mock.assert_any_call(
            {"specification_tree": self.specification_tree}, timeout=10)

    def test_do_assignment_logs_when_otdb_id_not_needed_resources(self):
        self.specification_tree["otdb_id"] = self.otdb_id + 11

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call("no otdb_id %s found in estimator results %s" %
                                               (self.otdb_id + 11, self.rerpc_replymessage))

    def test_do_assignment_should_not_claim_resouces_when_otdb_id_not_needed_resources(self):
        self.specification_tree["otdb_id"] = self.otdb_id + 1

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rarpc_mock.insertResourceClaims.assert_not_called()

    def test_do_assignment_logs_when_task_type_not_in_needed_resources(self):
        wrong_task_type = "observation"
        self.specification_tree["task_type"] = wrong_task_type

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call("no task type %s found in estimator results %s" %
                                               (wrong_task_type,
                                                self.rerpc_replymessage[str(self.otdb_id)]))

    def test_do_assignment_should_not_claim_resources_when_task_type_not_in_needed_resources(self):
        wrong_task_type = "observation"
        self.specification_tree["task_type"] = wrong_task_type

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rarpc_mock.insertResourceClaims.assert_not_called()

    def test_do_assignment_should_log_single_errors_in_needed_resources(self):
        self.specification_tree["otdb_id"] = self.resources_with_errors_otdb_id

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call("Error from Resource Estimator: %s", self.resource_error1)
        self.logger_mock.error.assert_any_call("Error from Resource Estimator: %s", self.resource_error2)

    def test_do_assignment_should_log_error_in_needed_resources(self):
        self.specification_tree["otdb_id"] = self.resources_with_errors_otdb_id

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call(
            "Error(s) in estimator for otdb_id=%s radb_id=%s" %
            (self.resources_with_errors_otdb_id, self.task_id))

    def test_do_assignment_should_update_task_with_error_on_errors_in_needed_resources(self):
        self.specification_tree["otdb_id"] = self.resources_with_errors_otdb_id

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rarpc_mock.updateTask.assert_any_call(self.task_id, task_status='error')

    def test_do_assignment_should_notify_bus_on_errors_in_needed_resources(self):
        content = {'radb_id': self.task_id, 'otdb_id': self.task_otdb_id, 'mom_id': self.task_mom_id}
        subject = 'TaskError'

        self.specification_tree["otdb_id"] = self.resources_with_errors_otdb_id

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.assertBusNotificationAndLogging(content, subject)

    def ra_notification_bus_send_called_with(self, content, subject):
        found = False
        for call in self.ra_notification_bus_mock.send.call_args_list:
            if call[0][0].subject == subject and call[0][0].content == content:
                found = True
        return found

    def test_do_assignment_should_log_estimator_reply(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call('doAssignment: Resource Estimator reply = %s',
                                              self.rerpc_replymessage)

    def test_do_assignment_logs_created_claim_per_needed_resource_type(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        claim = [self.bandwidth_claim, self.storage_claim]

        self.logger_mock.debug.assert_any_call('fitMultipleResources: created claim: %s', claim)

    def test_do_assignment_logs_amount_of_claims_inserted_in_radb(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        storage_claim = {'status': 'tentative', 'resource_id': 117, 'resource_type_id': 5, 'claim_size': 2,
                         'starttime': datetime.datetime(2016, 3, 25, 21, 47, 31),
                         'used_rcus': None,
                         'endtime': datetime.datetime(2017, 3, 25, 22, 47, 31),
                         'properties': [{'type': 15, 'io_type': 'output', 'sap_nr': 0, 'value': 0},
                                        {'type': 2, 'io_type': 'output', 'sap_nr': 0, 'value': 1},
                                        {'type': 10, 'io_type': 'output', 'sap_nr': 0, 'value': 1073741824}]}
        claims = [self.bandwidth_claim, storage_claim]

        self.logger_mock.info.assert_any_call('doAssignment: inserting %d claims in the radb: %s', len(claims), claims)

    def test_do_assignment_inserts_resource_claims_in_radb(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rarpc_mock.insertResourceClaims.assert_any_call(self.task_id, self.specification_claims, 1, 'anonymous', -1)

    def test_do_assignment_inserts_resource_claims_with_rcus_no_earlier_claims(self):
        used_rcus = '111100010111100101101010'

        self.rarpc_mock.insertRcuSpecifications.return_value = [1]
        self.rarpc_mock.insertResourceClaims.return_value = {'ids': [1]}
        self.rarpc_mock.getResourceClaims.return_value = []

        rcu_claim = {
            'resource_id': 212,
            'resource_type_id': 2,
            'starttime': self.task_start_time,
            'endtime': self.task_end_time,
            'status': 'tentative',
            'used_rcus': used_rcus,
            'claim_size': used_rcus.count('1'),
            'properties': []
        }

        self.specification_tree['otdb_id'] = self.resources_with_rcus_otdb_id
        self.specification_tree['task_type'] = 'observation'
        self.task['type'] = 'observation'
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rarpc_mock.insertResourceClaims.assert_any_call(self.task_id, [rcu_claim], 1, 'anonymous', -1)

    def test_do_assignment_logs_amount_claims_inserted(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call('doAssignment: %d claims were inserted in the radb' % 2)

    def test_do_assignment_logs_when_it_was_unable_to_claim_all_resources(self):
        self.rarpc_mock.insertResourceClaims.return_value = {'ids': []}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call('doAssignment: too few claims were inserted in the radb')

    def test_do_assignment_updates_task_when_it_was_unable_to_claim_all_resources(self):
        self.rarpc_mock.insertResourceClaims.return_value = {'ids': []}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rarpc_mock.updateTask.assert_any_call(self.task_id, task_status='conflict')

    def test_do_assignment_notifies_bus_when_it_was_unable_to_claim_all_resources(self):
        content = {'radb_id': self.task_id, 'otdb_id': self.task_otdb_id, 'mom_id': self.task_mom_id}
        subject = 'Task' + 'Conflict'

        self.rarpc_mock.insertResourceClaims.return_value = {'ids': []}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.assertBusNotificationAndLogging(content, subject)

    def test_do_assignment_updates_task_when_it_was_unable_to_claim_some_resources(self):
        self.rarpc_mock.insertResourceClaims.return_value = {'ids': [1]}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rarpc_mock.updateTask.assert_any_call(self.task_id, task_status='conflict')

    def test_do_assignment_notifies_bus_when_it_was_unable_to_claim_some_resources(self):
        content = {'radb_id': self.task_id, 'otdb_id': self.task_otdb_id, 'mom_id': self.task_mom_id}
        subject = 'Task' + 'Conflict'

        self.rarpc_mock.insertResourceClaims.return_value = {'ids': [1]}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.assertBusNotificationAndLogging(content, subject)

    def test_do_assignment_logs_when_there_are_conflicting_claims(self):
        conflicting_claims = [{}]

        self.rarpc_mock.getResourceClaims.return_value = conflicting_claims

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call(
            'doAssignment: Task cannot be scheduled, because of %d conflicting claims: %s' %
            (len(conflicting_claims), conflicting_claims))

    def test_do_assignment_notifies_bus_when_there_are_conflicting_claims(self):
        content = {'radb_id': self.task_id, 'otdb_id': self.task_otdb_id, 'mom_id': self.task_mom_id}
        subject = 'Task' + 'Conflict'

        conflicting_claims = [{}]
        self.rarpc_mock.getResourceClaims.return_value = conflicting_claims

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.assertBusNotificationAndLogging(content, subject)

    def test_do_assignment_logs_when_all_resources_were_claimed(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call(
            'doAssignment: all resources for task %s were succesfully claimed. Setting claim statuses to claimed' %
            self.task_id)

    def test_do_assignment_updates_task_and_resources_as_claimed_in_radb(self):
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rarpc_mock.updateTaskAndResourceClaims.assert_any_call(self.task_id, claim_status='claimed')

    def test_do_assignment_logs_task_data_removal_if_task_is_pipeline(self):
        self.sqrpc_mock.getDiskUsageForOTDBId.return_value = {'found': True, 'disk_usage': 10}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.info.assert_any_call("removing data on disk from previous run for otdb_id %s", self.otdb_id)

    def test_do_assignment_removes_task_data_if_task_is_pipeline(self):
        self.sqrpc_mock.getDiskUsageForOTDBId.return_value = {'found': True, 'disk_usage': 10}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.curpc_mock.removeTaskData.assert_any_call(self.task_otdb_id)

    def test_do_assignment_logs_when_taks_data_could_not_be_deleted(self):
        message = "file was locked"
        self.sqrpc_mock.getDiskUsageForOTDBId.return_value = {'found': True, 'disk_usage': 10}
        self.curpc_mock.removeTaskData.return_value = {'deleted': False, 'message': message}

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.warning.assert_any_call(
            "could not remove all data on disk from previous run for otdb_id %s: %s", self.otdb_id, message)

    def test_do_assignment_notifies_bus_when_task_is_scheduled(self):
        content = {'radb_id': self.task_id, 'otdb_id': self.task_otdb_id, 'mom_id': self.task_mom_id}
        subject = 'Task' + 'Scheduled'

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.assertBusNotificationAndLogging(content, subject)

    def assertBusNotificationAndLogging(self, content, subject):
        self.assertTrue(self.ra_notification_bus_send_called_with(content, ra_notification_prefix + subject))
        self.logger_mock.info.assert_any_call('Sending notification %s: %s' %
                                              (subject, str(content).replace('\n', ' ')))

    @mock.patch('lofar.sas.resourceassignment.resourceassigner.assignment.datetime')
    def test_do_assignment_logs_exception_from_otdbrpc_taskSetSpecification(self, datetime_mock):
        self.freeze_time_one_day_in_the_future(datetime_mock)

        exception = Exception("Error something went wrong")
        self.otdbrpc_mock.taskSetSpecification.side_effect = exception

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call(str(exception))

    def test_do_assignment_logs_exception_from_otdbrpc_taskSetSpecification_with_mom_bug(self):
        exception = Exception("Error something went wrong")
        self.otdbrpc_mock.taskSetSpecification.side_effect = exception

        self.resourceAssigner.doAssignment(self.mom_bug_specification_tree)

        self.logger_mock.error.assert_any_call(str(exception))

    def test_do_assignment_logs_exception_from_rerpc(self):
        exception = Exception("Error something went wrong")
        self.rerpc_mock.side_effect = exception

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call(str(exception))

    def test_do_assignment_updates_task_on_exception_from_rerpc(self):
        exception = Exception("Error something went wrong")
        self.rerpc_mock.side_effect = exception

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.rarpc_mock.updateTask.assert_any_call(self.task_id, task_status='error')

    def test_do_assignment_notifies_bus_on_exception_from_rerpc(self):
        content = {'radb_id': self.task_id, 'otdb_id': self.task_otdb_id, 'mom_id': self.task_mom_id}
        subject = 'Task' + 'Error'

        exception = Exception("Error something went wrong")
        self.rerpc_mock.side_effect = exception

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.assertBusNotificationAndLogging(content, subject)

    def test_do_assignment_logs_when_notifies_bus_thows_exception(self):
        exception = Exception("Error something went wrong")
        self.ra_notification_bus_mock.send.side_effect = exception

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call(str(exception))

    def test_do_assignment_logs_when_momrpc_getPredecessorIds_throws_exception(self):
        exception = Exception("Error something went wrong")
        self.momrpc_mock.getPredecessorIds.side_effect = exception

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call(str(exception))

    def test_do_assignment_logs_when_momrpc_getSuccessorIds_throws_exception(self):
        exception = Exception("Error something went wrong")
        self.momrpc_mock.getSuccessorIds.side_effect = exception

        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call(str(exception))

    @mock.patch('lofar.sas.resourceassignment.resourceassigner.assignment.datetime')
    def test_do_assignment_logs_exception_stop_time_parsing_on_predecessor(self, datetime_mock):
        self.freeze_time_one_day_in_the_future(datetime_mock)

        self.specification_tree[u'predecessors'][0]['specification'][u'Observation.stopTime'] = 'non parse'
        exception = ValueError('time data \'non parse\' does not match format \'%Y-%m-%d %H:%M:%S\'')
        self.resourceAssigner.doAssignment(self.specification_tree)

        self.logger_mock.error.assert_any_call(str(exception))

    def test_do_assignment_inserts_maintenance_resource_claims_in_radb(self):
        self.resourceAssigner.doAssignment(self.maintenance_specification_tree)

        self.logger_mock.info.assert_any_call('findClaims: needed_resources_by_type_id: %s',  {2: '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'})
        self.logger_mock.info.assert_any_call('doAssignment: %d claims were inserted in the radb' % 2)

    def test_do_assignment_inserts_projectreservation_resource_claims_in_radb(self):
        self.resourceAssigner.doAssignment(self.projectreservation_specification_tree)

        self.logger_mock.info.assert_any_call('findClaims: needed_resources_by_type_id: %s', {2: '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'})
        self.logger_mock.info.assert_any_call('doAssignment: %d claims were inserted in the radb' % 2)

    def test_fitSingleResources_fit_one_disk(self):
        """ Given 1 needed resource, and 1 claimable resource that fits, fitSingleResources should return succesful. """

        needed_resources_by_type_id = { 5: 500 }
        claimable_resources_list = [ { 5: { 'id': 1, 'available_capacity': 1000 } } ]

        claims = self.resourceAssigner.fitSingleResources(needed_resources_by_type_id, claimable_resources_list)

        self.assertIsNotNone(claims)

    def test_fitSingleResources_not_fit_one_disk(self):
        """ Given 1 needed resource, and 1 claimable resource that does NOT fits, fitSingleResources should return failure. """

        needed_resources_by_type_id = { 5: 500 }
        claimable_resources_list = [ { 5: { 'id': 1, 'available_capacity': 400 } } ]

        claims = self.resourceAssigner.fitSingleResources(needed_resources_by_type_id, claimable_resources_list)

        self.assertIsNone(claims)

    def test_fitSingleResources_fit_multiple_disks(self):
        """ Given 1 needed resource, and 2 claimable resources, of which one fits, fitSingleResources should return succesful. """

        needed_resources_by_type_id = { 5: 500 }
        claimable_resources_list = [ { 5: { 'id': 1, 'available_capacity': 400 } }, { 5: { 'id': 1, 'available_capacity': 1000 } } ]

        claims = self.resourceAssigner.fitSingleResources(needed_resources_by_type_id, claimable_resources_list)

        self.assertIsNotNone(claims)

    def test_fitSingleResources_not_fit_multiple_resources(self):
        """ Given 2 needed resources, and 2 claimable resource sets, of which neither fit for a different resource, fitSingleResources should return failure. """

        needed_resources_by_type_id = { 3: 3000, 5: 500 }
        claimable_resources_list = [ { 3: { 'id': 0, 'available_capacity': 3000 }, 5: { 'id': 1, 'available_capacity': 400 } },    # type 5 does not fit
                                     { 3: { 'id': 0, 'available_capacity': 1000 }, 5: { 'id': 1, 'available_capacity': 1000 } } ]  # type 3 does not fit

        claims = self.resourceAssigner.fitSingleResources(needed_resources_by_type_id, claimable_resources_list)

        self.assertIsNone(claims)

    def test_fitSingleResources_fit_multiple_resources(self):
        """ Given 2 needed resources, and 2 claimable resource sets, of which only one fits, fitSingleResources should return success. """

        needed_resources_by_type_id = { 3: 3000, 5: 500 }
        claimable_resources_list = [ { 3: { 'id': 0, 'available_capacity': 3000 }, 5: { 'id': 1, 'available_capacity': 400 } },    # type 5 does not fit
                                     { 3: { 'id': 0, 'available_capacity': 3000 }, 5: { 'id': 1, 'available_capacity': 1000 } } ]  # both fit

        claims = self.resourceAssigner.fitSingleResources(needed_resources_by_type_id, claimable_resources_list)

        self.assertIsNotNone(claims)

    def test_fitMultipleResources_not_fit(self):
        """ Given 2 needed resources (which we need 4 times), and 2 claimable resource sets, only 3 out of 4 fit, fitMultipleResources should return failure. """

        needed_resources_by_type_id = { 3: 1000, 5: 100 }
        claimable_resources_list = [ { 3: { 'id': 0, 'available_capacity': 3000 }, 5: { 'id': 1, 'available_capacity': 200 } },    # fits 2x
                                     { 3: { 'id': 0, 'available_capacity': 1000 }, 5: { 'id': 1, 'available_capacity': 1000 } } ]  # fits 1x

        claims = self.resourceAssigner.fitMultipleResources(needed_resources_by_type_id, 4, claimable_resources_list)

        self.assertIsNone(claims)

    def test_fitMultipleResources_fit(self):
        """ Given 2 needed resources (which we need 4 times), and 2 claimable resource sets, all 4 out of 4 fit, fitMultipleResources should return success. """

        needed_resources_by_type_id = { 3: 1000, 5: 100 }
        claimable_resources_list = [ { 3: { 'id': 0, 'available_capacity': 3000 }, 5: { 'id': 1, 'available_capacity': 200 } },    # fits 2x
                                     { 3: { 'id': 0, 'available_capacity': 2000 }, 5: { 'id': 1, 'available_capacity': 1000 } } ]  # fits 2x

        claims = self.resourceAssigner.fitMultipleResources(needed_resources_by_type_id, 4, claimable_resources_list)

        self.assertIsNotNone(claims)

    def test_findClaims_invalid_resource_group(self):
        """ If we try to find claims with a non-existing root_resource_group, findClaims should fail. """

        estimates = [ { 'root_resource_group': 'MIDDLE EARTH', 'resource_count': 1, 'resource_types': { 'storage': 100 } } ]
        claimable_resources_list = { self.cep4storage_resource_id:   { 'id': self.cep4storage_resource_id,   'type_id': 5, 'available_capacity': 400,  'active': True } }

        with self.assertRaises(ValueError):
            _ = self.resourceAssigner.findClaims(estimates, claimable_resources_list)

    def test_findClaims_fit(self):
        """ Given 2 needed resources (which we need 4 times), and 2 claimable resource sets, all 4 out of 4 fit, findClaims should return success. """

        estimates = [ { 'root_resource_group': 'CEP4', 'resource_count': 4, 'resource_types': { 'bandwidth': 1000, 'storage': 100 } } ]
        claimable_resources_list = { self.cep4bandwidth_resource_id: { 'id': self.cep4bandwidth_resource_id, 'type_id': 3, 'available_capacity': 4000, 'active': True },
                                     self.cep4storage_resource_id:   { 'id': self.cep4storage_resource_id,   'type_id': 5, 'available_capacity': 400,  'active': True } }

        all_fit, claims, unclaimable_resources = self.resourceAssigner.findClaims(estimates, claimable_resources_list)

        self.assertTrue(all_fit)
        self.assertIsNotNone(claims)
        self.assertEqual(unclaimable_resources, [])

    def test_findClaims_not_fit(self):
        """ Given 2 needed resources (which we need 4 times), and 2 claimable resource sets, 3 out of 4 fit, findClaims should return failure. """

        estimates = [ { 'root_resource_group': 'CEP4', 'resource_count': 4, 'resource_types': { 'bandwidth': 1000, 'storage': 100 } } ]
        claimable_resources_list = { self.cep4bandwidth_resource_id: { 'id': self.cep4bandwidth_resource_id, 'type_id': 3, 'available_capacity': 4000, 'active': True },
                                     self.cep4storage_resource_id:   { 'id': self.cep4storage_resource_id,   'type_id': 5, 'available_capacity': 300,  'active': True } }

        all_fit, claims, unclaimable_resources = self.resourceAssigner.findClaims(estimates, claimable_resources_list)

        self.assertFalse(all_fit)
        self.assertEqual(claims, [])
        self.assertEqual(unclaimable_resources, estimates)

    def test_findClaims_partial_fit(self):
        """ Given 2 sets of 2 needed resources (which we need 4 times), and 2 claimable resource sets, only one set fits, findClaims should return partial success. """

        estimates = [ { 'root_resource_group': 'CEP4', 'resource_count': 4, 'resource_types': { 'bandwidth': 1000, 'storage': 100 } },
                      { 'root_resource_group': 'CEP4', 'resource_count': 4, 'resource_types': { 'bandwidth': 1000, 'storage': 100 } } ]
        claimable_resources_list = { self.cep4bandwidth_resource_id: { 'id': self.cep4bandwidth_resource_id, 'type_id': 3, 'available_capacity': 5000, 'active': True },
                                     self.cep4storage_resource_id:   { 'id': self.cep4storage_resource_id,   'type_id': 5, 'available_capacity': 500,  'active': True } }

        all_fit, claims, unclaimable_resources = self.resourceAssigner.findClaims(estimates, claimable_resources_list)

        self.assertFalse(all_fit)
        self.assertEqual(len(claims), 2) # storage & bandwidth for estimates[0]
        self.assertEqual(unclaimable_resources, [estimates[1]])

if __name__ == '__main__':
    unittest.main()