old_contents: # Copyright 2013-2015 Massachusetts Open Cloud Contributors
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the
  # License.  You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing,
  # software distributed under the License is distributed on an "AS
  # IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  # express or implied.  See the License for the specific language
  # governing permissions and limitations under the License.
  """Unit tests for headnodes.
  
  These require an actual libvirt daemon (and full HaaS setup), and are
  somewhat particular to the MOC's development environment. They may be
  difficult to run in other contexts.
  """
  
  from haas.test_common import *
  from haas import config, server, rest
  import pytest
  
  
  @pytest.fixture
  def configure():
      config_testsuite()
      config.load_extensions()
  
  
  @pytest.fixture
  def db(request):
      return fresh_database(request)
  
  
  @pytest.fixture
  def server_init():
      server.register_drivers()
      server.validate_state()
  
  
  @pytest.yield_fixture
  def with_request_context():
      with rest.RequestContext():
          yield
  
  
  headnode_cleanup = pytest.fixture(headnode_cleanup)
  pytestmark = pytest.mark.usefixtures('configure',
                                       'server_init',
                                       'db',
                                       'with_request_context',
                                       'headnode_cleanup')
      
  
  
  class TestIpmi():
      """ Test IPMI driver calls using functions included in the IPMI driver. """
  
      def collect_nodes(self, db):
          """ Collects nodes in the free list. 
  	Raises error if free-nodes are less than 2. 
          """
          free_nodes = db.query(Node).filter_by(project_id=None).all()
          return free_nodes
  
      def test_node_power_cycle(self, db):
          nodes = self.collect_nodes(db)
          for node in nodes:
              api.node_power_cycle(node.label)
  
      def test_node_power_off(self, db):
          nodes = self.collect_nodes(db)
          for node in nodes:
              api.node_power_off(node.label)
  
  
  
new_contents: # Copyright 2013-2015 Massachusetts Open Cloud Contributors
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the
  # License.  You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing,
  # software distributed under the License is distributed on an "AS
  # IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  # express or implied.  See the License for the specific language
  # governing permissions and limitations under the License.
  """Unit tests for headnodes.
  
  These require an actual libvirt daemon (and full HaaS setup), and are
  somewhat particular to the MOC's development environment. They may be
  difficult to run in other contexts.
  """
  
  from haas.test_common import *
  from haas import config, server, rest
  import pytest
  
  
  @pytest.fixture
  def configure():
      config_testsuite()
      config.load_extensions()
  
  
  @pytest.fixture
  def db(request):
      return fresh_database(request)
  
  
  @pytest.fixture
  def server_init():
      server.register_drivers()
      server.validate_state()
  
  
  with_request_context = pytest.yield_fixture(with_request_context)
  
  
  headnode_cleanup = pytest.fixture(headnode_cleanup)
  pytestmark = pytest.mark.usefixtures('configure',
                                       'server_init',
                                       'db',
                                       'with_request_context',
                                       'headnode_cleanup')
  
  
  
  class TestIpmi():
      """ Test IPMI driver calls using functions included in the IPMI driver. """
  
      def collect_nodes(self, db):
          """ Collects nodes in the free list.
  	Raises error if free-nodes are less than 2.
          """
          free_nodes = db.query(Node).filter_by(project_id=None).all()
          return free_nodes
  
      def test_node_power_cycle(self, db):
          nodes = self.collect_nodes(db)
          for node in nodes:
              api.node_power_cycle(node.label)
  
      def test_node_power_off(self, db):
          nodes = self.collect_nodes(db)
          for node in nodes:
              api.node_power_off(node.label)
  
  
  
subject: Fix bitrot in ipmi deployment tests.