Skip to content

Commit

Permalink
fix(nms): Rename master portal to host portal
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Lee <andreilee@fb.com>
  • Loading branch information
andreilee committed Mar 25, 2022
1 parent ba004c6 commit 33379d8
Show file tree
Hide file tree
Showing 15 changed files with 735 additions and 978 deletions.
16 changes: 8 additions & 8 deletions nms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,38 +202,38 @@ This re-generates various files, including `MagmaAPIBindings.js` for NMS.
### Multitenancy and Organizations

Multitenancy is supported in the Magma NMS. Each tenant is called an "organization".
Each organization owns a subset of the networks provisioned on Orchestrator, and the special `master` organization administrates organizations in the system.
Each organization owns a subset of the networks provisioned on Orchestrator, and the special `host` organization administrates organizations in the system.

Users in organizations log into the NMS using a subdomain that matches their organization name.
For example, users of a *NewOrg* organization in the NMS would access the NMS using http://<NEWORG>.localhost:8081/nms

Note that any NMS user can only access the organization it was created under.

### First-time Setup
When you deploy the NMS for the first time, you'll need to create a user that has access to the master organization.
When you deploy the NMS for the first time, you'll need to create a user that has access to the host organization.

Run the following command from `magma/nms/packages/magmalte` and make sure to substitute `ADMIN_USER_EMAIL` and `ADMIN_USER_PASSWORD` with your desired email and password.
```
docker-compose exec magmalte yarn setAdminPassword master ADMIN_USER_EMAIL ADMIN_USER_PASSWORD
docker-compose exec magmalte yarn setAdminPassword host ADMIN_USER_EMAIL ADMIN_USER_PASSWORD
```

Access the `master` (http://master.localhost:8081/master) portal to create your first organization.
Access the `host` (http://host.localhost:8081/host) portal to create your first organization.
Create a new super user for that organization, and then you can login as that user for your new organization.

For example, if you created an organization called `magma-test`, you can access the NMS at http://magma-test.localhost:8081/nms

### First-time Setup (Fast)

Run the following from `magma/nms/packages/magmalte` to create two users, one for `master` organization, and another for `magma-test`.
Run the following from `magma/nms/packages/magmalte` to create two users, one for `host` organization, and another for `magma-test`.
The username and password for both will be `admin@magma.test` and `password1234`
```
./scripts/dev_setup.sh
```

### Master Portal
The master portal allows management of organizations.
### Host Portal
The host portal allows management of organizations.

http://master.localhost:8081/master
http://host.localhost:8081/host

### Admin Portal
The admin portal allows management for users of an organization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const mockAlertSt: Array<prom_firing_alert> = [
alertname: 'TestAlert1',
instance: '192.168.0.124:2112',
job: 'myapp',
monitor: 'master',
monitor: 'host',
networkID: 'test',
severity: 'critical',
},
Expand All @@ -73,7 +73,7 @@ const mockAlertSt: Array<prom_firing_alert> = [
alertname: 'TestAlert2',
instance: '192.168.0.124:2112',
job: 'myapp',
monitor: 'master',
monitor: 'host',
networkID: 'test',
severity: 'major',
},
Expand All @@ -95,7 +95,7 @@ const mockAlertSt: Array<prom_firing_alert> = [
alertname: 'TestAlert3',
instance: '192.168.0.124:2112',
job: 'myapp',
monitor: 'master',
monitor: 'host',
networkID: 'test',
severity: 'minor',
},
Expand All @@ -117,7 +117,7 @@ const mockAlertSt: Array<prom_firing_alert> = [
alertname: 'TestAlert4',
instance: '192.168.0.124:2112',
job: 'myapp',
monitor: 'master',
monitor: 'host',
networkID: 'test',
severity: 'normal',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import AppSideBar from '@fbcnms/ui/components/layout/AppSideBar';
import ApplicationMain from '../../components/ApplicationMain';
import AssignmentIcon from '@material-ui/icons/Assignment';
import CloudMetrics from '../../views/metrics/CloudMetrics';
import Features from '@fbcnms/ui/master/Features';
import Features from '@fbcnms/ui/host/Features';
import FlagIcon from '@material-ui/icons/Flag';
import NavListItem from '@fbcnms/ui/components/NavListItem';
import OrganizationEdit from '@fbcnms/ui/master/OrganizationEdit';
import Organizations from '@fbcnms/ui/master/Organizations';
import OrganizationEdit from '@fbcnms/ui/host/OrganizationEdit';
import Organizations from '@fbcnms/ui/host/Organizations';
import Paper from '@material-ui/core/Paper';
import PeopleIcon from '@material-ui/icons/People';
import React, {useContext} from 'react';
Expand Down Expand Up @@ -77,7 +77,7 @@ function NavItems() {
);
}

function Master() {
function Host() {
const classes = useStyles();
const {user, ssoEnabled} = useContext(AppContext);
const relativeUrl = useRelativeUrl();
Expand Down Expand Up @@ -129,10 +129,10 @@ const Index = () => {
return (
<ApplicationMain>
<AppContextProvider>
<Master />
<Host />
</AppContextProvider>
</ApplicationMain>
);
};

export default () => <Route path="/master" component={Index} />;
export default () => <Route path="/host" component={Index} />;
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ afterEach(() => {

describe('react router tests', () => {
test('/alerts renders the no alerts icon', () => {
const {getByTestId} = render(
const {queryByText} = render(
<Wrapper route={'/alarms'}>
<AlarmsWrapper />
</Wrapper>,
);

// assert that the 'no alerts' icon is visible
expect(getByTestId('no-alerts-icon')).toBeInTheDocument();
expect(queryByText('Severity')).toBeNull();
});
});

Expand All @@ -81,14 +81,14 @@ describe('Firing Alerts', () => {
],
});

const {getByTestId, getByText} = render(
const {getByText} = render(
<Wrapper route={'/alerts'}>
<AlarmsWrapper />
</Wrapper>,
);

// assert that the top level firing alerts header is visible
expect(getByTestId('firing-alerts')).toBeInTheDocument();
expect(getByText('Severity')).toBeInTheDocument();
expect(getByText('<<TEST ALERT>>')).toBeInTheDocument();
// TODO(andreilee): This has been removed
// expect(getByText('<<TEST DESCRIPTION>>')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import '@fbcnms/babel-register/polyfill';

import Index from './components/master/Index';
import Index from './components/host/Index';
import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter} from 'react-router-dom';
Expand Down
2 changes: 1 addition & 1 deletion nms/packages/magmalte/app/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import ReactDOM from 'react-dom';
import nullthrows from '@fbcnms/util/nullthrows';
import {AppContextProvider} from '@fbcnms/ui/context/AppContext';
import {BrowserRouter} from 'react-router-dom';
import {useHistory} from 'react-router';
import {useHistory} from 'react-router-dom';

function LoginWrapper() {
const history = useHistory();
Expand Down
2 changes: 1 addition & 1 deletion nms/packages/magmalte/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const resolveApp = (relativePath: string) =>
module.exports = {
appIndexJs: resolveApp('app/main.js'),
loginJs: resolveApp('app/login.js'),
masterJs: resolveApp('app/master.js'),
hostJs: resolveApp('app/host.js'),
appSrc: resolveApp('app'),
distPath: resolveApp('static/dist'),
packagesDir: resolveApp('../../packages'),
Expand Down
2 changes: 1 addition & 1 deletion nms/packages/magmalte/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
entry: {
main: entry([paths.appIndexJs]),
login: entry([paths.loginJs]),
master: entry([paths.masterJs]),
host: entry([paths.hostJs]),
},
externals: [
{
Expand Down
2 changes: 1 addition & 1 deletion nms/packages/magmalte/config/webpack.production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
entry: {
main: [paths.appIndexJs],
login: [paths.loginJs],
master: [paths.masterJs],
host: [paths.hostJs],
},
externals: [
{
Expand Down
20 changes: 10 additions & 10 deletions nms/packages/magmalte/mock/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@
}
},
"subscribers": {
"subscribers":
"subscribers":
{
"IMSI001010002220018": {
"name": "IMSI001010002220018",
Expand Down Expand Up @@ -1924,14 +1924,14 @@
"action": "PERMIT",
"match":{
"direction":"UPLINK",
"ip_proto": "IPPROTO_IP"
"ip_proto": "IPPROTO_IP"
}
},
{
"action": "PERMIT",
"match": {
"direction":"DOWNLINK",
"ip_proto": "IPPROTO_IP"
"ip_proto": "IPPROTO_IP"
}
}
],
Expand Down Expand Up @@ -1977,14 +1977,14 @@
"action": "PERMIT",
"match":{
"direction":"UPLINK",
"ip_proto": "IPPROTO_IP"
"ip_proto": "IPPROTO_IP"
}
},
{
"action": "PERMIT",
"match": {
"direction":"DOWNLINK",
"ip_proto": "IPPROTO_IP"
"ip_proto": "IPPROTO_IP"
}
}
],
Expand Down Expand Up @@ -2030,14 +2030,14 @@
"action": "PERMIT",
"match":{
"direction":"UPLINK",
"ip_proto": "IPPROTO_IP"
"ip_proto": "IPPROTO_IP"
}
},
{
"action": "PERMIT",
"match": {
"direction":"DOWNLINK",
"ip_proto": "IPPROTO_IP"
"ip_proto": "IPPROTO_IP"
}
}
],
Expand Down Expand Up @@ -2083,14 +2083,14 @@
"action": "PERMIT",
"match":{
"direction":"UPLINK",
"ip_proto": "IPPROTO_IP"
"ip_proto": "IPPROTO_IP"
}
},
{
"action": "PERMIT",
"match": {
"direction":"DOWNLINK",
"ip_proto": "IPPROTO_IP"
"ip_proto": "IPPROTO_IP"
}
}
],
Expand Down Expand Up @@ -2135,7 +2135,7 @@
"generatorURL": "http://orc8r-prometheus-77f497dcc8-wpf7x:9090/graph?g0.expr=vector%280%29&g0.tab=1",
"labels": {
"alertname": "time test",
"monitor": "master",
"monitor": "host",
"networkID": "mpk_dogfooding",
"severity": "INFO"
}
Expand Down
16 changes: 10 additions & 6 deletions nms/packages/magmalte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@
"@babel/register": "^7.13.16",
"@babel/runtime": "^7.14.0",
"@date-io/moment": "1.3.13",
"@fbcnms/alarms": "^0.3.1",
"@fbcnms/auth": "^0.1.6",
"@fbcnms/alarms": "^1.0.5",
"@fbcnms/auth": "^0.2.0",
"@fbcnms/babel-register": "^0.1.2",
"@fbcnms/express-middleware": "^0.1.5",
"@fbcnms/platform-server": "^0.3.3",
"@fbcnms/express-middleware": "^0.2.0",
"@fbcnms/platform-server": "^0.4.1",
"@fbcnms/projects": "^0.1.0",
"@fbcnms/sequelize-models": "^0.1.13",
"@fbcnms/sequelize-models": "^0.2.0",
"@fbcnms/strings": "^0.1.0",
"@fbcnms/types": "^0.1.11",
"@fbcnms/ui": "^0.2.0",
"@fbcnms/ui": "^2.0.1",
"@fbcnms/util": "^0.1.0",
"@material-table/core": "^4.3.36",
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.0.0",
"@material-ui/lab": "^4.0.0-alpha.60",
"@material-ui/pickers": "^3.2.10",
"@material-ui/styles": "^4.0.0",
"chart.js": "^2.7.3",
Expand All @@ -53,7 +55,9 @@
"material-ui-dropzone": "^3.5.0",
"pg": "^8.5.1",
"pug": "^3.0.1",
"react": "^16.8.6",
"react-chartjs-2": "^2.7.4",
"react-dom": "^16.8.6",
"react-json-tree": "^0.11.2",
"react-json-view": "^1.19.1",
"react-router-dom": "5.1.2",
Expand Down
2 changes: 1 addition & 1 deletion nms/packages/magmalte/scripts/dev_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set -e
# Add the test admin user
docker-compose exec magmalte yarn migrate
docker-compose exec magmalte yarn setAdminPassword magma-test admin@magma.test password1234
docker-compose exec magmalte yarn setAdminPassword master admin@magma.test password1234
docker-compose exec magmalte yarn setAdminPassword host admin@magma.test password1234

# Docker run in a Linux host doesn't resolve host.docker.internal to the host IP.
# See https://github.com/docker/for-linux/issues/264
Expand Down

0 comments on commit 33379d8

Please sign in to comment.