Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers()
            .AddFluentValidation();

            services.AddAutoMapper(typeof(DatacenterMapperProfile).Assembly);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Kubernox.Service", Version = "v1"
                });
            });

            services.AddSharedInfrastructure();
            services.AddPersistenceInfrastructure(Configuration);
            services.AddSignalR();
            services.AddHealthChecks();

            services.AddSerilogUi(options =>
            {
                options.UseNpgSql(Configuration.GetConnectionString("Default"), "logs");
            });

            ConfigureCors(services);
            AddBusinessLayer(services);

            services.AddSingleton <ILookupClient>(c =>
            {
                var endpoint = new IPEndPoint(IPAddress.Parse("8.8.8.8"), 53);
                return(new LookupClient(endpoint));
            });

            ConfigureClient.Initialise(Configuration["Proxmox:Uri"], Configuration["Proxmox:Token"]);
        }
 public DatacenterSyncBusiness(IConfiguration configuration, ILogger <DatacenterSyncBusiness> logger, IDatacenterRepository datacenterRepository)
 {
     ConfigureClient.Initialise(configuration["Proxmox:Uri"], configuration["Proxmox:Token"]);
     this.configuration        = configuration;
     this.logger               = logger;
     this.datacenterRepository = datacenterRepository;
 }
        public SerializedPayload NewConfigureClient(int prefetchCount)
        {
            var payload = new ConfigureClient
            {
                Id            = Guid.NewGuid(),
                PrefetchCount = prefetchCount
            };

            return(_serializer.Serialize(payload));
        }
Ejemplo n.º 4
0
 private void InitializeConfigurationProxy()
 {
     try
     {
         _configurationProxy = new ConfigureClient();
     }
     catch (Exception)
     {
         _configurationProxy.Abort();
     }
 }
        public void Serialization_ConfigureClient_MatchResults()
        {
            var configureClient = new ConfigureClient {
                Id = Guid.NewGuid(), PrefetchCount = 10
            };

            var b = _serializer.Serialize(configureClient);

            var result = _deserializer.ToConfigureClient(b.DataWithoutSize);

            Assert.Equal(configureClient.Id, result.Id);
            Assert.Equal(configureClient.PrefetchCount, result.PrefetchCount);
        }
Ejemplo n.º 6
0
        private void OnConfigureClient(Guid clientId, ConfigureClient configureClient)
        {
            if (_clientStore.TryGet(clientId, out var client))
            {
                client.ConfigureConcurrency(configureClient.PrefetchCount);

                SendReceivedPayloadOk(clientId, configureClient.Id);
            }
            else
            {
                SendReceivePayloadError(clientId, configureClient.Id, "Client not found");
            }
        }
Ejemplo n.º 7
0
 public ClusterBusiness(IClusterRepository clusterRepository, IDatacenterRepository datacenterRepository,
                        ISshKeyRepository sshKeyRepository, IClusterNodeRepository clusterNodeRepository,
                        IQueueService queueService, ITemplateRepository templateRepository,
                        IConfiguration configuration, ITraefikRedisStore traefikCache, IHubContext <AppHub, IAppHub> hubContext)
 {
     this.clusterRepository     = clusterRepository;
     this.datacenterRepository  = datacenterRepository;
     this.sshKeyRepository      = sshKeyRepository;
     this.clusterNodeRepository = clusterNodeRepository;
     this.queueService          = queueService;
     this.templateRepository    = templateRepository;
     this.configuration         = configuration;
     this.traefikCache          = traefikCache;
     this.hubContext            = hubContext;
     ConfigureClient.Initialise(configuration["Proxmox:Uri"], configuration["Proxmox:Token"]);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Reads (loads) the configuration of the system from the configuration service.
        /// </summary>
        public void LoadConfiguration()
        {
            _log.Trace(m => m("LoadConfiguration called for {0}.", (_ConfigurationServiceHostAddress == null) ? "null" : _ConfigurationServiceHostAddress.ToString()));

            if (_ConfigurationServiceHostAddress != null)
            {
                ConfigureClient cfgIfc = null;
                cfgIfc = new ConfigureClient();
                // Connect to the discovered service endpoint
                cfgIfc.Endpoint.Address = _ConfigurationServiceHostAddress;


                _graphic = cfgIfc.GetGraphicConfiguration();
                _log.Trace(m => m("All graphic details: {0}", _graphic.ToString()));

                // read available zones (via graphic configuration)
                // Root -> Graphic -> Building -> Floors -> Zone(s)
                _zones.Clear();
                _functions.Clear();
                foreach (Floor floor in _graphic.Building.Floors)
                {
                    _log.Trace(m => m("Read FLOOR with id={0}.", floor.Id));
                    foreach (ZoneGraphic zone in floor.Zones)
                    {
                        _log.Trace(m => m("Zone found with id {0} with name {1}.", zone.Id.ToString(), zone.Name));
                        _zones.Add(zone);

                        // Read the functions associated with this zone
                        Function[] functions = cfgIfc.GetFunctions(zone.Id);
                        _functions.AddRange(functions);
                    }
                }
                _log.Trace(m => m("Totally {0} zones found!", _zones.Count));
                _log.Trace(m => m("Totally {0} funtions found!", _functions.Count));


                // read available sources (via graphic configuration)
                // Root -> Graphic -> Source(s)
                _sources.Clear();
                foreach (SourceGraphic source in _graphic.Sources)
                {
                    _log.Trace(m => m("SOURCE found with id {0}, with the name {1}.", source.Id.ToString(), source.Name));
                    _sources.Add(source);
                }
                _log.Trace(m => m("Totally {0} sources found!", _sources.Count));
            }
        }
        public SerializedPayload Serialize(ConfigureClient configureClient)
        {
            var binaryWriter = ObjectPool.Shared.Rent <BinaryProtocolWriter>();

            try
            {
                return(binaryWriter
                       .WriteType(PayloadType.Configure)
                       .WriteId(configureClient.Id)
                       .WriteInt(configureClient.PrefetchCount)
                       .ToSerializedPayload());
            }
            finally
            {
                ObjectPool.Shared.Return(binaryWriter);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Create client for configuration service. Either use discovered service or configuration read from
        /// configuration file.
        /// </summary>
        /// <returns>Client to configure service.</returns>
        private ConfigureClient CreateConfigureClient()
        {
            ConfigureClient cfgIfc = null;

            if (ServiceProxy.ServiceDiscovery.isServiceDiscovered(serviceName))
            {
                cfgIfc = new ConfigureClient();
                // Connect to the discovered service endpoint
                EndpointAddress addr = ServiceProxy.ServiceDiscovery.EndpointAddress(serviceName, ServiceProxy.ServiceDiscovery.SelectedServer);
                cfgIfc.Endpoint.Address = addr;
                _log.Trace(m => m("Invoking discovered Configuration service at {0}", addr));
            }
            else
            {
                cfgIfc = new ConfigureClient("WSHttpBinding_IConfigure", ServiceProxy.buildEndpointAddress("WSHttpBinding_IConfigure"));
                _log.Trace(m => m("Invoking configured Configuration service at {0}", ServiceProxy.buildEndpointAddress("WSHttpBinding_IConfigure")));
            }
            _endPointAddress = cfgIfc.Endpoint.Address;
            return(cfgIfc);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Reads (loads) the functions (part of the system configuration) from the configuration service.
        /// </summary>
        public List <Function> LoadFunctions()
        {
            _log.Trace(m => m("LoadFunctions called for {0}.", (_ConfigurationServiceHostAddress == null) ? "null" : _ConfigurationServiceHostAddress.ToString()));

            if (_ConfigurationServiceHostAddress != null)
            {
                ConfigureClient cfgIfc = null;
                cfgIfc = new ConfigureClient();
                // Connect to the discovered service endpoint
                cfgIfc.Endpoint.Address = _ConfigurationServiceHostAddress;

                _functions.Clear();
                foreach (ZoneGraphic zone in _zones)
                {
                    _log.Trace(m => m("read functions for Zone id {0} with name {1}.", zone.Id.ToString(), zone.Name));

                    // ToDo: Not implemented yet! Implement GetFunctions(zone.Id) on server side!
                    _functions.AddRange(cfgIfc.GetFunctions(zone.Id));
                }
                _log.Trace(m => m("Totally {0} functions found! {1}", _functions.Count, _functions.ToString <Function>(" / ")));
            }
            return(_functions);
        }
Ejemplo n.º 12
0
 public virtual void HandleConfigure(ConfigureClient e)
 {
     m_messages = e.Messages;
     m_server   = e.Server;
     Self.Active();
 }
Ejemplo n.º 13
0
 public void HandleConfigure(ConfigureClient e)
 {
     Receiver.HandleConfigure(e);
     MachineHandledLog(nameof(HandleConfigure));
 }
Ejemplo n.º 14
0
 public void Configure(ConfigureClient e)
 {
     RuntimeHost.SendEvent(Id, e);
 }