Add RabbitMQ to proxy and improve process delete API.
Add RabbitMQ as an interprocess communication tool. Improved process delete API. Change-Id: Ie4956e356c2110a25962eda36c36d6f043847c03
This commit is contained in:
		@@ -417,28 +417,30 @@ class Controller(wsgi.Controller):
 | 
				
			|||||||
    @wsgi.response(204)
 | 
					    @wsgi.response(204)
 | 
				
			||||||
    def delete(self, req, gid, pid):
 | 
					    def delete(self, req, gid, pid):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def _get_children(context, gid, pid):
 | 
					        def _delete_children(context, gid, pid):
 | 
				
			||||||
            processes = db.process_get_all(context, gid, {"ppid": pid})
 | 
					            processes = db.process_get_all(context, gid, {"ppid": pid})
 | 
				
			||||||
            target_list = []
 | 
					 | 
				
			||||||
            for process in processes:
 | 
					            for process in processes:
 | 
				
			||||||
                target_list.append(process)
 | 
					                _delete_children(context, gid, process["pid"])
 | 
				
			||||||
                target_list.extend(
 | 
					                _delete(context, gid, process["pid"],
 | 
				
			||||||
                    _get_children(context, gid, process["pid"]))
 | 
					                        process["nova_instance_id"])
 | 
				
			||||||
            return target_list
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def _delete(context, gid, pid, nova_id):
 | 
				
			||||||
 | 
					            self.manager.process_delete(context, nova_id)
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					                db.process_delete(context, gid, pid)
 | 
				
			||||||
 | 
					            except exception.NotFound as e:
 | 
				
			||||||
 | 
					                LOG.exception(e)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self._uuid_check(gid, pid)
 | 
				
			||||||
 | 
					        context = req.environ['rack.context']
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self._uuid_check(gid, pid)
 | 
					 | 
				
			||||||
            context = req.environ['rack.context']
 | 
					 | 
				
			||||||
            process = db.process_get_by_pid(context, gid, pid)
 | 
					            process = db.process_get_by_pid(context, gid, pid)
 | 
				
			||||||
            target_list = _get_children(context, gid, pid)
 | 
					        except exception.NotFound as e:
 | 
				
			||||||
            target_list.append(process)
 | 
					            raise webob.exc.HTTPNotFound(explanation=e.format_message())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for process in target_list:
 | 
					        _delete_children(context, gid, pid)
 | 
				
			||||||
                self.manager.process_delete(
 | 
					        _delete(context, gid, pid, process["nova_instance_id"])
 | 
				
			||||||
                    context, process["nova_instance_id"])
 | 
					 | 
				
			||||||
                db.process_delete(context, gid, process["pid"])
 | 
					 | 
				
			||||||
        except exception.NotFound as exc:
 | 
					 | 
				
			||||||
            raise webob.exc.HTTPNotFound(explanation=exc.format_message())
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def create_resource():
 | 
					def create_resource():
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1886,23 +1886,82 @@ class ProcessesTest(test.NoDBTestCase):
 | 
				
			|||||||
        self.mox.StubOutWithMock(db, "process_get_by_pid")
 | 
					        self.mox.StubOutWithMock(db, "process_get_by_pid")
 | 
				
			||||||
        self.mox.StubOutWithMock(db, 'process_get_all')
 | 
					        self.mox.StubOutWithMock(db, 'process_get_all')
 | 
				
			||||||
        self.mox.StubOutWithMock(manager.ResourceOperator, "process_delete")
 | 
					        self.mox.StubOutWithMock(manager.ResourceOperator, "process_delete")
 | 
				
			||||||
        db.process_get_by_pid(IsA(context.RequestContext), GID, PID1)\
 | 
					
 | 
				
			||||||
 | 
					        # ppid
 | 
				
			||||||
 | 
					        #  |-- pid_1
 | 
				
			||||||
 | 
					        #  |    |---pid_1_1
 | 
				
			||||||
 | 
					        #  |---pid_2
 | 
				
			||||||
 | 
					        #  |    |---pid_2_1
 | 
				
			||||||
 | 
					        #  |         |---pid_2_1_1
 | 
				
			||||||
 | 
					        #  |         |---pid_2_1_2
 | 
				
			||||||
 | 
					        #  |---pid_3
 | 
				
			||||||
 | 
					        ppid = unicode(uuid.uuid4())
 | 
				
			||||||
 | 
					        pid_1 = unicode(uuid.uuid4())
 | 
				
			||||||
 | 
					        pid_1_1 = unicode(uuid.uuid4())
 | 
				
			||||||
 | 
					        pid_2 = unicode(uuid.uuid4())
 | 
				
			||||||
 | 
					        pid_2_1 = unicode(uuid.uuid4())
 | 
				
			||||||
 | 
					        pid_2_1_1 = unicode(uuid.uuid4())
 | 
				
			||||||
 | 
					        pid_2_1_2 = unicode(uuid.uuid4())
 | 
				
			||||||
 | 
					        pid_3 = unicode(uuid.uuid4())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        db.process_get_by_pid(IsA(context.RequestContext), GID, ppid)\
 | 
				
			||||||
            .AndReturn(
 | 
					            .AndReturn(
 | 
				
			||||||
                {"pid": PPID1, "nova_instance_id": "nova_instance_id_data1"})
 | 
					                {"pid": ppid, "nova_instance_id": "nova_id_ppid"})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # ppid -> [pid_1, pid_2, pid_3]
 | 
				
			||||||
        db.process_get_all(
 | 
					        db.process_get_all(
 | 
				
			||||||
            IsA(context.RequestContext), GID, {"ppid": PID1})\
 | 
					            IsA(context.RequestContext), GID, {"ppid": ppid})\
 | 
				
			||||||
            .AndReturn(
 | 
					            .AndReturn(
 | 
				
			||||||
                [{"pid": PID2, "nova_instance_id":
 | 
					                [{"pid": pid_1, "nova_instance_id": "nova_id_pid_1"},
 | 
				
			||||||
                    "nova_instance_id_data2"}])
 | 
					                 {"pid": pid_2, "nova_instance_id": "nova_id_pid_2"},
 | 
				
			||||||
 | 
					                 {"pid": pid_3, "nova_instance_id": "nova_id_pid_3"}])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # pid_1 -> [pid_1_1]
 | 
				
			||||||
        db.process_get_all(
 | 
					        db.process_get_all(
 | 
				
			||||||
            IsA(context.RequestContext), GID, {"ppid": PID2}).AndReturn([])
 | 
					            IsA(context.RequestContext), GID, {"ppid": pid_1})\
 | 
				
			||||||
        manager.ResourceOperator.process_delete(
 | 
					            .AndReturn(
 | 
				
			||||||
            IsA(context.RequestContext), IsA(str))
 | 
					                [{"pid": pid_1_1, "nova_instance_id": "nova_id_pid_1_1"}])
 | 
				
			||||||
        manager.ResourceOperator.process_delete(
 | 
					
 | 
				
			||||||
            IsA(context.RequestContext), IsA(str))
 | 
					        # pid_1_1 -> []
 | 
				
			||||||
 | 
					        db.process_get_all(
 | 
				
			||||||
 | 
					            IsA(context.RequestContext), GID, {"ppid": pid_1_1})\
 | 
				
			||||||
 | 
					            .AndReturn([])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # pid_2 -> [pid_2_1]
 | 
				
			||||||
 | 
					        db.process_get_all(
 | 
				
			||||||
 | 
					            IsA(context.RequestContext), GID, {"ppid": pid_2})\
 | 
				
			||||||
 | 
					            .AndReturn(
 | 
				
			||||||
 | 
					                [{"pid": pid_2_1, "nova_instance_id": "nova_id_pid_2_1"}])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # pid_2_1 -> [pid_2_1_1, pid_2_1_2]
 | 
				
			||||||
 | 
					        db.process_get_all(
 | 
				
			||||||
 | 
					            IsA(context.RequestContext), GID, {"ppid": pid_2_1})\
 | 
				
			||||||
 | 
					            .AndReturn(
 | 
				
			||||||
 | 
					                [{"pid": pid_2_1_1, "nova_instance_id": "nova_id_pid_2_1_1"},
 | 
				
			||||||
 | 
					                 {"pid": pid_2_1_2, "nova_instance_id": "nova_id_pid_2_1_2"}])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # pid_2_1_1 -> []
 | 
				
			||||||
 | 
					        db.process_get_all(
 | 
				
			||||||
 | 
					            IsA(context.RequestContext), GID, {"ppid": pid_2_1_1})\
 | 
				
			||||||
 | 
					            .AndReturn([])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # pid_2_1_2 -> []
 | 
				
			||||||
 | 
					        db.process_get_all(
 | 
				
			||||||
 | 
					            IsA(context.RequestContext), GID, {"ppid": pid_2_1_2})\
 | 
				
			||||||
 | 
					            .AndReturn([])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # pid_3 -> []
 | 
				
			||||||
 | 
					        db.process_get_all(
 | 
				
			||||||
 | 
					            IsA(context.RequestContext), GID, {"ppid": pid_3})\
 | 
				
			||||||
 | 
					            .AndReturn([])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for i in range(8):
 | 
				
			||||||
 | 
					            manager.ResourceOperator.process_delete(
 | 
				
			||||||
 | 
					                        IsA(context.RequestContext), IsA(str))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.mox.ReplayAll()
 | 
					        self.mox.ReplayAll()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        url = get_base_url(GID) + "/" + PID1
 | 
					        url = get_base_url(GID) + "/" + ppid
 | 
				
			||||||
        req = get_request(url, "DELETE")
 | 
					        req = get_request(url, "DELETE")
 | 
				
			||||||
        res = req.get_response(self.app)
 | 
					        res = req.get_response(self.app)
 | 
				
			||||||
        self.assertEqual(res.status_code, 204)
 | 
					        self.assertEqual(res.status_code, 204)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,7 +54,7 @@ yum -y install \
 | 
				
			|||||||
  libffi-devel libgcc-devel gcc python-devel python-lxml libxslt-devel \
 | 
					  libffi-devel libgcc-devel gcc python-devel python-lxml libxslt-devel \
 | 
				
			||||||
  libxml2-devel openssl-devel MySQL-python mysql-server python-pip redis \
 | 
					  libxml2-devel openssl-devel MySQL-python mysql-server python-pip redis \
 | 
				
			||||||
  openstack-swift openstack-swift-proxy openstack-swift-account openstack-swift-container \
 | 
					  openstack-swift openstack-swift-proxy openstack-swift-account openstack-swift-container \
 | 
				
			||||||
  openstack-swift-object memcached rsync xinetd openstack-utils xfsprogs || \
 | 
					  openstack-swift-object memcached rsync xinetd openstack-utils xfsprogs rabbitmq-server || \
 | 
				
			||||||
    exit_abort "Failed to install the required rpm packages"
 | 
					    exit_abort "Failed to install the required rpm packages"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
service iptables stop
 | 
					service iptables stop
 | 
				
			||||||
@@ -76,6 +76,14 @@ sed -i -e "s/bind 127.0.0.1/bind 0.0.0.0/g" /etc/redis.conf
 | 
				
			|||||||
service redis restart || exit_abort "Failed to start redis"
 | 
					service redis restart || exit_abort "Failed to start redis"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					########################################
 | 
				
			||||||
 | 
					# Setup RabbitMQ
 | 
				
			||||||
 | 
					########################################
 | 
				
			||||||
 | 
					echo "Setup RabbitMQ..."
 | 
				
			||||||
 | 
					/usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management
 | 
				
			||||||
 | 
					service rabbitmq-server restart || exit_abort "Failed to start rabbitmq-server"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
########################################
 | 
					########################################
 | 
				
			||||||
# Deploy RACK
 | 
					# Deploy RACK
 | 
				
			||||||
########################################
 | 
					########################################
 | 
				
			||||||
@@ -134,22 +142,6 @@ cp -f $ROOT_DIR/tools/setup/websocket_server.py /usr/bin/websocket_server
 | 
				
			|||||||
chmod +x /usr/bin/websocket_server
 | 
					chmod +x /usr/bin/websocket_server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
########################################
 | 
					 | 
				
			||||||
# Install python-rackclient
 | 
					 | 
				
			||||||
########################################
 | 
					 | 
				
			||||||
echo "Install python-rackclient..."
 | 
					 | 
				
			||||||
retval=$(which rack > /dev/null 2>&1; echo $?)
 | 
					 | 
				
			||||||
if [ "$retval" -ne 0 ]; then
 | 
					 | 
				
			||||||
  rm -fr ~/python-rackclient
 | 
					 | 
				
			||||||
  git clone https://github.com/stackforge/python-rackclient.git ~/python-rackclient ||\
 | 
					 | 
				
			||||||
    exit_abort "Failed to clone python-rackclient repository"
 | 
					 | 
				
			||||||
  cd ~/python-rackclient
 | 
					 | 
				
			||||||
  pip install -r requirements.txt || exit_abort "Failed to install the rackclient requirements"
 | 
					 | 
				
			||||||
  python setup.py install || exit_abort "Failed to install rackclient"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
########################################
 | 
					########################################
 | 
				
			||||||
# Setup Swift
 | 
					# Setup Swift
 | 
				
			||||||
########################################
 | 
					########################################
 | 
				
			||||||
@@ -247,6 +239,7 @@ swift-init rest start || exit_abort "Failed to start the rest of the Swift servi
 | 
				
			|||||||
chkconfig mysqld off
 | 
					chkconfig mysqld off
 | 
				
			||||||
chkconfig redis off
 | 
					chkconfig redis off
 | 
				
			||||||
chkconfig iptables off
 | 
					chkconfig iptables off
 | 
				
			||||||
 | 
					chkconfig rabbitmq-server off
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# set SELinux disabled
 | 
					# set SELinux disabled
 | 
				
			||||||
sed -i "s/\(^SELINUX=\).*/\1Disabled/" /etc/selinux/config
 | 
					sed -i "s/\(^SELINUX=\).*/\1Disabled/" /etc/selinux/config
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,6 +39,7 @@ proxy() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  websocket_server -d --bind-ipaddress 0.0.0.0 --bind-port 8888 --logfile /var/log/rack/ipc.log &
 | 
					  websocket_server -d --bind-ipaddress 0.0.0.0 --bind-port 8888 --logfile /var/log/rack/ipc.log &
 | 
				
			||||||
  service redis start || { echo "Error: redis could not start."; exit 1; }
 | 
					  service redis start || { echo "Error: redis could not start."; exit 1; }
 | 
				
			||||||
 | 
					  service rabbitmq-server start || { echo "Error: rabbitmq-server could not start."; exit 1; }
 | 
				
			||||||
  service memcached start || { echo "Error: memcached could not start."; exit 1; }
 | 
					  service memcached start || { echo "Error: memcached could not start."; exit 1; }
 | 
				
			||||||
  service xinetd start || { echo "Error: xinetd could not start."; exit 1; }
 | 
					  service xinetd start || { echo "Error: xinetd could not start."; exit 1; }
 | 
				
			||||||
  swift-init main start && swift-init rest start || { echo "Error: Swift services could not start."; exit 1; }
 | 
					  swift-init main start && swift-init rest start || { echo "Error: Swift services could not start."; exit 1; }
 | 
				
			||||||
@@ -49,4 +50,4 @@ if [ "$RACK_PID" == "null" ]; then
 | 
				
			|||||||
  api
 | 
					  api
 | 
				
			||||||
elif [ "$RACK_PID" != "null" ]; then
 | 
					elif [ "$RACK_PID" != "null" ]; then
 | 
				
			||||||
  proxy
 | 
					  proxy
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user