Skip to content

Commit

Permalink
Mesh meta data operators (#3072)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-WWU-IT authored Jul 14, 2022
1 parent 3bc0b4c commit de389ee
Show file tree
Hide file tree
Showing 53 changed files with 1,167 additions and 836 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/mesh-metadata-ops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Mesh meta data operators

To better support sites that run multiple instances, the meta data have been extended to include a new hierarchy layer called 'operators'. This PR brings all necessary changes in the Mentix and site accounts services.

https://github.com/cs3org/reva/pull/3072
27 changes: 0 additions & 27 deletions docs/content/en/docs/config/http/services/mentix/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,3 @@ Mentix exposes its data via an HTTP endpoint using the `webapi` exporter. Data c

- **metrics**
The [Metrics](metrics) exporter exposes various site-specific metrics through Prometheus.

## Site Accounts service
Mentix uses the Reva site accounts service to query information about site accounts. The following settings must be configured properly:

{{% dir name="url" type="string" default="" %}}
The URL of the site accounts service.
{{< highlight toml >}}
[http.services.mentix.accounts]
url = "https://example.com/accounts"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="user" type="string" default="" %}}
The user name to use for basic HTTP authentication.
{{< highlight toml >}}
[http.services.mentix.accounts]
user = "hans"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="password" type="string" default="" %}}
The user password to use for basic HTTP authentication.
{{< highlight toml >}}
[http.services.mentix.accounts]
password = "secret"
{{< /highlight >}}
{{% /dir %}}
4 changes: 2 additions & 2 deletions docs/content/en/docs/config/http/services/siteacc/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ driver = "file"

### Storage settings - File drivers
{{% dir name="sites_file" type="string" default="" %}}
The sites file location.
The operators file location.
{{< highlight toml >}}
[http.services.siteacc.storage.file]
sites_file = "/var/reva/sites.json"
operators_file = "/var/reva/operators.json"
{{< /highlight >}}
{{% /dir %}}

Expand Down
7 changes: 0 additions & 7 deletions examples/mentix/mentix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ enabled_connectors = ["gocdb"]
# Enable the Metrics exporter
[http.services.mentix.exporters.metrics]

# Set up the accounts service used to query information about accounts associated with registered sites
[http.services.mentix.accounts]
# Depending on where the service is running, localhost may also be used here
url = "https://sciencemesh.example.com/iop/accounts"
user = "username"
password = "userpass"

# Configure the Prometheus Service Discovery:
[http.services.mentix.exporters.promsd]
# The following path must be made available to Prometheus.
Expand Down
2 changes: 1 addition & 1 deletion examples/siteacc/siteacc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apikey = "verysecret"
[http.services.siteacc.storage]
driver = "file"
[http.services.siteacc.storage.file]
sites_file = "/var/revad/sites.json"
operators_file = "/var/revad/operators.json"
accounts_file = "/var/revad/accounts.json"

# Email related settings
Expand Down
4 changes: 2 additions & 2 deletions internal/http/services/siteacc/siteacc.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error)
return nil, err
}

// Create the site accounts instance
// Create the sites accounts instance
siteacc, err := siteacc.New(conf, log)
if err != nil {
return nil, errors.Wrap(err, "error creating the site accounts service")
return nil, errors.Wrap(err, "error creating the sites accounts service")
}

// Create the service
Expand Down
100 changes: 0 additions & 100 deletions pkg/mentix/accservice/accservice.go

This file was deleted.

6 changes: 0 additions & 6 deletions pkg/mentix/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ type Configuration struct {
} `mapstructure:"metrics"`
} `mapstructure:"exporters"`

AccountsService struct {
URL string `mapstructure:"url"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
} `mapstructure:"accounts"`

// Internal settings
EnabledConnectors []string `mapstructure:"-"`
EnabledImporters []string `mapstructure:"-"`
Expand Down
57 changes: 44 additions & 13 deletions pkg/mentix/connectors/gocdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,25 @@ func (connector *GOCDBConnector) RetrieveMeshData() (*meshdata.MeshData, error)
return nil, fmt.Errorf("could not query service types: %v", err)
}

if err := connector.querySites(meshData); err != nil {
return nil, fmt.Errorf("could not query sites: %v", err)
if err := connector.queryNGIs(meshData); err != nil {
return nil, fmt.Errorf("could not query operators: %v", err)
}

for _, site := range meshData.Sites {
// Get services associated with the current site
if err := connector.queryServices(meshData, site); err != nil {
return nil, fmt.Errorf("could not query services of site '%v': %v", site.Name, err)
for _, op := range meshData.Operators {
if err := connector.querySites(meshData, op); err != nil {
return nil, fmt.Errorf("could not query sites of operator '%v': %v", op.Name, err)
}

// Get downtimes scheduled for the current site
if err := connector.queryDowntimes(meshData, site); err != nil {
return nil, fmt.Errorf("could not query downtimes of site '%v': %v", site.Name, err)
for _, site := range op.Sites {
// Get services associated with the current site
if err := connector.queryServices(meshData, site); err != nil {
return nil, fmt.Errorf("could not query services of site '%v': %v", site.Name, err)
}

// Get downtimes scheduled for the current site
if err := connector.queryDowntimes(meshData, site); err != nil {
return nil, fmt.Errorf("could not query downtimes of site '%v': %v", site.Name, err)
}
}
}

Expand Down Expand Up @@ -124,14 +130,39 @@ func (connector *GOCDBConnector) queryServiceTypes(meshData *meshdata.MeshData)
return nil
}

func (connector *GOCDBConnector) querySites(meshData *meshdata.MeshData) error {
func (connector *GOCDBConnector) queryNGIs(meshData *meshdata.MeshData) error {
var ngis gocdb.NGIs
if err := connector.query(&ngis, "get_ngi", false, true, network.URLParams{}); err != nil {
return err
}

// Copy retrieved data into the mesh data
meshData.Operators = nil
for _, ngi := range ngis.NGIs {
operator := &meshdata.Operator{
ID: ngi.Name,
Name: ngi.Name,
Homepage: "",
Email: ngi.Email,
HelpdeskEmail: ngi.HelpdeskEmail,
SecurityEmail: ngi.SecurityEmail,
Sites: nil,
Properties: map[string]string{},
}
meshData.Operators = append(meshData.Operators, operator)
}

return nil
}

func (connector *GOCDBConnector) querySites(meshData *meshdata.MeshData, op *meshdata.Operator) error {
var sites gocdb.Sites
if err := connector.query(&sites, "get_site", false, true, network.URLParams{}); err != nil {
if err := connector.query(&sites, "get_site", false, true, network.URLParams{"roc": op.ID}); err != nil {
return err
}

// Copy retrieved data into the mesh data
meshData.Sites = nil
op.Sites = nil
for _, site := range sites.Sites {
properties := connector.extensionsToMap(&site.Extensions)

Expand All @@ -158,7 +189,7 @@ func (connector *GOCDBConnector) querySites(meshData *meshdata.MeshData) error {
Properties: properties,
Downtimes: meshdata.Downtimes{},
}
meshData.Sites = append(meshData.Sites, meshsite)
op.Sites = append(op.Sites, meshsite)
}

return nil
Expand Down
13 changes: 13 additions & 0 deletions pkg/mentix/connectors/gocdb/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ type ServiceTypes struct {
Types []*ServiceType `xml:"SERVICE_TYPE"`
}

// NGI represents an NGI in GOCDB.
type NGI struct {
Name string `xml:"NAME"`
Email string `xml:"EMAIL"`
HelpdeskEmail string `xml:"HELPDESK_EMAIL"`
SecurityEmail string `xml:"SECURITY_EMAIL"`
}

// NGIs is a list of NGI objects.
type NGIs struct {
NGIs []*NGI `xml:"NGI"`
}

// Site represents a site in GOCDB.
type Site struct {
ShortName string `xml:"SHORT_NAME"`
Expand Down
Loading

0 comments on commit de389ee

Please sign in to comment.