launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #11035
[Merge] lp:~jtv/maas/kill-reconcile into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/kill-reconcile into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/kill-reconcile/+merge/119909
Actually that command was no longer in a position to run anyway. It would have broken on the first line of actual code, because the function to retrieve the papi proxy no longer exists. It's a bit disturbing that no tests took notice of this fact, but it's hard to test interaction with Cobbler's database. And maybe there was a test that was accidentally never committed/pushed.
The juju/vdenv script is now in all likelihood completely broken. I suspect we may end up re-doing vdenv entirely, given how closely it is coupled to Cobbler. For now I just made the minimum change that would let me remove the obsolete and now unusable command.
Jeroen
--
https://code.launchpad.net/~jtv/maas/kill-reconcile/+merge/119909
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/kill-reconcile into lp:maas.
=== modified file 'qa/scripts/prepare-for-juju-with-vdenv'
--- qa/scripts/prepare-for-juju-with-vdenv 2012-04-25 17:08:39 +0000
+++ qa/scripts/prepare-for-juju-with-vdenv 2012-08-16 12:31:20 +0000
@@ -19,8 +19,11 @@
cat <<'EOF'
This script assumes that `vdenv` has been started, and that `zimmer` is
-running. It will then *destroy* your development/demo database, rebuild
-everything, and reconcile with Cobbler.
+running. It will then *destroy* your development/demo database, and
+rebuild everything.
+
+WARNING: Script is probably broken at the moment and may simply destroy
+your database.
EOF
wait_for_user_to_press_n
@@ -36,7 +39,10 @@
bin/maas createadmin \
--username "${LOGNAME}" --password test \
--email "${LOGNAME}@example.com"
-bin/maas reconcile
+
+# TODO: Set up virtual nodes. We used to read them from Cobbler database
+# here, as set up by vdenv.
+
make dbharness <<'EOF'
UPDATE maasserver_node
SET owner_id = NULL, status = 4
@@ -69,11 +75,7 @@
4. Put it into `~/.juju/environments.yaml`.
-Some tips for productive Juju fun:
-
- - Check VNC output (via virsh). Go to vt7 for the boot log.
-
- - Check netboot enabled/disabled (in Cobbler).
+Be sure to check VNC output (via virsh). Go to vt7 for the boot log.
Good luck. You'll need it ;)
=== removed file 'src/maasserver/management/commands/reconcile.py'
--- src/maasserver/management/commands/reconcile.py 2012-05-22 12:27:18 +0000
+++ src/maasserver/management/commands/reconcile.py 1970-01-01 00:00:00 +0000
@@ -1,109 +0,0 @@
-# Copyright 2012 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Reconcile MAAS's view of the world with the Provisioning Server's.
-
-Both MAAS and the Provisioning Server will be examined. Missing nodes will be
-copied in *both* directions. Nodes that exist in common will have their MAC
-addresses reconciled in *both* directions. The result should be the union of
-nodes in MAAS and nodes as the Provisioning Server sees them.
-
-The Provisioning Server is currently stateless, so this actually implies
-reconciling with Cobbler.
-
-************************************************************************
-** DO NOT USE ON A PRODUCTION SYSTEM **
-** This is intended for use as a QA tool only **
-************************************************************************
-"""
-
-from __future__ import (
- absolute_import,
- print_function,
- unicode_literals,
- )
-
-__metaclass__ = type
-__all__ = [
- "Command",
- ]
-
-from django.core.management.base import NoArgsCommand
-from maasserver import provisioning
-from maasserver.enum import ARCHITECTURE
-from maasserver.models import Node
-
-
-ARCHITECTURE_GUESSES = {
- "i386": ARCHITECTURE.i386,
- "amd64": ARCHITECTURE.amd64,
- "x86_64": ARCHITECTURE.amd64,
- }
-
-
-def guess_architecture_from_profile(profile_name):
- """
- This attempts to obtain the architecture from a Cobbler profile name. The
- naming convention for profile names is "maas-${series}-${arch}".
- """
- for guess, architecture in ARCHITECTURE_GUESSES.items():
- if guess in profile_name:
- return architecture
- else:
- return None
-
-
-def reconcile():
- papi = provisioning.get_provisioning_api_proxy()
- nodes_local = {node.system_id: node for node in Node.objects.all()}
- nodes_remote = papi.get_nodes()
-
- missing_local = set(nodes_remote).difference(nodes_local)
- missing_local.discard("default")
- for name in missing_local:
- print("remote:", name)
- remote_node = nodes_remote[name]
- local_node = Node(
- system_id=remote_node["name"],
- architecture=(
- guess_architecture_from_profile(remote_node["profile"])),
- power_type=remote_node["power_type"],
- hostname=remote_node["name"])
- local_node.save()
- for mac_address in remote_node["mac_addresses"]:
- local_node.add_mac_address(mac_address)
-
- missing_remote = set(nodes_local).difference(nodes_remote)
- for name in missing_remote:
- print("local:", name)
- local_node = nodes_local[name]
- provisioning.provision_post_save_Node(
- sender=None, instance=local_node, created=False)
-
- present_in_both = set(nodes_local).intersection(nodes_remote)
- for name in present_in_both:
- print("common:", name)
- node_local = nodes_local[name]
- node_remote = nodes_remote[name]
- # Check that MACs are the same.
- macs_local = {
- mac.mac_address
- for mac in node_local.macaddress_set.all()
- }
- print("- local macs:", " ".join(sorted(macs_local)))
- macs_remote = {
- mac for mac in node_remote["mac_addresses"]
- }
- print("- remote macs:", " ".join(sorted(macs_remote)))
- for mac in macs_remote - macs_local:
- node_local.add_mac_address(mac)
- if len(macs_local - macs_remote) != 0:
- provisioning.set_node_mac_addresses(node_local)
-
-
-class Command(NoArgsCommand):
-
- help = __doc__
-
- def handle_noargs(self, **options):
- reconcile()
=== removed file 'src/maasserver/tests/test_commands_reconcile.py'
--- src/maasserver/tests/test_commands_reconcile.py 2012-05-22 12:27:18 +0000
+++ src/maasserver/tests/test_commands_reconcile.py 1970-01-01 00:00:00 +0000
@@ -1,28 +0,0 @@
-# Copyright 2012 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Tests for `maasserver.management.commands.reconcile`."""
-
-from __future__ import (
- absolute_import,
- print_function,
- unicode_literals,
- )
-
-__metaclass__ = type
-__all__ = []
-
-from maasserver.management.commands.reconcile import (
- guess_architecture_from_profile,
- )
-from maastesting.testcase import TestCase
-
-
-class TestFunctions(TestCase):
-
- def test_guess_architecture_from_profile(self):
- guess = guess_architecture_from_profile
- self.assertEqual("i386", guess("a-i386-profile"))
- self.assertEqual("amd64", guess("amd64-profile"))
- self.assertEqual("amd64", guess("profile-for-x86_64"))
- self.assertEqual(None, guess("profile-for-arm"))