def enableComponents(self, session: Session): """ Raises: ConfigurationError """ self._logger.info('Enabling \'installer\' component') base_kit = KitApi().getKit(session, 'base') enabledComponents = ['installer'] # get list of components from 'base' kit components = [c for c in base_kit.getComponentList() if c.getName() in enabledComponents] installerNode = NodeApi().getInstallerNode(session) for component in components: SoftwareProfileApi().enableComponent( session, installerNode.getSoftwareProfile().getName(), base_kit.getName(), base_kit.getVersion(), base_kit.getIteration(), component.getName(), compVersion=component.getVersion(), )
def test_basic(self, node_state_change_object, get_kit_installer_function, MockClass1, get_os_object_factory_function, dbm): """ Transfer a single node """ name = 'compute-01' with dbm.session() as session: # xfer node 'compute-01' to 'compute2' software profile result = NodeApi().transferNodes(session, 'compute2', nodespec=name) # get node after xfer node = NodeApi().getNode(session, name) # validate new software profile assert node.getSoftwareProfile().getName() == 'compute2' # validate state (which is fudged above) assert node.getState() != 'Installed' # update status from 'Expired' to 'Installed' to allow xfer NodeApi().updateNodeStatus(session, name, state='Installed') # ensure event fired to indicate node state change node_state_change_object.assert_called() # xfer node back to 'compute' software profile NodeApi().transferNodes(session, 'compute', nodespec=name) NodeApi().updateNodeStatus(session, name, state='Installed') node = NodeApi().getNode(session, name) assert node.getSoftwareProfile().getName() == 'compute'
def test_getNodeById(self, get_software_profile_metadata_mock, get_os_boot_host_manager_mock): \ # pylint: disable=unused-argument from tortuga.node.nodeApi import NodeApi node_id = 1 with self.dbm.session() as session: node = NodeApi().getNodeById(session, node_id) assert node.getId() == node_id # this is a bit of a cheat since it compares host names only # but that should be sufficient here... assert node.getName().split('.', 1)[0] == \ socket.getfqdn().split('.', 1)[0] get_software_profile_metadata_mock.assert_called_with( session, node.getSoftwareProfile().getName())
def enableComponents(self): """ Raises: ConfigurationError """ self._logger.info('Enabling \'installer\' component') k = self.__getBaseKit() enabledComponents = ['installer'] components = [ c for c in k.getComponentList() if c.getName() in enabledComponents ] installerNode = NodeApi().getInstallerNode() for component in components: SoftwareProfileApi().enableComponent( installerNode.getSoftwareProfile().getName(), k.getName(), k.getVersion(), k.getIteration(), component.getName(), component.getVersion())