"Fossies" - the Fresh Open Source Software Archive

Member "senlin-8.0.0/senlin/objects/requests/clusters.py" (16 Oct 2019, 9205 Bytes) of package /linux/misc/openstack/senlin-8.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "clusters.py" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 4.0.0_vs_6.0.0.

    1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    2 # not use this file except in compliance with the License. You may obtain
    3 # a copy of the License at
    4 #
    5 #         http://www.apache.org/licenses/LICENSE-2.0
    6 #
    7 # Unless required by applicable law or agreed to in writing, software
    8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   10 # License for the specific language governing permissions and limitations
   11 # under the License.
   12 
   13 from oslo_config import cfg
   14 from oslo_utils import versionutils
   15 
   16 from senlin.common import consts
   17 from senlin.objects import base
   18 from senlin.objects import fields
   19 
   20 CONF = cfg.CONF
   21 CONF.import_opt('default_action_timeout', 'senlin.common.config')
   22 
   23 
   24 @base.SenlinObjectRegistry.register
   25 class ClusterListRequest(base.SenlinObject):
   26 
   27     fields = {
   28         'name': fields.ListOfStringsField(nullable=True),
   29         'status': fields.ListOfEnumField(
   30             valid_values=list(consts.CLUSTER_STATUSES), nullable=True),
   31         'limit': fields.NonNegativeIntegerField(nullable=True),
   32         'marker': fields.UUIDField(nullable=True),
   33         'sort': fields.SortField(
   34             valid_keys=list(consts.CLUSTER_SORT_KEYS), nullable=True),
   35         'project_safe': fields.FlexibleBooleanField(default=True),
   36     }
   37 
   38 
   39 @base.SenlinObjectRegistry.register
   40 class ClusterCreateRequestBody(base.SenlinObject):
   41 
   42     # VERSION 1.0: initial version
   43     # VERSION 1.1: added field 'config'
   44     VERSION = '1.1'
   45     VERSION_MAP = {
   46         '1.7': '1.1',
   47     }
   48 
   49     fields = {
   50         'name': fields.NameField(),
   51         'profile_id': fields.StringField(),
   52         'min_size': fields.CapacityField(
   53             nullable=True, minimum=0,
   54             default=consts.CLUSTER_DEFAULT_MIN_SIZE),
   55         'max_size': fields.CapacityField(
   56             nullable=True, minimum=-1,
   57             default=consts.CLUSTER_DEFAULT_MAX_SIZE),
   58         'desired_capacity': fields.CapacityField(
   59             nullable=True, minimum=0),
   60         'metadata': fields.JsonField(nullable=True, default={}),
   61         'timeout': fields.NonNegativeIntegerField(
   62             nullable=True, default=CONF.default_action_timeout),
   63         'config': fields.JsonField(nullable=True, default={}),
   64     }
   65 
   66     def obj_make_compatible(self, primitive, target_version):
   67         super(ClusterCreateRequest, self).obj_make_compatible(
   68             primitive, target_version)
   69         target_version = versionutils.convert_version_to_tuple(target_version)
   70         if target_version < (1, 1):
   71             if 'config' in primitive['senlin_object.data']:
   72                 del primitive['senlin_object.data']['config']
   73 
   74 
   75 @base.SenlinObjectRegistry.register
   76 class ClusterCreateRequest(base.SenlinObject):
   77 
   78     fields = {
   79         'cluster': fields.ObjectField('ClusterCreateRequestBody')
   80     }
   81 
   82 
   83 @base.SenlinObjectRegistry.register
   84 class ClusterGetRequest(base.SenlinObject):
   85 
   86     fields = {
   87         'identity': fields.StringField()
   88     }
   89 
   90 
   91 @base.SenlinObjectRegistry.register
   92 class ClusterUpdateRequest(base.SenlinObject):
   93 
   94     # VERSION 1.0: initial version
   95     # VERSION 1.1: added field 'profile_only'
   96     # VERSION 1.2: added field 'config'
   97     VERSION = '1.2'
   98     VERSION_MAP = {
   99         '1.6': '1.1',
  100         '1.7': '1.2',
  101     }
  102 
  103     fields = {
  104         'identity': fields.StringField(),
  105         'name': fields.NameField(nullable=True),
  106         'profile_id': fields.StringField(nullable=True),
  107         'metadata': fields.JsonField(nullable=True),
  108         'timeout': fields.NonNegativeIntegerField(nullable=True),
  109         'profile_only': fields.BooleanField(nullable=True),
  110         'config': fields.JsonField(nullable=True),
  111     }
  112 
  113     def obj_make_compatible(self, primitive, target_version):
  114         super(ClusterUpdateRequest, self).obj_make_compatible(
  115             primitive, target_version)
  116         target_version = versionutils.convert_version_to_tuple(target_version)
  117         if target_version < (1, 1):
  118             if 'profile_only' in primitive['senlin_object.data']:
  119                 del primitive['senlin_object.data']['profile_only']
  120         if target_version < (1, 2):
  121             if 'config' in primitive['senlin_object.data']:
  122                 del primitive['senlin_object.data']['config']
  123 
  124 
  125 @base.SenlinObjectRegistry.register
  126 class ClusterAddNodesRequest(base.SenlinObject):
  127 
  128     fields = {
  129         'identity': fields.StringField(),
  130         'nodes': fields.IdentityListField(min_items=1)
  131     }
  132 
  133 
  134 @base.SenlinObjectRegistry.register
  135 class ClusterDelNodesRequest(base.SenlinObject):
  136 
  137     # VERSION 1.0: Initial version
  138     # VERSION 1.1: Add field 'destroy_after_deletion'
  139     VERSION = '1.1'
  140     VERSION_MAP = {
  141         '1.4': '1.1',
  142     }
  143 
  144     fields = {
  145         'identity': fields.StringField(),
  146         'nodes': fields.IdentityListField(min_items=1),
  147         'destroy_after_deletion': fields.BooleanField(nullable=True,
  148                                                       default=False)
  149     }
  150 
  151     def obj_make_compatible(self, primitive, target_version):
  152         super(ClusterDelNodesRequest, self).obj_make_compatible(
  153             primitive, target_version)
  154         target_version = versionutils.convert_version_to_tuple(target_version)
  155         if target_version < (1, 1):
  156             if 'destroy_after_deletion' in primitive['senlin_object.data']:
  157                 del primitive['senlin_object.data']['destroy_after_deletion']
  158 
  159 
  160 @base.SenlinObjectRegistry.register
  161 class ClusterReplaceNodesRequest(base.SenlinObject):
  162 
  163     fields = {
  164         'identity': fields.StringField(),
  165         'nodes': fields.NodeReplaceMapField(),
  166     }
  167 
  168 
  169 @base.SenlinObjectRegistry.register
  170 class ClusterResizeRequest(base.SenlinObject):
  171 
  172     fields = {
  173         'identity': fields.StringField(),
  174         'adjustment_type': fields.AdjustmentTypeField(nullable=True),
  175         'number': fields.FloatField(nullable=True),
  176         'min_size': fields.CapacityField(nullable=True, minimum=0),
  177         'max_size': fields.CapacityField(nullable=True, minimum=-1),
  178         'min_step': fields.NonNegativeIntegerField(nullable=True),
  179         'strict': fields.BooleanField(nullable=True, default=True),
  180     }
  181 
  182 
  183 @base.SenlinObjectRegistry.register
  184 class ClusterScaleInRequest(base.SenlinObject):
  185 
  186     fields = {
  187         'identity': fields.StringField(),
  188         'count': fields.NonNegativeIntegerField(nullable=True),
  189     }
  190 
  191 
  192 @base.SenlinObjectRegistry.register
  193 class ClusterScaleOutRequest(base.SenlinObject):
  194 
  195     fields = {
  196         'identity': fields.StringField(),
  197         'count': fields.NonNegativeIntegerField(nullable=True),
  198     }
  199 
  200 
  201 @base.SenlinObjectRegistry.register
  202 class ClusterAttachPolicyRequest(base.SenlinObject):
  203 
  204     fields = {
  205         'identity': fields.StringField(),
  206         'policy_id': fields.StringField(),
  207         'enabled': fields.BooleanField(nullable=True, default=True),
  208     }
  209 
  210 
  211 @base.SenlinObjectRegistry.register
  212 class ClusterUpdatePolicyRequest(base.SenlinObject):
  213 
  214     fields = {
  215         'identity': fields.StringField(),
  216         'policy_id': fields.StringField(),
  217         'enabled': fields.BooleanField(nullable=True, default=True),
  218     }
  219 
  220 
  221 @base.SenlinObjectRegistry.register
  222 class ClusterDetachPolicyRequest(base.SenlinObject):
  223 
  224     fields = {
  225         'identity': fields.StringField(),
  226         'policy_id': fields.StringField(),
  227     }
  228 
  229 
  230 @base.SenlinObjectRegistry.register
  231 class ClusterCheckRequest(base.SenlinObject):
  232 
  233     fields = {
  234         'identity': fields.StringField(),
  235         'params': fields.JsonField(nullable=True),
  236     }
  237 
  238 
  239 @base.SenlinObjectRegistry.register
  240 class ClusterRecoverRequest(base.SenlinObject):
  241 
  242     fields = {
  243         'identity': fields.StringField(),
  244         'params': fields.JsonField(nullable=True),
  245     }
  246 
  247 
  248 @base.SenlinObjectRegistry.register
  249 class ClusterCollectRequest(base.SenlinObject):
  250 
  251     fields = {
  252         'identity': fields.StringField(),
  253         'path': fields.StringField(),
  254     }
  255 
  256 
  257 @base.SenlinObjectRegistry.register
  258 class ClusterOperationRequest(base.SenlinObject):
  259 
  260     fields = {
  261         'identity': fields.StringField(),
  262         'operation': fields.StringField(),
  263         'filters': fields.JsonField(nullable=True, default={}),
  264         'params': fields.JsonField(nullable=True, default={}),
  265     }
  266 
  267 
  268 @base.SenlinObjectRegistry.register
  269 class ClusterDeleteRequest(base.SenlinObject):
  270     # VERSION 1.0: Initial version
  271     # VERSION 1.1 Added field 'force'
  272     VERSION = '1.1'
  273     VERSION_MAP = {
  274         '1.8': '1.1',
  275     }
  276 
  277     fields = {
  278         'identity': fields.StringField(),
  279         'force': fields.BooleanField(default=False)
  280     }
  281 
  282     def obj_make_compatible(self, primitive, target_version):
  283         super(ClusterDeleteRequest, self).obj_make_compatible(
  284             primitive, target_version)
  285         target_version = versionutils.convert_version_to_tuple(target_version)
  286         if target_version < (1, 1):
  287             if 'force' in primitive['senlin_object.data']:
  288                 del primitive['senlin_object.data']['force']
  289 
  290 
  291 @base.SenlinObjectRegistry.register
  292 class ClusterCompleteLifecycleRequest(base.SenlinObject):
  293 
  294     fields = {
  295         'identity': fields.StringField(),
  296         'lifecycle_action_token': fields.StringField(),
  297     }