def recovery_list_policies(self, cntx):
     tenant_name = cntx.tenant
     try:
         headers, containers = Clients(cntx).swift().get_account(
             prefix=tenant_name, full_listing=True)
         # TOF: since cinder backup restore wants containers
         # (and not pseudo-containers)
         # we have to create a container for each policy execution.
         # Here we're doing a sort of hack to derive policy names from
         # container names in this form:
         # tenant_policyName_executionTimeStamp (e.g.,
         # admin_instance_only_20140825140210)
         # get policy names
         policies = {}
         for container in containers:
             try:
                 [policy_name, timestamp] =\
                     wp.get_policy_name_and_timestamp_from_container(
                         tenant_name, container['name'])
                 policies[policy_name] = {'id': policy_name,
                                          'name': policy_name,
                                          "timestamp": timestamp}
             except Exception, e:
                 # keep going
                 LOG.warn(e)
         # convert dict to list
         policies = policies.values()
         return policies
 def recovery_list_policy_executions(self, cntx, policy_name):
     LOG.debug("In recovery_list_policy_executions with name: %s"
               % policy_name)
     tenant_name = cntx.tenant
     headers, containers = Clients(cntx).swift().\
         get_account(prefix=tenant_name + "_" + policy_name,
                     full_listing=True)
     # sort in reverse name order (newer containers first)
     containers.sort(reverse=True, key=lambda k: k['name'])
     policies = []
     # split name and timestamp and put in list of dict
     for container in containers:
             try:
                 [policy_name, timestamp] =\
                     wp.get_policy_name_and_timestamp_from_container(
                         tenant_name, container['name'])
                 policies.append({'id': container['name'],
                                  'name': policy_name,
                                  "timestamp": timestamp})
             except Exception, e:
                 # keep going
                 LOG.warn(e)