Exemple #1
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)
Exemple #2
0
 def get(self, request, *args, **kwargs):
     from deveops.tools.aliyun import ecs, cms
     API = ecs.AliyunECSTool()
     API = cms.AliyunCMSTool()
     from deveops.utils import vmware
     obj = self.get_object()
     data = None
     if obj.detail.aliyun_id:
         data = API.get_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)