Example #1
0
    def get_channels(self, slice=None, options={}):

        all_channels = self.driver.shell.getChannels({}, [])
        channels = []
        if slice:
            reserved_channels = self.driver.shell.getReservedChannels()
            reserved_channel_ids = []
            for channel in reserved_channels:
                if channel['slice_id'] == slice['slice_id']:
                    reserved_channel_ids.append(channel['channel_id'])

            for channel in all_channels:
                if channel['channel_id'] in reserved_channel_ids:
                    channels.append(channel)
        else:
            channels = all_channels

        rspec_channels = []
        for channel in channels:
            rspec_channel = Channel()
            rspec_channel['channel_num'] = channel['channel']
            rspec_channel['frequency'] = channel['frequency']
            rspec_channel['standard'] = channel['modulation']
            rspec_channel['component_id'] = channel_to_urn(
                self.driver.hrn, self.driver.testbedInfo['name'],
                channel['channel'])
            rspec_channels.append(rspec_channel)
        return rspec_channels
Example #2
0
    def get_channels(self, slice=None, options={}):
 
        all_channels = self.driver.shell.getChannels({}, [])
        channels = []
        if slice:
            reserved_channels = self.driver.shell.getReservedChannels()
            reserved_channel_ids = []
            for channel in reserved_channels:
                 if channel['slice_id'] == slice['slice_id']:
                     reserved_channel_ids.append(channel['channel_id'])

            for channel in all_channels:
                 if channel['channel_id'] in reserved_channel_ids:
                     channels.append(channel)
        else:
            channels = all_channels

        rspec_channels = []
        for channel in channels:
            rspec_channel = Channel()
            rspec_channel['channel_num'] = channel['channel']
            rspec_channel['frequency'] = channel['frequency']
            rspec_channel['standard'] = channel['modulation']
            rspec_channel['component_id'] = channel_to_urn(self.driver.hrn, self.driver.testbedInfo['name'], channel['channel'])
            rspec_channels.append(rspec_channel)
        return rspec_channels
Example #3
0
    def get_leases_and_channels(self, slice=None, slice_xrn=None, options={}):

        slices = self.driver.shell.getSlices({}, [])
        nodes = self.driver.shell.getNodes({}, [])
        leases = self.driver.shell.getReservedNodes({}, [])
        channels = self.driver.shell.getChannels({}, [])
        reserved_channels = self.driver.shell.getReservedChannels()
        grain = self.driver.testbedInfo['grain']

        if slice_xrn and not slice:
            return ([], [])

        if slice:
            all_leases = []
            all_leases.extend(leases)
            all_reserved_channels = []
            all_reserved_channels.extend(reserved_channels)
            for lease in all_leases:
                if lease['slice_id'] != slice['slice_id']:
                    leases.remove(lease)
            for channel in all_reserved_channels:
                if channel['slice_id'] != slice['slice_id']:
                    reserved_channels.remove(channel)

        rspec_channels = []
        for channel in reserved_channels:

            rspec_channel = {}
            #retrieve channel number
            for chl in channels:
                if chl['channel_id'] == channel['channel_id']:
                    channel_number = chl['channel']
                    break

            rspec_channel['channel_num'] = channel_number
            rspec_channel['start_time'] = channel['start_time']
            rspec_channel['duration'] = (int(channel['end_time']) - int(
                channel['start_time'])) / int(grain)
            rspec_channel['component_id'] = channel_to_urn(
                self.driver.hrn, self.driver.testbedInfo['name'],
                channel_number)

            # retreive slicename
            for slc in slices:
                if slc['slice_id'] == channel['slice_id']:
                    slicename = slc['slice_name']
                    break

            if slice_xrn:
                slice_urn = slice_xrn
                slice_hrn = urn_to_hrn(slice_urn)
            else:
                slice_hrn = slicename_to_hrn(self.driver.hrn,
                                             self.driver.testbedInfo['name'],
                                             slicename)
                slice_urn = hrn_to_urn(slice_hrn, 'slice')

            rspec_channel['slice_id'] = slice_urn
            rspec_channels.append(rspec_channel)

        rspec_leases = []
        for lease in leases:

            rspec_lease = Lease()

            rspec_lease['lease_id'] = lease['reservation_id']
            # retreive node name
            for node in nodes:
                if node['node_id'] == lease['node_id']:
                    nodename = node['hostname']
                    break

            rspec_lease['component_id'] = hostname_to_urn(
                self.driver.hrn, self.driver.testbedInfo['name'], nodename)
            # retreive slicename
            for slc in slices:
                if slc['slice_id'] == lease['slice_id']:
                    slicename = slc['slice_name']
                    break

            if slice_xrn:
                slice_urn = slice_xrn
                slice_hrn = urn_to_hrn(slice_urn)
            else:
                slice_hrn = slicename_to_hrn(self.driver.hrn,
                                             self.driver.testbedInfo['name'],
                                             slicename)
                slice_urn = hrn_to_urn(slice_hrn, 'slice')

            rspec_lease['slice_id'] = slice_urn
            rspec_lease['start_time'] = lease['start_time']
            rspec_lease['duration'] = (int(lease['end_time']) -
                                       int(lease['start_time'])) / int(grain)
            rspec_leases.append(rspec_lease)

        return (rspec_leases, rspec_channels)
Example #4
0
    def get_leases_and_channels(self, slice=None, slice_xrn=None,  options={}):
        
        slices = self.driver.shell.getSlices({}, [])
        nodes = self.driver.shell.getNodes({}, [])
        leases = self.driver.shell.getReservedNodes({}, [])
        channels = self.driver.shell.getChannels({}, [])
        reserved_channels = self.driver.shell.getReservedChannels()
        grain = self.driver.testbedInfo['grain']

        if slice_xrn and not slice:
            return ([], [])

        if slice:
            all_leases = []
            all_leases.extend(leases)
            all_reserved_channels = []
            all_reserved_channels.extend(reserved_channels)
            for lease in all_leases:
                 if lease['slice_id'] != slice['slice_id']:
                     leases.remove(lease)
            for channel in all_reserved_channels:
                 if channel['slice_id'] != slice['slice_id']:
                     reserved_channels.remove(channel)

        rspec_channels = []
        for channel in reserved_channels:
             
            rspec_channel = {}
            #retrieve channel number  
            for chl in channels:
                 if chl['channel_id'] == channel['channel_id']:
                     channel_number = chl['channel']
                     break

            rspec_channel['channel_num'] = channel_number
            rspec_channel['start_time'] = channel['start_time']
            rspec_channel['duration'] = (int(channel['end_time']) - int(channel['start_time'])) / int(grain)
            rspec_channel['component_id'] = channel_to_urn(self.driver.hrn, self.driver.testbedInfo['name'], channel_number)
                 
            # retreive slicename
            for slc in slices:
                 if slc['slice_id'] == channel['slice_id']:
                     slicename = slc['slice_name']
                     break

            if slice_xrn:
                slice_urn = slice_xrn
                slice_hrn = urn_to_hrn(slice_urn)
            else:
                slice_hrn = slicename_to_hrn(self.driver.hrn, self.driver.testbedInfo['name'], slicename)
                slice_urn = hrn_to_urn(slice_hrn, 'slice')

            rspec_channel['slice_id'] = slice_urn
            rspec_channels.append(rspec_channel)

 
        rspec_leases = []
        for lease in leases:

            rspec_lease = Lease()
            
            rspec_lease['lease_id'] = lease['reservation_id']
            # retreive node name
            for node in nodes:
                 if node['node_id'] == lease['node_id']:
                     nodename = node['hostname']
                     break
           
            rspec_lease['component_id'] = hostname_to_urn(self.driver.hrn, self.driver.testbedInfo['name'], nodename)
            # retreive slicename
            for slc in slices:
                 if slc['slice_id'] == lease['slice_id']:
                     slicename = slc['slice_name']
                     break
            
            if slice_xrn:
                slice_urn = slice_xrn
                slice_hrn = urn_to_hrn(slice_urn)
            else:
                slice_hrn = slicename_to_hrn(self.driver.hrn, self.driver.testbedInfo['name'], slicename)
                slice_urn = hrn_to_urn(slice_hrn, 'slice')

            rspec_lease['slice_id'] = slice_urn
            rspec_lease['start_time'] = lease['start_time']
            rspec_lease['duration'] = (int(lease['end_time']) - int(lease['start_time'])) / int(grain)
            rspec_leases.append(rspec_lease)

        return (rspec_leases, rspec_channels)