Merge "Add rc_data support for magnum replication controller"
This commit is contained in:
commit
953139c9f9
@ -88,6 +88,9 @@ class ReplicationController(base.APIBase):
|
|||||||
rc_definition_url = wtypes.text
|
rc_definition_url = wtypes.text
|
||||||
"""URL for ReplicationController file to create the RC"""
|
"""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)
|
links = wsme.wsattr([link.Link], readonly=True)
|
||||||
"""A list containing a self link and associated rc links"""
|
"""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
|
# ignore rc_definition_url as it was used for create rc
|
||||||
if field == 'rc_definition_url':
|
if field == 'rc_definition_url':
|
||||||
continue
|
continue
|
||||||
|
# ignore rc_data as it was used for create rc
|
||||||
|
if field == 'rc_data':
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
patch_val = getattr(rc, field)
|
patch_val = getattr(rc, field)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -174,8 +174,9 @@ class Handler(object):
|
|||||||
# Replication Controller Operations
|
# Replication Controller Operations
|
||||||
def rc_create(self, ctxt, rc):
|
def rc_create(self, ctxt, rc):
|
||||||
LOG.debug("rc_create")
|
LOG.debug("rc_create")
|
||||||
|
k8s_master_url = _retrive_k8s_master_url(ctxt, rc)
|
||||||
# trigger a kubectl command
|
# trigger a kubectl command
|
||||||
status = self.kube_cli.rc_create(rc)
|
status = self.kube_cli.rc_create(k8s_master_url, rc)
|
||||||
if not status:
|
if not status:
|
||||||
return None
|
return None
|
||||||
# call the rc object to persist in db
|
# call the rc object to persist in db
|
||||||
|
@ -34,6 +34,7 @@ class ReplicationController(base.MagnumObject):
|
|||||||
'selector': obj_utils.dict_or_none,
|
'selector': obj_utils.dict_or_none,
|
||||||
'replicas': int,
|
'replicas': int,
|
||||||
'rc_definition_url': obj_utils.str_or_none,
|
'rc_definition_url': obj_utils.str_or_none,
|
||||||
|
'rc_data': obj_utils.str_or_none,
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -43,6 +44,9 @@ class ReplicationController(base.MagnumObject):
|
|||||||
# ignore rc_definition_url as it was used for create rc
|
# ignore rc_definition_url as it was used for create rc
|
||||||
if field == 'rc_definition_url':
|
if field == 'rc_definition_url':
|
||||||
continue
|
continue
|
||||||
|
# ignore rc_data as it was used for create rc
|
||||||
|
if field == 'rc_data':
|
||||||
|
continue
|
||||||
rc[field] = db_rc[field]
|
rc[field] = db_rc[field]
|
||||||
|
|
||||||
rc.obj_reset_changes()
|
rc.obj_reset_changes()
|
||||||
|
@ -31,6 +31,9 @@ class TestKube(base.BaseTestCase):
|
|||||||
def mock_service(self):
|
def mock_service(self):
|
||||||
return objects.Service({})
|
return objects.Service({})
|
||||||
|
|
||||||
|
def mock_rc(self):
|
||||||
|
return objects.ReplicationController({})
|
||||||
|
|
||||||
def mock_bay(self):
|
def mock_bay(self):
|
||||||
return objects.Bay({})
|
return objects.Bay({})
|
||||||
|
|
||||||
@ -120,3 +123,18 @@ class TestKube(base.BaseTestCase):
|
|||||||
self.kube_handler.service_create({}, expected_service)
|
self.kube_handler.service_create({}, expected_service)
|
||||||
mock_kube_cli.service_create.assert_called_once_with(
|
mock_kube_cli.service_create.assert_called_once_with(
|
||||||
expected_master_url, expected_service)
|
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