Merge "Make replication controller delete working"

This commit is contained in:
Jenkins 2015-01-16 05:20:29 +00:00 committed by Gerrit Code Review
commit aa45150fd4
6 changed files with 15 additions and 14 deletions

View File

@ -355,6 +355,4 @@ class ReplicationControllersController(rest.RestController):
if self.from_rcs:
raise exception.OperationNotPermitted
rpc_rc = objects.ReplicationController.get_by_uuid(
pecan.request.context, rc_uuid)
pecan.request.rpcapi.rc_delete(rpc_rc)
pecan.request.rpcapi.rc_delete(rc_uuid)

View File

@ -97,8 +97,8 @@ class API(rpc_service.API):
return objects.ReplicationController.list(context, limit, marker,
sort_key, sort_dir)
def rc_delete(self, rc):
return self._call('rc_delete', rc=rc)
def rc_delete(self, uuid):
return self._call('rc_delete', uuid=uuid)
def rc_show(self, ctxt, uuid):
return objects.ReplicationController.get_by_uuid(ctxt, uuid)

View File

@ -263,14 +263,14 @@ class KubeClient(object):
return False
return True
def rc_delete(self, master_address, uuid):
LOG.debug("rc_delete %s" % uuid)
def rc_delete(self, master_address, name):
LOG.debug("rc_delete %s" % name)
try:
out, err = utils.trycmd('kubectl', 'delete', 'rc', uuid,
out, err = utils.trycmd('kubectl', 'delete', 'rc', name,
'-s', master_address)
if err:
return False
except Exception as e:
LOG.error("Couldn't delete rc %s due to error %s" % (uuid, e))
LOG.error("Couldn't delete rc %s due to error %s" % (name, e))
return False
return True

View File

@ -193,10 +193,12 @@ class Handler(object):
rc.refresh(ctxt)
return rc
def rc_delete(self, ctxt, rc):
def rc_delete(self, ctxt, uuid):
LOG.debug("rc_delete ")
rc = objects.ReplicationController.get_by_uuid(ctxt, uuid)
k8s_master_url = _retrive_k8s_master_url(ctxt, rc)
# trigger a kubectl command
status = self.kube_cli.pod_delete(rc.uuid)
status = self.kube_cli.pod_delete(k8s_master_url, rc.name)
if not status:
return None
# call the rc object to persist in db

View File

@ -10,6 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from magnum.conductor import api
from magnum import objects
from magnum.tests.db import base as db_base
from mock import patch
@ -20,7 +21,8 @@ class TestRCController(db_base.DbTestCase):
rc.create()
return rc
def mock_rc_destroy(self, rc):
def mock_rc_destroy(self, uuid):
rc = objects.ReplicationController.get_by_uuid({}, uuid)
rc.destroy()
def test_rc_api(self):

View File

@ -113,9 +113,8 @@ class RPCAPITestCase(base.DbTestCase):
version='1.0',
rc=self.fake_rc)
# TODO(sdake) the parameters to delete operations are highly suspect
def test_rc_delete(self):
self._test_rpcapi('rc_delete',
'call',
version='1.0',
rc=self.fake_rc)
uuid=self.fake_rc['uuid'])