Esempio n. 1
0
 def get(self, request, *args, **kwargs):
     from deveops.utils import aliyun
     data = None
     if self.kwargs['pk']:
         data = aliyun.fetch_Instance(self.kwargs['pk'])
         if data:
             data['type'] = 'aliyun'
         else:
             return Response(data, status=status.HTTP_406_NOT_ACCEPTABLE)
         return Response(data, status=status.HTTP_200_OK)
     else:
         return Response(data, status=status.HTTP_406_NOT_ACCEPTABLE)
Esempio n. 2
0
 def get(self, request, *args, **kwargs):
     from deveops.utils import aliyun
     from deveops.utils import vmware
     obj = self.get_object()
     data = None
     if obj.detail.aliyun_id:
         data = aliyun.fetch_Instance(obj.detail.aliyun_id)
         if data:
             data['type'] = 'aliyun'
         else:
             return Response(data, status=status.HTTP_406_NOT_ACCEPTABLE)
         return Response(data, status=status.HTTP_200_OK)
     elif obj.detail.vmware_id:
         data = vmware.fetch_Instance(obj.detail.vmware_id)
         if data:
             data['type'] = 'vmware'
         else:
             return Response(data, status=status.HTTP_406_NOT_ACCEPTABLE)
         return Response(data, status=status.HTTP_200_OK)
     else:
         return Response(data, status=status.HTTP_406_NOT_ACCEPTABLE)