Remove useless get_one() method in SG API
Removes the servicegroup API had a get_one() method that was not used. Related blueprint: servicegroup-api-is-up-host-topic Change-Id: Ic2ee3f5cf31d0deab744d8bf23e2092c51ab1f36
This commit is contained in:
@@ -95,10 +95,3 @@ class API(object):
|
|||||||
LOG.debug('Returns ALL members of the [%s] '
|
LOG.debug('Returns ALL members of the [%s] '
|
||||||
'ServiceGroup', group_id)
|
'ServiceGroup', group_id)
|
||||||
return self._driver.get_all(group_id)
|
return self._driver.get_all(group_id)
|
||||||
|
|
||||||
def get_one(self, group_id):
|
|
||||||
"""Returns one member of the given group. The strategy to select
|
|
||||||
the member is decided by the driver (e.g. random or round-robin).
|
|
||||||
"""
|
|
||||||
LOG.debug('Returns one member of the [%s] group', group_id)
|
|
||||||
return self._driver.get_one(group_id)
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import random
|
|
||||||
|
|
||||||
|
|
||||||
class Driver(object):
|
class Driver(object):
|
||||||
"""Base class for all ServiceGroup drivers."""
|
"""Base class for all ServiceGroup drivers."""
|
||||||
@@ -33,16 +31,3 @@ class Driver(object):
|
|||||||
def get_all(self, group_id):
|
def get_all(self, group_id):
|
||||||
"""Returns ALL members of the given group."""
|
"""Returns ALL members of the given group."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def get_one(self, group_id):
|
|
||||||
"""The default behavior of get_one is to randomly pick one from
|
|
||||||
the result of get_all(). This is likely to be overridden in the
|
|
||||||
actual driver implementation.
|
|
||||||
"""
|
|
||||||
members = self.get_all(group_id)
|
|
||||||
if members is None:
|
|
||||||
return None
|
|
||||||
length = len(members)
|
|
||||||
if length == 0:
|
|
||||||
return None
|
|
||||||
return random.choice(members)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user