Beispiel #1
0
    def test_set_network_hosts(self):
        self.mox.StubOutWithMock(db, "network_get_all")
        self.mox.StubOutWithMock(db, "network_set_host")
        self.mox.StubOutWithMock(db, "network_update")

        db.network_get_all(mox.IgnoreArg()).AndReturn([networks[0]])
        db.network_set_host(mox.IgnoreArg(), networks[0]["id"], mox.IgnoreArg()).AndReturn(HOST)
        db.network_update(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg())
        self.mox.ReplayAll()

        self.network.set_network_hosts(None)
Beispiel #2
0
 def save(self, context):
     updates = self._get_primitive_changes()
     if 'netmask_v6' in updates:
         # NOTE(danms): For some reason, historical code stores the
         # IPv6 netmask as just the CIDR mask length, so convert that
         # back here before saving for now.
         updates['netmask_v6'] = netaddr.IPNetwork(
             updates['netmask_v6']).netmask
     set_host = 'host' in updates
     if set_host:
         db.network_set_host(context, self.id, updates.pop('host'))
     if updates:
         db_network = db.network_update(context, self.id, updates)
     elif set_host:
         db_network = db.network_get(context, self.id)
     else:
         db_network = None
     if db_network is not None:
         self._from_db_object(context, self, db_network)
Beispiel #3
0
 def save(self, context):
     updates = self._get_primitive_changes()
     if 'netmask_v6' in updates:
         # NOTE(danms): For some reason, historical code stores the
         # IPv6 netmask as just the CIDR mask length, so convert that
         # back here before saving for now.
         updates['netmask_v6'] = netaddr.IPNetwork(
             updates['netmask_v6']).netmask
     set_host = 'host' in updates
     if set_host:
         db.network_set_host(context, self.id, updates.pop('host'))
     if updates:
         db_network = db.network_update(context, self.id, updates)
     elif set_host:
         db_network = db.network_get(context, self.id)
     else:
         db_network = None
     if db_network is not None:
         self._from_db_object(context, self, db_network)