• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.get_id函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyrax.utils.get_id函数的典型用法代码示例。如果您正苦于以下问题:Python get_id函数的具体用法?Python get_id怎么用?Python get_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: delete_check

 def delete_check(self, entity, check):
     """
     Deletes the specified check from the entity.
     """
     uri = "/%s/%s/checks/%s" % (self.uri_base, utils.get_id(entity),
             utils.get_id(check))
     resp, resp_body = self.api.method_delete(uri)
开发者ID:CarlFK,项目名称:pyrax,代码行数:7,代码来源:cloudmonitoring.py


示例2: update_check

 def update_check(self, check, label=None, name=None, disabled=None,
         metadata=None, monitoring_zones_poll=None, timeout=None,
         period=None, target_alias=None, target_hostname=None,
         target_receiver=None):
     if monitoring_zones_poll:
         monitoring_zones_poll = utils.coerce_string_to_list(
                 monitoring_zones_poll)
         monitoring_zones_poll = [utils.get_id(mzp)
                 for mzp in monitoring_zones_poll]
     body = {}
     local_dict = locals()
     label = label or name
     params = ("label", "disabled", "metadata", "monitoring_zones_poll",
             "timeout", "period", "target_alias", "target_hostname",
             "target_receiver")
     body = _params_to_dict(params, body, locals())
     entity = check.entity
     uri = "/%s/%s/checks/%s" % (self.uri_base, utils.get_id(entity),
             utils.get_id(check))
     try:
         resp, resp_body = self.api.method_put(uri, body=body)
     except exc.BadRequest as e:
         msg = e.message
         dtls = e.details
         if msg.startswith("Validation error"):
             raise exc.InvalidMonitoringCheckUpdate("The update failed "
                     "validation: %s: %s" % (msg, dtls))
         else:
             # Some other issue.
             raise
     return resp_body
开发者ID:CarlFK,项目名称:pyrax,代码行数:31,代码来源:cloudmonitoring.py


示例3: update_policy

 def update_policy(self, scaling_group, policy, name=None, policy_type=None,
         cooldown=None, change=None, is_percent=False,
         desired_capacity=None, args=None):
     """
     Updates the specified policy. One or more of the parameters may be
     specified.
     """
     uri = "/%s/%s/policies/%s" % (self.uri_base,
             utils.get_id(scaling_group), utils.get_id(policy))
     if not isinstance(policy, AutoScalePolicy):
         # Received an ID
         policy = self.get_policy(scaling_group, policy)
     body = {"name": name or policy.name,
             "type": policy_type or policy.type,
             "cooldown": cooldown or policy.cooldown,
             }
     if desired_capacity is not None:
         body["desiredCapacity"] = desired_capacity
     elif change is not None:
         if is_percent:
             body["changePercent"] = change
         else:
             body["change"] = change
     else:
         if getattr(policy, "changePercent", None) is not None:
             body["changePercent"] = policy.changePercent
         elif getattr(policy, "change", None) is not None:
             body["change"] = policy.change
         elif getattr(policy, "desiredCapacity", None) is not None:
             body["desiredCapacity"] = policy.desiredCapacity
     args = args or getattr(policy, "args", None)
     if args is not None:
         body["args"] = args
     resp, resp_body = self.api.method_put(uri, body=body)
     return None
开发者ID:CarlFK,项目名称:pyrax,代码行数:35,代码来源:autoscale.py


示例4: create_alarm

    def create_alarm(self, entity, check, notification_plan, criteria=None,
            disabled=False, label=None, name=None, metadata=None):
        """
        Creates an alarm that binds the check on the given entity with a
        notification plan.

        Note that the 'criteria' parameter, if supplied, should be a string
        representing the DSL for describing alerting conditions and their
        output states. Pyrax does not do any validation of these criteria
        statements; it is up to you as the developer to understand the language
        and correctly form the statement. This alarm language is documented
        online in the Cloud Monitoring section of http://docs.rackspace.com.
        """
        uri = "/%s/%s/alarms" % (self.uri_base, utils.get_id(entity))
        body = {"check_id": utils.get_id(check),
                "notification_plan_id": utils.get_id(notification_plan),
                }
        if criteria:
            body["criteria"] = criteria
        if disabled is not None:
            body["disabled"] = disabled
        label_name = label or name
        if label_name:
            body["label"] = label_name
        if metadata:
            body["metadata"] = metadata
        resp, resp_body = self.api.method_post(uri, body=body)
        if resp.status_code == 201:
            alarm_id = resp.headers["x-object-id"]
            return self.get_alarm(entity, alarm_id)
开发者ID:CarlFK,项目名称:pyrax,代码行数:30,代码来源:cloudmonitoring.py


示例5: delete_alarm

 def delete_alarm(self, entity, alarm):
     """
     Deletes the specified alarm.
     """
     uri = "/%s/%s/alarms/%s" % (self.uri_base, utils.get_id(entity),
             utils.get_id(alarm))
     resp, resp_body = self.api.method_delete(uri)
开发者ID:CarlFK,项目名称:pyrax,代码行数:7,代码来源:cloudmonitoring.py


示例6: delete_policy

 def delete_policy(self, scaling_group, policy):
     """
     Deletes the specified policy from the scaling group.
     """
     uri = "/%s/%s/policies/%s" % (self.uri_base,
             utils.get_id(scaling_group), utils.get_id(policy))
     resp, resp_body = self.api.method_delete(uri)
开发者ID:lakshmi-kannan,项目名称:pyrax,代码行数:7,代码来源:autoscale.py


示例7: _get_node_base_uri

 def _get_node_base_uri(self, pool, node=None):
     if node is not None:
         template = "/%s/%s/nodes/%s"
         params = (self.uri_base, utils.get_id(pool), utils.get_id(node))
     else:
         template = "/%s/%s/nodes"
         params = (self.uri_base, utils.get_id(pool))
     return template % params
开发者ID:pratikmallya,项目名称:pyrax,代码行数:8,代码来源:rackconnect.py


示例8: get_check

 def get_check(self, entity, check):
     """
     Returns the current version of the check for the entity.
     """
     uri = "/%s/%s/checks/%s" % (self.uri_base, utils.get_id(entity),
             utils.get_id(check))
     resp, resp_body = self.api.method_get(uri)
     return CloudMonitorCheck(self, resp_body, entity)
开发者ID:CarlFK,项目名称:pyrax,代码行数:8,代码来源:cloudmonitoring.py


示例9: execute_policy

 def execute_policy(self, scaling_group, policy):
     """
     Executes the specified policy for this scaling group.
     """
     uri = "/%s/%s/policies/%s/execute" % (self.uri_base,
             utils.get_id(scaling_group), utils.get_id(policy))
     resp, resp_body = self.api.method_post(uri)
     return None
开发者ID:lakshmi-kannan,项目名称:pyrax,代码行数:8,代码来源:autoscale.py


示例10: get_record

 def get_record(self, domain, record):
     """
     Gets the full information for an existing record for this domain.
     """
     rec_id = utils.get_id(record)
     uri = "/domains/%s/records/%s" % (utils.get_id(domain), rec_id)
     resp, ret_body = self.api.method_get(uri)
     return ret_body
开发者ID:ozgurakan,项目名称:pyrax,代码行数:8,代码来源:clouddns.py


示例11: delete_record

 def delete_record(self, domain, record):
     """
     Deletes an existing record for a domain.
     """
     uri = "/domains/%s/records/%s" % (utils.get_id(domain), utils.get_id(record))
     resp, ret_body = self._async_call(uri, method="DELETE",
             error_class=exc.DomainRecordDeletionFailed, has_response=False)
     return ret_body
开发者ID:ozgurakan,项目名称:pyrax,代码行数:8,代码来源:clouddns.py


示例12: test_get_id

 def test_get_id(self):
     target = "test_id"
     class Obj_with_id(object):
         id = target
     obj = Obj_with_id()
     self.assertEqual(utils.get_id(obj), target)
     self.assertEqual(utils.get_id(obj), target)
     self.assertEqual(utils.get_id(obj.id), target)
开发者ID:ExtremeSitting,项目名称:pyrax,代码行数:8,代码来源:test_utils.py


示例13: get_metric_data_points

    def get_metric_data_points(self, entity, check, metric, start, end,
            points=None, resolution=None, stats=None):
        """
        Returns the data points for a given metric for the given period. The
        'start' and 'end' times must be specified; they can be be either Python
        date/datetime values, a string representing a date/datetime in either
        of 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DD' formats, or a Unix timestamp:

        The 'points' parameter represents the number of points to return. The
        'resolution' parameter represents the granularity of the data. You must
        specify either 'points' or 'resolution', but not both. The allowed
        values for resolution are: 'FULL', 'MIN5', 'MIN20', 'MIN60', 'MIN240',
        and 'MIN1440'.

        Finally, the 'stats' parameter specifies the stats you want returned.
        By default only the 'average' is returned. You omit this parameter,
        pass in a single value, or pass in a list of values. The allowed values
        are: 'average', 'variance', 'min', and 'max'
        """
        allowed_resolutions = ("FULL", "MIN5", "MIN20", "MIN60", "MIN240",
                "MIN1440")
        if not (points or resolution):
            raise exc.MissingMonitoringCheckGranularity("You must specify "
                    "either the 'points' or 'resolution' parameter when "
                    "fetching metrics.")
        if resolution:
            if resolution.upper() not in allowed_resolutions:
                raise exc.InvalidMonitoringMetricsResolution("The specified "
                        "resolution '%s' is not valid. The valid values are: "
                        "%s." % (resolution, str(allowed_resolutions)))
        start_tm = utils.to_timestamp(start)
        end_tm = utils.to_timestamp(end)
        qparms = []
        # Timestamps with fractional seconds currently cause a 408 (timeout)
        qparms.append("from=%s" % int(start_tm))
        qparms.append("to=%s" % int(end_tm))
        if points:
            qparms.append("points=%s" % points)
        if resolution:
            qparms.append("resolution=%s" % resolution.upper())
        if stats:
            stats = utils.coerce_string_to_list(stats)
            for stat in stats:
                qparms.append("select=%s" % stat)
        qparm = "&".join(qparms)
        uri = "/%s/%s/checks/%s/metrics/%s/plot?%s" % (self.uri_base,
                utils.get_id(entity), utils.get_id(check), metric, qparm)
        try:
            resp, resp_body = self.api.method_get(uri)
        except exc.BadRequest as e:
            msg = e.message
            dtls = e.details
            if msg.startswith("Validation error"):
                raise exc.InvalidMonitoringMetricsRequest("Your request was "
                        "invalid: '%s'" % dtls)
            else:
                raise
        return resp_body["values"]
开发者ID:naterh,项目名称:pyrax,代码行数:58,代码来源:cloudmonitoring.py


示例14: _make_pool_node_body

 def _make_pool_node_body(self, pool, server):
     return {
         'cloud_server': {
             'id': utils.get_id(server)
         },
         'load_balancer_pool': {
             'id': utils.get_id(pool),
         }
     }
开发者ID:pratikmallya,项目名称:pyrax,代码行数:9,代码来源:rackconnect.py


示例15: delete_webhook

 def delete_webhook(self, scaling_group, policy, webhook):
     """
     Deletes the specified webhook from the specified policy.
     """
     uri = "/%s/%s/policies/%s/webhooks/%s" % (self.uri_base,
             utils.get_id(scaling_group), utils.get_id(policy),
             utils.get_id(webhook))
     resp, resp_body = self.api.method_delete(uri)
     return None
开发者ID:lakshmi-kannan,项目名称:pyrax,代码行数:9,代码来源:autoscale.py


示例16: get_policy

 def get_policy(self, scaling_group, policy):
     """
     Gets the detail for the specified policy.
     """
     uri = "/%s/%s/policies/%s" % (self.uri_base,
             utils.get_id(scaling_group), utils.get_id(policy))
     resp, resp_body = self.api.method_get(uri)
     data = resp_body.get("policy")
     return AutoScalePolicy(self, data, scaling_group)
开发者ID:lakshmi-kannan,项目名称:pyrax,代码行数:9,代码来源:autoscale.py


示例17: list_webhooks

 def list_webhooks(self, scaling_group, policy):
     """
     Returns a list of all webhooks for the specified policy.
     """
     uri = "/%s/%s/policies/%s/webhooks" % (self.uri_base,
             utils.get_id(scaling_group), utils.get_id(policy))
     resp, resp_body = self.api.method_get(uri)
     return [AutoScaleWebhook(self, data, policy)
             for data in resp_body.get("webhooks", [])]
开发者ID:lakshmi-kannan,项目名称:pyrax,代码行数:9,代码来源:autoscale.py


示例18: list_metrics

 def list_metrics(self, entity, check):
     """
     Returns a list of all the metrics associated with the specified check.
     """
     uri = "/%s/%s/checks/%s/metrics" % (self.uri_base,
             utils.get_id(entity), utils.get_id(check))
     resp, resp_body = self.api.method_get(uri)
     metrics = [val["name"]
             for val in resp_body["values"]]
     return metrics
开发者ID:CarlFK,项目名称:pyrax,代码行数:10,代码来源:cloudmonitoring.py


示例19: get_record

 def get_record(self, domain, record):
     """
     Gets the full information for an existing record for this domain.
     """
     rec_id = utils.get_id(record)
     domain_id = utils.get_id(domain)
     uri = "/domains/%s/records/%s" % (domain_id, rec_id)
     resp, resp_body = self.api.method_get(uri)
     resp_body['domain_id'] = domain_id
     return CloudDNSRecord(self, resp_body, loaded=False)
开发者ID:216software,项目名称:pyrax,代码行数:10,代码来源:clouddns.py


示例20: get_alarm

 def get_alarm(self, entity, alarm):
     """
     Returns the alarm with the specified ID for this entity. If a
     CloudMonitorAlarm instance is passed, returns a new CloudMonitorAlarm
     object with the current state from the API.
     """
     uri = "/%s/%s/alarms/%s" % (self.uri_base, utils.get_id(entity),
             utils.get_id(alarm))
     resp, resp_body = self.api.method_get(uri)
     return CloudMonitorAlarm(self, resp_body, entity)
开发者ID:CarlFK,项目名称:pyrax,代码行数:10,代码来源:cloudmonitoring.py



注:本文中的pyrax.utils.get_id函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_name函数代码示例发布时间:2022-05-27
下一篇:
Python utils.get_checksum函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap