def process_kickstart(self, data): """Process the kickstart data.""" log.debug("Processing kickstart data...") self.set_root_password(data.rootpw.password, crypted=data.rootpw.isCrypted) self.set_root_account_locked(data.rootpw.lock) # make sure the root account is locked unless a password is set in kickstart if not data.rootpw.password: log.debug( "root specified in kickstart without password, locking account" ) self.set_root_account_locked(True) # if password was set in kickstart it can't be changed by default if data.rootpw.seen: self.set_can_change_root_password(False) self._rootpw_seen = True user_data_list = [] for user_ksdata in data.user.userList: user_data_list.append(self._ksdata_to_user_data(user_ksdata)) self.set_users(user_data_list) group_data_list = [] for group_ksdata in data.group.groupList: group_data = GroupData() group_data.name = group_ksdata.name if group_ksdata.gid is not None: group_data.gid = group_ksdata.gid group_data_list.append(group_data) self.set_groups(group_data_list) ssh_key_data_list = [] for ssh_key_ksdata in data.sshkey.sshUserList: ssh_key_data = SshKeyData() ssh_key_data.key = ssh_key_ksdata.key ssh_key_data.username = ssh_key_ksdata.username ssh_key_data_list.append(ssh_key_data) self.set_ssh_keys(ssh_key_data_list)
def Groups(self) -> List[Structure]: """List of groups, each describing a single group. :return: a list of group describing DBus Structures """ # internally we hold the data about groups as a list of structures, # which we need to turn into a list of dicts before returning it # over DBus group_dicts = [] for group_data in self.implementation.groups: group_dicts.append(GroupData.to_structure(group_data)) return group_dicts
def test_getter_setter(self): """Test getters and setters for the Group GID values.""" group_data = GroupData() group_data.name = "group" # everything should be unset by default assert group_data.gid == 0 assert group_data.gid_mode == ID_MODE_USE_DEFAULT assert group_data.get_gid() is None group_data.set_gid(789) # now everything is set assert group_data.gid == 789 assert group_data.gid_mode == ID_MODE_USE_VALUE assert group_data.get_gid() == 789 group_data.gid_mode = ID_MODE_USE_DEFAULT # mode should decide whether numbers are used, regardless of being stored assert group_data.gid_mode == ID_MODE_USE_DEFAULT assert group_data.gid == 789 assert group_data.get_gid() is None group_data.set_gid(None) # setting None resets everything assert group_data.gid == 0 assert group_data.gid_mode == ID_MODE_USE_DEFAULT assert group_data.get_gid() is None
def getter_setter_test(self): """Test getters and setters for the Group GID values.""" group_data = GroupData() group_data.name = "group" # everything should be unset by default self.assertEqual(group_data.gid, 0) self.assertEqual(group_data.gid_mode, ID_MODE_USE_DEFAULT) self.assertEqual(group_data.get_gid(), None) group_data.set_gid(789) # now everything is set self.assertEqual(group_data.gid, 789) self.assertEqual(group_data.gid_mode, ID_MODE_USE_VALUE) self.assertEqual(group_data.get_gid(), 789) group_data.gid_mode = ID_MODE_USE_DEFAULT # mode should decide whether numbers are used, regardless of being stored self.assertEqual(group_data.gid_mode, ID_MODE_USE_DEFAULT) self.assertEqual(group_data.gid, 789) self.assertEqual(group_data.get_gid(), None) group_data.set_gid(None) # setting None resets everything self.assertEqual(group_data.gid, 0) self.assertEqual(group_data.gid_mode, ID_MODE_USE_DEFAULT) self.assertEqual(group_data.get_gid(), None)
def Groups(self, groups: List[Structure]): """Set a list of groups, each corresponding to a single group. :param groups: a list of group describing DBus structures """ self.implementation.set_groups(GroupData.from_structure_list(groups))
def Groups(self) -> List[Structure]: """List of groups, each describing a single group. :return: a list of group describing DBus Structures """ return GroupData.to_structure_list(self.implementation.groups)