Пример #1
0
 def post(self, request):
     with self._handle_exception(request):
         sname = request.data.get('share')
         if (Replica.objects.filter(share=sname).exists()):
             e_msg = ('Another replication task already exists for this '
                      'share(%s). Only 1-1 replication is supported '
                      'currently.' % sname)
             handle_exception(Exception(e_msg), request)
         share = self._validate_share(sname, request)
         appliance = self._validate_appliance(request)
         dpool = request.data.get('pool')
         crontab = request.data.get('crontab')
         task_name = request.data.get('task_name')
         data_port = self._validate_port(request.data.get('listener_port'),
                                         request)
         replication_ip = request.data.get('listener_ip', None)
         if (replication_ip is not None
                 and len(replication_ip.strip()) == 0):
             replication_ip = None
         ts = datetime.utcnow().replace(tzinfo=utc)
         r = Replica(task_name=task_name,
                     share=sname,
                     appliance=appliance.uuid,
                     pool=share.pool.name,
                     dpool=dpool,
                     enabled=True,
                     crontab=crontab,
                     data_port=data_port,
                     ts=ts,
                     replication_ip=replication_ip)
         r.save()
         self._refresh_crontab()
         return Response(ReplicaSerializer(r).data)
Пример #2
0
 def post(self, request):
     with self._handle_exception(request):
         sname = request.data.get('share')
         if (Replica.objects.filter(share=sname).exists()):
             e_msg = ('Another replication task already exists for this '
                      'share(%s). Only 1-1 replication is supported '
                      'currently.' % sname)
             handle_exception(Exception(e_msg), request)
         share = self._validate_share(sname, request)
         appliance = self._validate_appliance(request)
         dpool = request.data.get('pool')
         frequency = self._validate_frequency(request)
         task_name = request.data.get('task_name')
         try:
             data_port = int(request.data.get('data_port'))
             meta_port = int(request.data.get('meta_port'))
         except:
             e_msg = ('data and meta ports must be valid port '
                      'numbers(1-65535).')
             handle_exception(Exception(e_msg), request)
         data_port = self._validate_port(data_port, request)
         meta_port = self._validate_port(meta_port, request)
         ts = datetime.utcnow().replace(tzinfo=utc)
         r = Replica(task_name=task_name,
                     share=sname,
                     appliance=appliance.uuid,
                     pool=share.pool.name,
                     dpool=dpool,
                     enabled=True,
                     frequency=frequency,
                     data_port=data_port,
                     meta_port=meta_port,
                     ts=ts)
         r.save()
         return Response(ReplicaSerializer(r).data)
Пример #3
0
 def post(self, request):
     with self._handle_exception(request):
         sname = request.data.get('share')
         if (Replica.objects.filter(share=sname).exists()):
             e_msg = ('Another replication task already exists for this '
                      'share(%s). Only 1-1 replication is supported '
                      'currently.' % sname)
             handle_exception(Exception(e_msg), request)
         share = self._validate_share(sname, request)
         appliance = self._validate_appliance(request)
         dpool = request.data.get('pool')
         crontab = request.data.get('crontab')
         task_name = request.data.get('task_name')
         data_port = self._validate_port(request.data.get('listener_port'),
                                         request)
         replication_ip = request.data.get('listener_ip', None)
         if (replication_ip is not None and
                 len(replication_ip.strip()) == 0):
             replication_ip = None
         ts = datetime.utcnow().replace(tzinfo=utc)
         r = Replica(task_name=task_name, share=sname,
                     appliance=appliance.uuid, pool=share.pool.name,
                     dpool=dpool, enabled=True, crontab=crontab,
                     data_port=data_port, ts=ts,
                     replication_ip=replication_ip)
         r.save()
         self._refresh_crontab()
         return Response(ReplicaSerializer(r).data)
Пример #4
0
 def post(self, request):
     with self._handle_exception(request):
         sname = request.DATA.get('share')
         if (Replica.objects.filter(share=sname).exists()):
             e_msg = ('Another replication task already exists for this '
                      'share(%s). Only 1-1 replication is supported '
                      'currently.' % sname)
             handle_exception(Exception(e_msg), request)
         share = self._validate_share(sname, request)
         appliance = self._validate_appliance(request)
         dpool = request.DATA.get('pool')
         frequency = self._validate_frequency(request)
         task_name = request.DATA.get('task_name')
         try:
             data_port = int(request.DATA.get('data_port'))
             meta_port = int(request.DATA.get('meta_port'))
         except:
             e_msg = ('data and meta ports must be valid port '
                      'numbers(1-65535).')
             handle_exception(Exception(e_msg), request)
         data_port = self._validate_port(data_port, request)
         meta_port = self._validate_port(meta_port, request)
         ts = datetime.utcnow().replace(tzinfo=utc)
         r = Replica(task_name=task_name, share=sname,
                     appliance=appliance.uuid, pool=share.pool.name,
                     dpool=dpool, enabled=True, frequency=frequency,
                     data_port=data_port, meta_port=meta_port, ts=ts)
         r.save()
         return Response(ReplicaSerializer(r).data)
Пример #5
0
 def post(self, request):
     sname = request.DATA['share']
     share = self._validate_share(sname, request)
     aip = request.DATA['appliance']
     appliance = self._validate_appliance(aip, request)
     dpool = request.DATA['pool']
     frequency = int(request.DATA['frequency'])
     task_name = request.DATA['task_name']
     r = Replica(task_name=task_name, share=sname, appliance=aip,
                 pool=share.pool.name, dpool=dpool, enabled=True,
                 frequency=frequency)
     r.save()
     return Response(ReplicaSerializer(r).data)
Пример #6
0
 def post(self, request):
     sname = request.DATA['share']
     if (Replica.objects.filter(share=sname).exists()):
         e_msg = ('Another replication task already exists for this '
                  'share(%s). Sorry, only 1-1 replication is supported.'
                  % sname)
         handle_exception(Exception(e_msg), request)
     share = self._validate_share(sname, request)
     aip = request.DATA['appliance']
     self._validate_appliance(aip, request)
     dpool = request.DATA['pool']
     frequency = int(request.DATA['frequency'])
     task_name = request.DATA['task_name']
     data_port = int(request.DATA['data_port'])
     meta_port = int(request.DATA['meta_port'])
     ts = datetime.utcnow().replace(tzinfo=utc)
     r = Replica(task_name=task_name, share=sname, appliance=aip,
                 pool=share.pool.name, dpool=dpool, enabled=True,
                 frequency=frequency, data_port=data_port,
                 meta_port=meta_port, ts=ts)
     r.save()
     return Response(ReplicaSerializer(r).data)