def _get_data(self):
     try:
         policy_id = self.kwargs['policy_id']
         policy = dragon.dragonclient(self.request).dr \
             .get_workload_policy(policy_id)
     except Exception:
         msg = _('Unable to retrieve details for policy "%s".') \
             % (policy_id)
         exceptions.handle(self.request, msg)
     return policy
 def get_policies_data(self):
     try:
         dr_client = dragon.dragonclient(self.request)
         policies = dr_client.dr.list_workload_policies()
         LOG.debug("Policies: %s" % policies)
         return policies
     except Exception as e:
         messages.error(self.request, "cannot get policies from dragon")
         LOG.error(e)
         return []
 def get_resources_data(self):
     try:
         dr_client = dragon.dragonclient(self.request)
         policy_id = self.kwargs['policy_id']
         resources = dr_client.dr.get_policy_resource_actions(policy_id)
         logging.warn("Resources: %s" % resources)
         return resources
     except Exception as e:
         messages.error(self.request, "cannot get resources from dragon")
         LOG.error(e)
         return []
 def get_exec_actions_data(self):
     try:
         policy_exec_id = self.kwargs['policy_execution_id']
         dr_client = dragon.dragonclient(self.request)
         exec_actions = dr_client.dr \
             .get_policy_execution_actions(policy_exec_id)
         return exec_actions
     except Exception as e:
         messages.error(self.request, "cannot get resources from dragon")
         LOG.error(e)
         return []
 def get_backups_data(self):
     try:
         dr_client = dragon.dragonclient(self.request)
         containers = dr_client.dr.recovery_list_policies()
         if type(containers) != NoneType:
             logging.info(containers)
             return containers
         else:
             return []
     except Exception, e:
         messages.error(self.request,
                        "cannot connect to recovery swift through dragon")
         logging.exception(e)
         return []
 def get_executions_data(self):
     try:
         dr_client = dragon.dragonclient(self.request)
         policy_id = self.kwargs['policy_id']
         executions = dr_client.dr.list_policy_executions(policy_id)
         logging.warn(executions)
         if isinstance(executions, list):
             return executions
         elif isinstance(executions, dict):
             return [executions]
     except:
         messages.error(self.request,
                        "Could not retrieve policy executions")
         logging.exception("Could not retrieve policy executions")
 def get_backups_data(self):
     try:
         dr_client = dragon.dragonclient(self.request)
         containers = dr_client.dr.recovery_list_policies()
         if type(containers) != NoneType:
             logging.info(containers)
             return containers
         else:
             return []
     except Exception, e:
         messages.error(self.request,
                        "cannot connect to recovery swift through dragon")
         logging.exception(e)
         return []
 def get_backups_data(self):
     try:
         dr_client = dragon.dragonclient(self.request)
         policy_name = self.kwargs['policy_name']
         containers = dr_client.dr \
             .recovery_list_policy_executions(policy_name)
         if type(containers) != NoneType:
             return containers
         else:
             return []
     except Exception, e:
         messages.error(self.request,
                        "cannot connect to recovery swift through dragon")
         logging.exception(e)
         return []
 def get_backups_data(self):
     try:
         dr_client = dragon.dragonclient(self.request)
         policy_name = self.kwargs['policy_name']
         containers = dr_client.dr \
             .recovery_list_policy_executions(policy_name)
         if type(containers) != NoneType:
             return containers
         else:
             return []
     except Exception, e:
         messages.error(self.request,
                 "cannot connect to recovery swift through dragon")
         logging.exception(e)
         return []
 def get_resources_data(self):
     try:
         policy_id = self.kwargs['policy_id']
         dr_client = dragon.dragonclient(self.request)
         filtered_resources = []
         dr_resources = dr_client.dr.get_policy_resource_actions(policy_id)
         dr_resource_ids = [x['resource_id'] for x in dr_resources]
         instances = self.get_instances_data()
         for instance in instances:
             if instance.id not in dr_resource_ids:
                 filtered_resources.append({'name': instance.name,
                                            'type': 'Instance',
                                            'id': instance.id})
         volumes = self.get_volumes_data()
         for volume in volumes:
             if volume.id not in dr_resource_ids:
                 filtered_resources.append({'name': volume.name,
                                            'type': 'Volume',
                                            'id': volume.id})
         return filtered_resources
     except Exception as e:
         messages.error(self.request, "cannot get resources from dragon")
         LOG.error(e)
         return []