
Pylint is currently running python3.0 syntax and we are updating the pylint to python3.9. As a result we received a few warnings that have not been previously identified with python3.0 syntax. This code change will address those warnings raised by latest pylint check. The following alarms are addressed: 1. W0237 - Parameter '.' has been renamed to '.' in overridden method 2. E1101 - Instance of '.' has no '.' member (no-member) 3. W0127 - Assigning the same variable to itself 4. E4702 - Iterated dict is being modified inside for loop body 5. W0602 - Using global for '.' but no assignment is done 6. E1123 - Unexpected keyword argument '.'. in method call 7. W0238 - Unused private memeber '.' 8. E1121 - Too many positional arguments for methods call The following alarms are still remain suppressed: 1. W1514 - Using open with specifying encoding (python2 does not support this change) 2. W0707 - Consider explicitly re-raising using raise '.' from '.' (same as above) Test Plan : 1. Perform DC Regression Test and compare before and after code change 2. Ensure Tox can pass on both Debain and CentOS build server 3. Ensure pylint3 and pylint3.9 can pass without warning 4. Ensure ISO can be properly booted on both Debian and CentOS Story: 2008943 Task: 45832 Signed-off-by: BoYuan Chang <boyuan.chang@windriver.com> Change-Id: I6f3a25fd788a3bdc021067c624123132a716e5c8
71 lines
2.9 KiB
Python
71 lines
2.9 KiB
Python
# Copyright (c) 2015 Ericsson AB.
|
|
# Copyright (c) 2020-2022 Wind River Systems, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
"""Service object."""
|
|
|
|
from dcorch.db import api as db_api
|
|
from dcorch.objects import base
|
|
from oslo_versionedobjects import fields as ovo_fields
|
|
|
|
|
|
@base.OrchestratorObjectRegistry.register
|
|
class Service(base.OrchestratorObject, base.VersionedObjectDictCompat):
|
|
"""DC Orchestrator service object."""
|
|
|
|
fields = {
|
|
'id': ovo_fields.UUIDField(),
|
|
'host': ovo_fields.StringField(),
|
|
'binary': ovo_fields.StringField(),
|
|
'topic': ovo_fields.StringField(),
|
|
'disabled': ovo_fields.BooleanField(),
|
|
'disabled_reason': ovo_fields.StringField(nullable=True),
|
|
'created_at': ovo_fields.DateTimeField(),
|
|
'updated_at': ovo_fields.DateTimeField(),
|
|
'deleted_at': ovo_fields.DateTimeField(nullable=True),
|
|
'deleted': ovo_fields.IntegerField(nullable=True),
|
|
}
|
|
|
|
@classmethod
|
|
def create(cls, context, service_id, host=None, binary=None, topic=None):
|
|
obj = db_api.service_create(context, service_id=service_id, host=host,
|
|
binary=binary, topic=topic)
|
|
return cls._from_db_object(context, cls(context), obj)
|
|
|
|
@classmethod
|
|
def get(cls, context, service_id):
|
|
obj = db_api.service_get(context, service_id)
|
|
return cls._from_db_object(context, cls(), obj)
|
|
|
|
@classmethod
|
|
def get_all(cls, context):
|
|
objs = db_api.service_get_all(context)
|
|
return [cls._from_db_object(context, cls(), obj) for obj in objs]
|
|
|
|
# A function named update has been defined inside the base class (oslo_versionedobjects)
|
|
# which was defined with different parameters and served a different purpose
|
|
# Pylint was not able to distinguish the two thus raised an warning (W0237) suggesting
|
|
# undesired parameter name change. Added suppress to ignore this check
|
|
# Since alarm W0237 was not introduced until pylint 2.1x, the CentOS pylint (running 2.3) will
|
|
# raise an alarm (E0012) on W0237 suggesting it is invalid, Another suppress is added for E0012
|
|
@classmethod
|
|
def update(cls, context, obj_id, values=None): # pylint: disable=E0012,W0237
|
|
obj = db_api.service_update(context, obj_id, values=values)
|
|
return cls._from_db_object(context, cls(), obj)
|
|
|
|
@classmethod
|
|
def delete(cls, context, obj_id):
|
|
db_api.service_delete(context, obj_id)
|