Beispiel #1
0
 def format_policies(policy_list):
     linkify_policy_list(policy_list, self.tenant_id, self.scaling_group_id)
     return {
         'policies': policy_list,
         "policies_links": get_policies_links(policy_list, self.tenant_id,
                                              self.scaling_group_id, None, **paginate)
     }
Beispiel #2
0
 def openstack_formatting(data, uuid):
     data["links"] = get_autoscale_links(self.tenant_id, uuid)
     data["state"] = format_state_dict(data["state"])
     linkify_policy_list(data["scalingPolicies"], self.tenant_id, uuid)
     data['scalingPolicies_links'] = get_policies_links(
         data['scalingPolicies'], self.tenant_id, uuid, rel='policies')
     return {"group": data}
 def test_get_policies_links(self):
     """
     `get_policies_links` gets link from `get_autoscale_links` and delegates to
     get_collection_links
     """
     links = get_policies_links('policies', 'tid', 'gid', rel='rel', limit=2, marker='3')
     self.assertEqual(links, 'col links')
     self.gal.assert_called_once_with('tid', 'gid', '', format=None)
     self.gcl.assert_called_once_with('policies', 'url', 'rel', 2, '3')
Beispiel #4
0
 def _format_output(result):
     uuid = result['id']
     result["state"] = format_state_dict(result["state"])
     request.setHeader(
         "Location", get_autoscale_links(self.tenant_id, uuid, format=None))
     result["links"] = get_autoscale_links(self.tenant_id, uuid)
     linkify_policy_list(result['scalingPolicies'], self.tenant_id, uuid)
     result['scalingPolicies_links'] = get_policies_links(
         result['scalingPolicies'], self.tenant_id, uuid, rel='policies')
     return {"group": result}
Beispiel #5
0
 def format_policies(policy_list):
     linkify_policy_list(policy_list, self.tenant_id,
                         self.scaling_group_id)
     return {
         'policies':
         policy_list,
         "policies_links":
         get_policies_links(policy_list, self.tenant_id,
                            self.scaling_group_id, None, **paginate)
     }
Beispiel #6
0
 def openstack_formatting(results):
     data, active = results
     data["links"] = get_autoscale_links(self.tenant_id, self.group_id)
     data["state"] = format_state_dict(data["state"], active)
     linkify_policy_list(
         data["scalingPolicies"], self.tenant_id, self.group_id)
     data['scalingPolicies_links'] = get_policies_links(
         data['scalingPolicies'], self.tenant_id, self.group_id,
         rel='policies')
     if with_webhooks(request):
         add_webhooks_links(data["scalingPolicies"])
     return {"group": data}
Beispiel #7
0
 def openstack_formatting(results):
     data, active = results
     data["links"] = get_autoscale_links(self.tenant_id, self.group_id)
     data["state"] = format_state_dict(data["state"], active)
     linkify_policy_list(
         data["scalingPolicies"], self.tenant_id, self.group_id)
     data['scalingPolicies_links'] = get_policies_links(
         data['scalingPolicies'], self.tenant_id, self.group_id,
         rel='policies')
     if with_webhooks(request):
         add_webhooks_links(data["scalingPolicies"])
     return {"group": data}
Beispiel #8
0
 def _format_output(result):
     uuid = result['id']
     result["state"] = format_state_dict(result["state"])
     request.setHeader(
         "Location",
         get_autoscale_links(self.tenant_id, uuid, format=None))
     result["links"] = get_autoscale_links(self.tenant_id, uuid)
     linkify_policy_list(
         result['scalingPolicies'], self.tenant_id, uuid)
     result['scalingPolicies_links'] = get_policies_links(
         result['scalingPolicies'],
         self.tenant_id, uuid, rel='policies')
     return {"group": result}
Beispiel #9
0
 def test_get_policies_links(self):
     """
     `get_policies_links` gets link from `get_autoscale_links` and delegates to
     get_collection_links
     """
     links = get_policies_links('policies',
                                'tid',
                                'gid',
                                rel='rel',
                                limit=2,
                                marker='3')
     self.assertEqual(links, 'col links')
     self.gal.assert_called_once_with('tid', 'gid', '', format=None)
     self.gcl.assert_called_once_with('policies', 'url', 'rel', 2, '3')