Ejemplo n.º 1
0
        public async Task <IActionResult> Launch([FromBody] LaunchInstanceConfiguration instanceConfiguration)
        {
            var systemVolume = await volumeDataSource.GetVolume(instanceConfiguration.SystemVolumeId);

            if (systemVolume == null)
            {
                return(BadRequest($"Cannot find a system volume {instanceConfiguration.SystemVolumeId}"));
            }

            foreach (var volumeId in instanceConfiguration.DataVolumeIds)
            {
                var dataVolume = await volumeDataSource.GetVolume(volumeId);

                if (dataVolume == null)
                {
                    return(BadRequest($"Cannot find a data volume {volumeId}"));
                }
            }

            var resp = await instanceDataSource.LaunchAsync(instanceConfiguration);

            return(Ok(resp));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Launch a new instance by the provided confiduration
        /// </summary>
        /// <param name="configuration">Configurations</param>
        /// <returns></returns>
        public async Task <InstanceGrpc> LaunchAsync(LaunchInstanceConfiguration configuration)
        {
            return(await grpcCallerService.CallService(urls.Volumes, async channel =>
            {
                var client = new Instances.API.Instances.InstancesClient(channel);
                //new Instances.InstanceClient()

                logger.LogDebug("grpc client created, request = {@id}", "");

                LaunchInstanceRequest launchInstanceRequest = new LaunchInstanceRequest()
                {
                    Name = configuration.Name,
                    InstanceType = configuration.InstanceType,
                    SystemVolume = configuration.SystemVolumeId
                };
                launchInstanceRequest.DataVolumes.AddRange(configuration.DataVolumeIds);

                var response = await client.LaunchAsync(launchInstanceRequest);

                logger.LogDebug("grpc response {@response}", response);

                return response;
            }));
        }