예제 #1
0
    def test_validate_networks_none_fixed_ip(self):
        self.mox.StubOutWithMock(db, "network_get_all_by_uuids")

        requested_networks = [(1, None)]
        db.network_get_all_by_uuids(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(networks)
        self.mox.ReplayAll()
        self.network.validate_networks(self.context, requested_networks)
예제 #2
0
    def test_validate_networks_invalid_fixed_ip(self):
        self.mox.StubOutWithMock(db, "network_get_all_by_uuids")
        requested_networks = [(1, "192.168.0.100.1")]
        db.network_get_all_by_uuids(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(networks)
        self.mox.ReplayAll()

        self.assertRaises(exception.FixedIpInvalid, self.network.validate_networks, self.context, requested_networks)
예제 #3
0
    def test_validate_networks_none_fixed_ip(self):
        self.mox.StubOutWithMock(db, 'network_get_all_by_uuids')

        requested_networks = [(1, None)]
        db.network_get_all_by_uuids(mox.IgnoreArg(), mox.IgnoreArg(),
                                    mox.IgnoreArg()).AndReturn(networks)
        self.mox.ReplayAll()
        self.network.validate_networks(self.context, requested_networks)
예제 #4
0
    def test_validate_networks_invalid_fixed_ip(self):
        self.mox.StubOutWithMock(db, 'network_get_all_by_uuids')
        requested_networks = [(1, "192.168.0.100.1")]
        db.network_get_all_by_uuids(mox.IgnoreArg(), mox.IgnoreArg(),
                                    mox.IgnoreArg()).AndReturn(networks)
        self.mox.ReplayAll()

        self.assertRaises(exception.FixedIpInvalid,
                          self.network.validate_networks, self.context,
                          requested_networks)
예제 #5
0
    def test_validate_networks_empty_fixed_ip(self):
        self.mox.StubOutWithMock(db, 'network_get_all_by_uuids')

        requested_networks = [(1, "")]
        db.network_get_all_by_uuids(mox.IgnoreArg(),
                                mox.IgnoreArg()).AndReturn(networks)
        self.mox.ReplayAll()

        self.assertRaises(exception.FixedIpInvalid,
                          self.network.validate_networks,
                          None, requested_networks)
예제 #6
0
    def test_validate_networks(self):
        self.mox.StubOutWithMock(db, "network_get_all_by_uuids")
        self.mox.StubOutWithMock(db, "fixed_ip_get_by_address")

        requested_networks = [("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb", "192.168.1.100")]
        db.network_get_all_by_uuids(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(networks)

        fixed_ips[1]["network"] = FakeModel(**networks[1])
        fixed_ips[1]["instance"] = None
        db.fixed_ip_get_by_address(mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(fixed_ips[1])

        self.mox.ReplayAll()
        self.network.validate_networks(self.context, requested_networks)
예제 #7
0
    def test_validate_networks(self):
        self.mox.StubOutWithMock(db, 'network_get_all_by_uuids')
        self.mox.StubOutWithMock(db, "fixed_ip_get_by_address")

        requested_networks = [("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
                               "192.168.1.100")]
        db.network_get_all_by_uuids(mox.IgnoreArg(), mox.IgnoreArg(),
                                    mox.IgnoreArg()).AndReturn(networks)

        fixed_ips[1]['network'] = FakeModel(**networks[1])
        fixed_ips[1]['instance'] = None
        db.fixed_ip_get_by_address(mox.IgnoreArg(),
                                   mox.IgnoreArg()).AndReturn(fixed_ips[1])

        self.mox.ReplayAll()
        self.network.validate_networks(self.context, requested_networks)
예제 #8
0
 def get_by_uuids(cls, context, network_uuids, project_only='allow_none'):
     db_networks = db.network_get_all_by_uuids(context, network_uuids,
                                               project_only)
     return obj_base.obj_make_list(context, cls(context), objects.Network,
                                   db_networks)
예제 #9
0
파일: network.py 프로젝트: EdLeafe/nova
 def get_by_uuids(cls, context, network_uuids, project_only='allow_none'):
     db_networks = db.network_get_all_by_uuids(context, network_uuids,
                                               project_only)
     return obj_base.obj_make_list(context, cls(context), objects.Network,
                                   db_networks)