def __initialize_node(self, name, db_hardware_profile, db_software_profile): node = Node(name=name) node.softwareprofile = db_software_profile node.hardwareprofile = db_hardware_profile node.isIdle = False node.addHostSession = self.addHostSession return node
def primeDb(session: Session, settings: Dict[str, Any]): """ Prime database with initial data """ # Create node entry for installer node = Node(name=settings['fqdn']) node.state = state.NODE_STATE_INSTALLED node.lockedState = 'HardLocked' node.lastUpdate = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) node.bootFrom = 1 node.isIdle = False # Create Installer Software Profile node.softwareprofile = SoftwareProfile( name=settings['installer_software_profile'], description='Installer software profile', type='installer', minNodes=1, maxNodes=1, lockedState='HardLocked', ) node.softwareprofile.os = OperatingSystem( name=settings['osInfo'].getName(), version=settings['osInfo'].getVersion(), arch=settings['osInfo'].getArch()) node.softwareprofile.os.family = OperatingSystemFamily( name=settings['osInfo'].getOsFamilyInfo().getName(), version=settings['osInfo'].getOsFamilyInfo().getVersion(), arch=settings['osInfo'].getOsFamilyInfo().getArch()) # Create Installer Hardware Profile node.hardwareprofile = HardwareProfile( name=settings['installer_hardware_profile']) node.hardwareprofile.description = 'Installer hardware profile' node.hardwareprofile.nameFormat = 'installer' node.hardwareprofile.installType = 'package' node.hardwareprofile.setLocation = 'local' node.hardwareprofile.mappedsoftwareprofiles.append(node.softwareprofile) session.add(node)
def start(self, addNodesRequest: dict, dbSession: Session, dbHardwareProfile: HardwareProfile, dbSoftwareProfile: Optional[SoftwareProfile] = None): """ Create nodes """ # # Load resource adapter settings # config = self.getResourceAdapterConfig( sectionName=addNodesRequest.get( 'resource_adapter_configuration', 'default') ) nodes = [] for _ in range(addNodesRequest['count']): random_host_name_suffix = get_random_host_name_suffix() node = Node(name='compute-{}'.format(random_host_name_suffix)) node.softwareprofile = dbSoftwareProfile node.hardwareprofile = dbHardwareProfile node.isIdle = False node.state = self.STATE_TRANSITIONS[0] # create dummy nic nic = Nic(boot=True, ip=generate_fake_ip()) node.nics.append(nic) self._simulate_state_changes( node, config.get('state', self.settings['state'].default) ) nodes.append(node) return nodes