コード例 #1
0
ファイル: test_db.py プロジェクト: sapcc/networking-nsx-t
    def test_port_sgs(self):
        with self.session.begin(subtransactions=True):
            self.session.add(sg_model.SecurityGroupPortBinding(
                security_group_id=self.sg_id_1,
                port_id=self.port_id_1
            ))

        has_sg_on_host = db.has_security_group_used_by_host(self.ctx, self.host, self.sg_id_1)
        sg_with_rev = db.get_security_groups_with_revisions(self.ctx, self.host, 100, 0)
        sg = db.get_security_group_revision(self.ctx, self.sg_id_1)
        port_sgs = db.get_port_security_groups(self.ctx, self.port_id_1)
        port_ids = db.get_port_id_by_sec_group_id(self.ctx, self.host, self.sg_id_1)
        sgs_for_host = db.get_security_groups_for_host(self.ctx, self.host, 100, 0)
        sg_ips = db.get_security_group_members_ips(self.ctx, self.sg_id_1)
        sg_port_ids = db.get_security_group_port_ids(self.ctx, self.host, self.sg_id_1)

        self.assertEqual(True, has_sg_on_host)
        self.assertEqual(1, len(sg_with_rev))
        self.assertEqual(self.sg_id_1, sg_with_rev[0][0])
        self.assertEqual(3, len(sg))
        self.assertEqual(self.sg_id_1, sg[0])
        self.assertEqual(0, sg[1])
        self.assertEqual(True, sg[2])
        self.assertEqual(1, len(port_sgs))
        self.assertEqual(self.sg_id_1, port_sgs[0][0])
        self.assertEqual(1, len(port_ids))
        self.assertEqual(self.port_id_1, port_ids[0])
        self.assertEqual(8, len(sgs_for_host))
        for sgs_for_h in sgs_for_host:
            self.assertEqual(self.sg_id_1, sgs_for_h[0])
        self.assertEqual(1, len(sg_ips))
        self.assertEqual("192.168.0.100", sg_ips[0][0])
        self.assertEqual(1, len(sg_port_ids))
        self.assertEqual(self.port_id_1, sg_port_ids[0])
コード例 #2
0
 def _create_port_security_group_binding(self, context, port_id,
                                         security_group_id):
     with db_api.CONTEXT_WRITER.using(context):
         db = sg_models.SecurityGroupPortBinding(
             port_id=port_id, security_group_id=security_group_id)
         context.session.add(db)
コード例 #3
0
 def _create_port_security_group_binding(self, context, port_id,
                                         security_group_id):
     with context.session.begin(subtransactions=True):
         db = sg_models.SecurityGroupPortBinding(port_id=port_id,
                                       security_group_id=security_group_id)
         context.session.add(db)
コード例 #4
0
 def _create_port_security_group_binding(self, context, port_id,
                                         security_group_id):
     with db_api.context_manager.writer.using(context):
         db = sg_models.SecurityGroupPortBinding(
             port_id=port_id, security_group_id=security_group_id)
         context.session.add(db)