Merge "Fix for network validation on Neutron after stop"

This commit is contained in:
Jenkins 2014-02-21 14:18:03 +00:00 committed by Gerrit Code Review
commit 48a9966264
6 changed files with 22 additions and 13 deletions

View File

@ -381,7 +381,7 @@ class ClusterAttributesHandler(BaseHandler):
data = self.checked_data()
if cluster.are_attributes_locked:
if cluster.is_locked:
error = web.forbidden()
error.data = "Environment attributes can't be changed " \
"after, or in deploy."

View File

@ -62,7 +62,7 @@ class ProviderHandler(BaseHandler):
)
def check_if_network_configuration_locked(self, cluster):
if cluster.are_attributes_locked:
if cluster.is_locked:
error = web.forbidden()
error.data = "Network configuration can't be changed " \
"after, or in deploy."

View File

@ -32,7 +32,6 @@ from nailgun.db.sqlalchemy.models.base import Base
from nailgun.db.sqlalchemy.models.fields import JSON
from nailgun.db.sqlalchemy.models.node import Node
from nailgun.db.sqlalchemy.models.release import Release
from nailgun.db.sqlalchemy.models.task import Task
from nailgun.logger import logger
from nailgun.settings import settings
from nailgun.utils import dict_merge
@ -173,14 +172,8 @@ class Cluster(Base):
return '%s (id=%s, mode=%s)' % (self.name, self.id, self.mode)
@property
def are_attributes_locked(self):
if db().query(Task).filter_by(
cluster_id=self.id,
name="deploy",
status="running"
).count():
return True
elif self.status in ["new", "stopped"] and not \
def is_locked(self):
if self.status in ("new", "stopped") and not \
db().query(Node).filter_by(
cluster_id=self.id,
status="ready"

View File

@ -273,7 +273,7 @@ class TaskHelper(object):
filter(Task.name.in_(
['check_before_deployment', 'check_networks'])).count()
return task.cluster.status == 'new' and error_checking_tasks_count
return not task.cluster.is_locked and error_checking_tasks_count
@classmethod
def __update_cluster_to_provisioning_error(cls, cluster):

View File

@ -551,9 +551,10 @@ class VerifyNetworksTaskManager(TaskManager):
if (
self.cluster.net_provider == 'neutron'
) and (
self.cluster.status != 'new'
self.cluster.is_locked
):
task.status = 'error'
task.progress = 100
task.message = (u'Network verification on Neutron '
'is not implemented yet')
db().add(task)
@ -562,6 +563,7 @@ class VerifyNetworksTaskManager(TaskManager):
if len(self.cluster.nodes) < 2:
task.status = 'error'
task.progress = 100
task.message = ('At least two nodes are required to be '
'in the environment for network verification.')
db().add(task)

View File

@ -363,6 +363,20 @@ class TestVerifyNeutronVlan(BaseIntegrationTest):
}]
)
def tearDown(self):
self._wait_for_threads()
super(TestVerifyNeutronVlan, self).tearDown()
@fake_tasks()
def test_verify_networks_after_stop(self):
self.cluster = self.env.clusters[0]
self.env.launch_deployment()
stop_task = self.env.stop_deployment()
self.env.wait_ready(stop_task, 60)
self.assertEquals(self.cluster.status, "stopped")
verify_task = self.env.launch_verify_networks()
self.env.wait_ready(verify_task, 60)
@fake_tasks(fake_rpc=False)
def test_network_verification_neutron_with_vlan_segmentation(
self, mocked_rpc):