Beispiel #1
0
 def invoke(self, data=None, **conditions):
     if len(self.args) <= 0:
         logger.error("invalid request params", self.args)
         raise RestError(400, 'request params is invalid.')
     if conditions is None:
         logger.error('invalid conditions', conditions)
         raise RestError(400, 'request params is invalid.')
     if not 'cloud' in conditions:
         logger.error('invalid conditions', conditions)
         raise RestError(400, 'request params is invalid.')
     obj, action = self.args
     context = ScaleContext.covert_to_context(operation_obj=obj, name=conditions.pop('cloud'), **conditions)
     scale = ScaleProxy(context)
     if not hasattr(scale, '_{0}'.format(action)):
         raise RestError(501, 'UnSupport method ' + action)
     return getattr(scale, '_{0}'.format(action))(**conditions)
Beispiel #2
0
 def invoke(self, data=None, **conditions):
     if len(self.args) <= 0:
         logger.error("invalid request params", self.args)
         raise RestError(400, 'request params is invalid.')
     if conditions is None:
         logger.error('invalid conditions', conditions)
         raise RestError(400, 'request params is invalid.')
     if not 'cloud' in conditions:
         logger.error('invalid conditions', conditions)
         raise RestError(400, 'request params is invalid.')
     obj, action = self.args
     context = ScaleContext.covert_to_context(operation_obj=obj,
                                              name=conditions.pop('cloud'),
                                              **conditions)
     scale = ScaleProxy(context)
     if not hasattr(scale, '_{0}'.format(action)):
         raise RestError(501, 'UnSupport method ' + action)
     return getattr(scale, '_{0}'.format(action))(**conditions)
Beispiel #3
0
 def invoke(self, data=None, **conditions):
     """
     :param data: body object for scale out
     :param conditions:volume id of instance id for scale in
     :return:
     """
     if len(self.args) < 2:
         logger.error('can not support scale type')
         raise ValueError("can not support scale type")
     operate_obj, action = self.args
     validate_message(action, data, **conditions)
     # update data is data is None
     data = yaml.load(data) or {}
     data.update(**conditions)
     context = ScaleContext.covert_to_context(operation_obj=operate_obj, **data)
     scale = ScaleProxy(context)
     # invoke the proxy scale_in or scale_out method
     if not hasattr(scale, action):
         raise RestError(501, 'UnSupport method ' + action)
     return getattr(scale, action)()
Beispiel #4
0
 def invoke(self, data=None, **conditions):
     """
     :param data: body object for scale out
     :param conditions:volume id of instance id for scale in
     :return:
     """
     if len(self.args) < 2:
         logger.error('can not support scale type')
         raise ValueError("can not support scale type")
     operate_obj, action = self.args
     validate_message(action, data, **conditions)
     # update data is data is None
     data = yaml.load(data) or {}
     data.update(**conditions)
     context = ScaleContext.covert_to_context(operation_obj=operate_obj,
                                              **data)
     scale = ScaleProxy(context)
     # invoke the proxy scale_in or scale_out method
     if not hasattr(scale, action):
         raise RestError(501, 'UnSupport method ' + action)
     return getattr(scale, action)()