Beispiel #1
0
 def test_add_job_to_context(self):
     job_body = dict(tenant_id=self.tenant_id, action=self.action,
                     completed=False)
     job_body = dict(job=job_body)
     job = job_api.create_job(self.admin_context, job_body)
     self.assertIsNotNone(job)
     self.assertFalse(hasattr(self.admin_context, 'async_job'))
     job_api.add_job_to_context(self.admin_context, job['id'])
     self.assertTrue(hasattr(self.admin_context, 'async_job'))
     self.assertEqual(self.admin_context.async_job['job']['id'],
                      job['id'])
Beispiel #2
0
 def test_add_job_to_context(self):
     job_body = dict(tenant_id=self.tenant_id,
                     action=self.action,
                     completed=False)
     job_body = dict(job=job_body)
     job = job_api.create_job(self.admin_context, job_body)
     self.assertIsNotNone(job)
     self.assertFalse(hasattr(self.admin_context, 'async_job'))
     job_api.add_job_to_context(self.admin_context, job['id'])
     self.assertTrue(hasattr(self.admin_context, 'async_job'))
     self.assertEqual(self.admin_context.async_job['job']['id'], job['id'])
def _perform_async_update_rule(context, id, db_sg_group, rule_id, action):
    """Updates a SG rule async and return the job information.

    Only happens if the security group has associated ports. If the async
    connection fails the update continues (legacy mode).
    """
    rpc_reply = None
    sg_rpc = sg_rpc_api.QuarkSGAsyncProcessClient()
    ports = db_api.sg_gather_associated_ports(context, db_sg_group)
    if len(ports) > 0:
        rpc_reply = sg_rpc.start_update(context, id, rule_id, action)
        if rpc_reply:
            job_id = rpc_reply['job_id']
            job_api.add_job_to_context(context, job_id)
        else:
            LOG.error("Async update failed. Is the worker running?")
Beispiel #4
0
def _perform_async_update_rule(context, id, db_sg_group, rule_id, action):
    """Updates a SG rule async and return the job information.

    Only happens if the security group has associated ports. If the async
    connection fails the update continues (legacy mode).
    """
    rpc_reply = None
    sg_rpc = sg_rpc_api.QuarkSGAsyncProcessClient()
    ports = db_api.sg_gather_associated_ports(context, db_sg_group)
    if len(ports) > 0:
        rpc_reply = sg_rpc.start_update(context, id, rule_id, action)
        if rpc_reply:
            job_id = rpc_reply['job_id']
            job_api.add_job_to_context(context, job_id)
        else:
            LOG.error("Async update failed. Is the worker running?")
Beispiel #5
0
 def test_add_missing_job_to_context(self):
     self.assertFalse(hasattr(self.admin_context, 'async_job'))
     job_api.add_job_to_context(self.admin_context, 0)
     self.assertFalse(hasattr(self.admin_context, 'async_job'))
Beispiel #6
0
 def test_add_missing_job_to_context(self):
     self.assertFalse(hasattr(self.admin_context, 'async_job'))
     job_api.add_job_to_context(self.admin_context, 0)
     self.assertFalse(hasattr(self.admin_context, 'async_job'))