Пример #1
0
    def make_node(self,
                  mac=False,
                  hostname=None,
                  status=None,
                  architecture=ARCHITECTURE.i386,
                  updated=None,
                  created=None,
                  nodegroup=None,
                  routers=None,
                  zone=None,
                  **kwargs):
        # hostname=None is a valid value, hence the set_hostname trick.
        if hostname is None:
            hostname = self.getRandomString(20)
        if status is None:
            status = NODE_STATUS.DEFAULT_STATUS
        if nodegroup is None:
            nodegroup = self.make_node_group()
        if routers is None:
            routers = [self.make_MAC()]
        if zone is None:
            zone = self.make_zone()
        node = Node(hostname=hostname,
                    status=status,
                    architecture=architecture,
                    nodegroup=nodegroup,
                    routers=routers,
                    zone=zone,
                    **kwargs)
        self._save_node_unchecked(node)
        if mac:
            self.make_mac_address(node=node)

        # Update the 'updated'/'created' fields with a call to 'update'
        # preventing a call to save() from overriding the values.
        if updated is not None:
            Node.objects.filter(id=node.id).update(updated=updated)
        if created is not None:
            Node.objects.filter(id=node.id).update(created=created)
        return reload_object(node)
Пример #2
0
 def test_create_node_creates_default_numanode(self):
     node = Node()
     node.save()
     [numanode] = node.numanode_set.all()
     self.assertIs(numanode.node, node)
     self.assertEqual(numanode.index, 0)
Пример #3
0
 def test_netboot_defaults_to_True(self):
     node = Node()
     self.assertTrue(node.netboot)