/// <summary>
        /// Takes machines that have the creation status of <see cref="CreationStatus.QUEUED_FOR_CREATION"/> and status of active and configures them and sets them to configured
        /// </summary>
        /// <param name="state"></param>
        private async void CreatedTimerCallback(object state)
        {
            if (_CreatedIsGoing)
            {
                return;
            }
            try
            {
                _CreatedIsGoing = true;
                VmDeploymentContext _context = GetContext();
                var PollTime = DateTimeOffset.UtcNow;
                var machines = await _context.Machines.Where(machine => machine.MachineCreationStatus == CreationStatus.QUEUED_FOR_CREATION).ToListAsync();

                foreach (Machine machine in machines)
                {
                    if (machine.MachineStatus?.MachineState == MachineStates.ACTIVE)
                    {
                        Console.WriteLine($"MachineControllerService.CreatedTimerCallback: Machine Booted after creation: { machine.MachineID}");
                        try
                        {
                            if (machine.MachineStatus?.MachineIp == null)
                            {
                                Console.WriteLine($"Error configuring machine: no ip");
                                continue;
                            }
                            await _machineConfigurator.ConfigureMachineWithFile(machine);//TODO: Return to using ssh based configuration
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine($"Error occurred configuring machine: {machine.HostName}, {machine.MachineID}");
                            Console.WriteLine($"Error: {e.Message}");
                            Console.WriteLine(e.StackTrace);
                            continue;
                        }
                        machine.MachineCreationStatus = CreationStatus.CONFIGURED;
                        _context.Machines.Update(machine);
                        await _context.SaveChangesAsync();
                    }
                }
            }
            finally
            {
                _CreatedIsGoing = false;
            }
        }
 public AuthController(IConfiguration configuration, VmDeploymentContext context)
 {
     _configuration = configuration;
     _context       = context;
 }
Beispiel #3
0
 public MachineController(VmDeploymentContext context, IOpenNebulaAccessor accessor, SshConfigBuilder sshConfigBuilder)
 {
     _context          = context;
     _accessor         = accessor;
     _sshConfigBuilder = sshConfigBuilder;
 }
Beispiel #4
0
 public CourseController(VmDeploymentContext context)
 {
     _context = context;
 }
 public GroupAssignmentController(VmDeploymentContext context)
 {
     _context = context;
 }
Beispiel #6
0
 public MachineCredentialController(VmDeploymentContext context, SshConfigBuilder configBuilder)
 {
     _context       = context;
     _configBuilder = configBuilder;
 }
 public SshConfigBuilder(VmDeploymentContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
Beispiel #8
0
 public EducatorController(VmDeploymentContext context)
 {
     _context = context;
 }
Beispiel #9
0
 public CreationController(VmDeploymentContext context)
 {
     _context = context;
 }