Skip to content

Commit

Permalink
Setup files merged
Browse files Browse the repository at this point in the history
  • Loading branch information
vvoluom committed Apr 9, 2020
1 parent 6d78c92 commit 372ad0c
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 226 deletions.
3 changes: 0 additions & 3 deletions config/example_node_exporter_nodes.ini

This file was deleted.

11 changes: 0 additions & 11 deletions config/example_prometheus_config_main.ini

This file was deleted.

1 change: 1 addition & 0 deletions config/example_user_config_main.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[api_server]
port = 3000
metrics_url = http://127.0.0.1:9100/metrics
13 changes: 12 additions & 1 deletion config/example_user_config_nodes.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
[node_0]
node_name = Oasis_Local
ws_url = unix:/serverdir/node/internal.sock
is_path = unix:/serverdir/node/internal.sock
p_url = http://127.0.0.1:3000/

[node_1]
node_name = Oasis_Local_1
is_path = unix:/serverdir/node/internal.sock
p_url = http://127.0.0.1:3000/

[node_2]
node_name = Oasis_Local_Failure
is_path = unix:/serverdir/nodes/internal.sock
p_url = http://127.0.0.1:3001/
19 changes: 1 addition & 18 deletions run_setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from configparser import ConfigParser

from setup import setup_user_config_main, setup_user_config_nodes, \
setup_prometheus_config_main, setup_exporter_config_main, \
setup_sentry_config_main

def run() -> None:
Expand All @@ -11,13 +10,7 @@ def run() -> None:

cp_nodes = ConfigParser()
cp_nodes.read('config/user_config_nodes.ini')

cp_prometheus = ConfigParser()
cp_prometheus.read('config/prometheus_config_main.ini')

cp_exporter = ConfigParser()
cp_exporter.read('config/node_exporter_nodes.ini')


cp_sentry = ConfigParser()
cp_sentry.read('config/user_config_sentry.ini')

Expand All @@ -34,16 +27,6 @@ def run() -> None:
cp_nodes.write(f)
print('Saved config/user_config_nodes.ini\n')

setup_prometheus_config_main.setup_nodes(cp_prometheus)
with open('config/prometheus_config_main.ini', 'w') as f:
cp_prometheus.write(f)
print('Saved config/prometheus_config_main.ini\n')

setup_exporter_config_main.setup_nodes(cp_exporter)
with open('config/node_exporter_nodes.ini', 'w') as f:
cp_exporter.write(f)
print('Saved config/node_exporter_nodes.ini\n')

setup_sentry_config_main.setup_nodes(cp_sentry)
with open('config/user_config_sentry.ini', 'w') as f:
cp_sentry.write(f)
Expand Down
70 changes: 0 additions & 70 deletions setup/setup_exporter_config_main.py

This file was deleted.

68 changes: 0 additions & 68 deletions setup/setup_prometheus_config_main.py

This file was deleted.

17 changes: 16 additions & 1 deletion setup/setup_user_config_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def reset_section(section: str, cp: ConfigParser) -> None:
def setup_api_server(cp: ConfigParser) -> None:
print('==== API Server')
print('The API Server makes it possible to query Oasis Nodes and '
'retrieve certain data about the node and the blockchain')
'retrieve certain data about the node and the blockchain. '
'The Node Exporter will also be setup during this process to able to '
'query system data.')

already_set_up = is_already_set_up(cp, 'api_server')
if already_set_up and \
Expand All @@ -35,6 +37,7 @@ def setup_api_server(cp: ConfigParser) -> None:

reset_section('api_server', cp)
cp['api_server']['port'] = ''
cp['api_server']['metrics_url'] = ''

if not already_set_up and \
not yn_prompt('Do you wish to set up the API Server? (Y/n)\n'):
Expand All @@ -46,8 +49,20 @@ def setup_api_server(cp: ConfigParser) -> None:
port = input('Please insert the port you would like the API Server to use: '
'(default: 8080)\n')
port = '8080' if port == '' else port

print('==== Node Exporter')
print('To retrieve data from the Node Exporter, '
'the API needs to know where to find the '
'Node Exporter endpoint! ')

# Get node's local host url
metrics_url = input('Node Exporter\'s localhost url'
' is needed which was exposed during the Node Exporter setup'
' (typically 127.0.0.1:9100/metrics):\n')


cp['api_server']['port'] = port
cp['api_server']['metrics_url'] = metrics_url


def setup_all(cp: ConfigParser) -> None:
Expand Down
24 changes: 18 additions & 6 deletions setup/setup_user_config_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


def get_node(nodes_so_far: List[NodeConfig]) -> Optional[NodeConfig]:

# Get node's name
node_names_so_far = [n.node_name for n in nodes_so_far]
while True:
Expand All @@ -15,12 +16,21 @@ def get_node(nodes_so_far: List[NodeConfig]) -> Optional[NodeConfig]:
else:
break

# Get node's internal socket
is_path = input('Node\'s internal socket file path which was setup during the Oasis node '
' installation (typically unix:/serverdir/nodes/internal.sock):\n')
# Get node's internal socket path way
is_path = input('Node\'s internal socket file path which was setup during '
'the Oasis node installation (typically '
'unix:/serverdir/nodes/internal.sock):\n')

print('==== Prometheus')
print('To retrieve data from Prometheus, the API needs'
'to know where to find the Prometheus endpoints! ')

# Get Prometheus's URL of the Node
p_url = input('Prometheus Node\'s localhost url '
'(typically 127.0.0.1:3000):\n')

# Return node
return NodeConfig(node_name, is_path)
return NodeConfig(node_name, is_path, p_url)


def setup_nodes(cp: ConfigParser) -> None:
Expand All @@ -30,7 +40,8 @@ def setup_nodes(cp: ConfigParser) -> None:
'the nodes! The list of nodes the API will connect to will now be '
'set up. This includes validators, sentries, and any full nodes that '
'can be used as a data source to retrieve data from the network\'s '
'perspective. Node names must be unique!')
'perspective. Node names must be unique! The list of API Nodes will '
'also include their Prometheus Endpoints.')

# Check if list already set up
already_set_up = len(cp.sections()) > 0
Expand Down Expand Up @@ -64,4 +75,5 @@ def setup_nodes(cp: ConfigParser) -> None:
section = 'node_' + str(i)
cp.add_section(section)
cp[section]['node_name'] = node.node_name
cp[section]['ws_url'] = node.ws_url
cp[section]['is_path'] = node.is_path
cp[section]['p_url'] = node.p_url
5 changes: 3 additions & 2 deletions setup/utils/config_parsers/node.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class NodeConfig:

def __init__(self, node_name: str, ws_url: str) -> None:
def __init__(self, node_name: str, is_path: str, p_url : str) -> None:
self.node_name = node_name
self.ws_url = ws_url
self.is_path = is_path
self.p_url = p_url
46 changes: 0 additions & 46 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ import (
var (
confMain ini.Config
confNodes ini.Config
confPrometheus ini.Config
confExporter ini.Config
confSentry ini.Config
mainConfigFile = "config/user_config_main.ini"
nodesFile = "config/user_config_nodes.ini"
prometheusFile = "config/prometheus_config_main.ini"
exporterFile = "config/node_exporter_nodes.ini"
sentryFile = "config/user_config_sentry.ini"
)

Expand All @@ -35,16 +31,6 @@ func SetNodesFile(newFile string) {
nodesFile = newFile
}

// SetPrometheusFile containing prometheus configuration
func SetPrometheusFile(newFile string) {
prometheusFile = newFile
}

// SetExporterFile containing the Node Exporter configuration
func SetExporterFile(newFile string) {
exporterFile = newFile
}

// GetSentryData returns Sentry configuration
func GetSentryData() map[string]map[string]string {
return confSentry
Expand All @@ -60,16 +46,6 @@ func GetNodes() map[string]map[string]string {
return confNodes
}

// GetPrometheusFile returns Prometheus configuration
func GetPrometheusFile() map[string]map[string]string {
return confPrometheus
}

// GetExporterFile returns Node_Extrasctor configuration
func GetExporterFile() map[string]map[string]string {
return confExporter
}

// LoadMainConfiguration loads main configuration file from config folder
func LoadMainConfiguration() (map[string]map[string]string, error) {

Expand All @@ -92,28 +68,6 @@ func LoadNodesConfiguration() (map[string]map[string]string, error) {
return confNodes, nil
}

// LoadPrometheusConfiguration loads prometheus configuration
func LoadPrometheusConfiguration() (map[string]map[string]string, error) {

// Decode and read file containing prometheus information
if err := ini.DecodeFile(prometheusFile, &confPrometheus); err != nil {
lgr.Error.Println(err)
return nil, err
}
return confPrometheus, nil
}

// LoadExporterConfiguration loads Node Exporter configuration
func LoadExporterConfiguration() (map[string]map[string]string, error) {

// Decode and read the file containing the Node Exporter information
if err := ini.DecodeFile(exporterFile, &confExporter); err != nil {
lgr.Error.Println(err)
return nil, err
}
return confExporter, nil
}

// LoadSentryConfiguration loads sentry configuration details
func LoadSentryConfiguration() (map[string]map[string]string, error) {

Expand Down

0 comments on commit 372ad0c

Please sign in to comment.