Ejemplo n.º 1
0
    def checkReservation(self, port, start_time, end_time):
        # check types
        if not type(start_time) is datetime.datetime and type(
                end_time) is datetime.datetime:
            raise error.InvalidRequestError(
                'Reservation start and end types must be datetime types')

        # sanity checks
        if start_time > end_time:
            raise error.InvalidRequestError(
                'Invalid request: Reverse duration (end time before start time)'
            )

        now = datetime.datetime.utcnow()
        if start_time < now:
            delta = now - start_time
            stamp = str(start_time).rsplit('.')[0]
            raise error.InvalidRequestError(
                'Invalid request: Start time in the past (Startime: %s Delta: %s)'
                % (stamp, str(delta)))

        if start_time > datetime.datetime(2025, 1, 1):
            raise error.InvalidRequestError(
                'Invalid request: Start time after year 2025')

        for (c_port, c_start_time, c_end_time) in self.connections:
            if port == c_port:
                if self._portOverlap(c_start_time, c_end_time, start_time,
                                     end_time):
                    raise error.InvalidRequestError(
                        'Port %s not available in specified time span' % port)
Ejemplo n.º 2
0
 def _checkVLANMatch(self, source_nrm_port, dest_nrm_port):
     source_vlan = source_nrm_port.split('.')[-1]
     dest_vlan = dest_nrm_port.split('.')[-1]
     if source_vlan != dest_vlan:
         raise error.InvalidRequestError(
             'Cannot create connection between different VLANs (%s/%s).' %
             (source_vlan, dest_vlan))
Ejemplo n.º 3
0
    def _checkTiming(self, res_start, res_end):
        # check that ports are available in the specified schedule
        if res_start in [None, ''] or res_end in [None, '']:
            raise error.InvalidRequestError(
                'Reservation must specify start and end time (was either None or '
                ')')

        # sanity checks
        if res_start > res_end:
            raise error.InvalidRequestError(
                'Refusing to make reservation with reverse duration')

        if res_start < datetime.datetime.utcnow():
            raise error.InvalidRequestError(
                'Refusing to make reservation with start time in the past')

        if res_start > datetime.datetime(2025, 1, 1):
            raise error.InvalidRequestError(
                'Refusing to make reservation with start time after 2025')
Ejemplo n.º 4
0
 def _checkVLANMatch(self, source_port, dest_port):
     source_vlan = source_port.split('=', 1)[1]
     dest_vlan = dest_port.split('=', 1)[1]
     if source_vlan != dest_vlan:
         raise error.InvalidRequestError(
             'Cannot create connection between different VLANs.')