Add rc_data support for magnum replication controller
Change-Id: I041ee8a4e111d6c900ff6d654eeb23d61fff28ff
This commit is contained in:
parent
444a202859
commit
9c68323035
@ -83,11 +83,14 @@ class ReplicationController(base.APIBase):
|
||||
"""Selector of this ReplicationController"""
|
||||
|
||||
replicas = wtypes.IntegerType()
|
||||
"""Replicas of this ReplicationController """
|
||||
"""Replicas of this ReplicationController"""
|
||||
|
||||
rc_definition_url = wtypes.text
|
||||
"""URL for ReplicationController file to create the RC"""
|
||||
|
||||
rc_data = wtypes.text
|
||||
"""Data for service to create the ReplicationController"""
|
||||
|
||||
links = wsme.wsattr([link.Link], readonly=True)
|
||||
"""A list containing a self link and associated rc links"""
|
||||
|
||||
@ -312,6 +315,9 @@ class ReplicationControllersController(rest.RestController):
|
||||
# ignore rc_definition_url as it was used for create rc
|
||||
if field == 'rc_definition_url':
|
||||
continue
|
||||
# ignore rc_data as it was used for create rc
|
||||
if field == 'rc_data':
|
||||
continue
|
||||
try:
|
||||
patch_val = getattr(rc, field)
|
||||
except AttributeError:
|
||||
|
@ -174,8 +174,9 @@ class Handler(object):
|
||||
# Replication Controller Operations
|
||||
def rc_create(self, ctxt, rc):
|
||||
LOG.debug("rc_create")
|
||||
k8s_master_url = _retrive_k8s_master_url(ctxt, rc)
|
||||
# trigger a kubectl command
|
||||
status = self.kube_cli.rc_create(rc)
|
||||
status = self.kube_cli.rc_create(k8s_master_url, rc)
|
||||
if not status:
|
||||
return None
|
||||
# call the rc object to persist in db
|
||||
|
@ -34,6 +34,7 @@ class ReplicationController(base.MagnumObject):
|
||||
'selector': obj_utils.dict_or_none,
|
||||
'replicas': int,
|
||||
'rc_definition_url': obj_utils.str_or_none,
|
||||
'rc_data': obj_utils.str_or_none,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
@ -43,6 +44,9 @@ class ReplicationController(base.MagnumObject):
|
||||
# ignore rc_definition_url as it was used for create rc
|
||||
if field == 'rc_definition_url':
|
||||
continue
|
||||
# ignore rc_data as it was used for create rc
|
||||
if field == 'rc_data':
|
||||
continue
|
||||
rc[field] = db_rc[field]
|
||||
|
||||
rc.obj_reset_changes()
|
||||
|
@ -31,6 +31,9 @@ class TestKube(base.BaseTestCase):
|
||||
def mock_service(self):
|
||||
return objects.Service({})
|
||||
|
||||
def mock_rc(self):
|
||||
return objects.ReplicationController({})
|
||||
|
||||
def mock_bay(self):
|
||||
return objects.Bay({})
|
||||
|
||||
@ -120,3 +123,18 @@ class TestKube(base.BaseTestCase):
|
||||
self.kube_handler.service_create({}, expected_service)
|
||||
mock_kube_cli.service_create.assert_called_once_with(
|
||||
expected_master_url, expected_service)
|
||||
|
||||
@patch('magnum.conductor.handlers.kube._retrive_k8s_master_url')
|
||||
def test_rc_create_with_success(self,
|
||||
mock_retrive_k8s_master_url):
|
||||
expected_master_url = 'master_address'
|
||||
expected_rc = self.mock_rc()
|
||||
expected_rc.create = mock.MagicMock()
|
||||
|
||||
mock_retrive_k8s_master_url.return_value = expected_master_url
|
||||
with patch.object(self.kube_handler, 'kube_cli') as mock_kube_cli:
|
||||
mock_kube_cli.rc_create.return_value = True
|
||||
|
||||
self.kube_handler.rc_create({}, expected_rc)
|
||||
mock_kube_cli.rc_create.assert_called_once_with(
|
||||
expected_master_url, expected_rc)
|
||||
|
Loading…
Reference in New Issue
Block a user