diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index b56aa954..08d89f07 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -220,6 +220,8 @@ import { ConfiguratorDialogSwitchComponent } from './components/project-map/node
import { ConfiguratorDialogVirtualBoxComponent } from './components/project-map/node-editors/configurator/virtualbox/configurator-virtualbox.component';
import { CustomAdaptersTableComponent } from './components/preferences/common/custom-adapters-table/custom-adapters-table.component';
import { ConfiguratorDialogQemuComponent } from './components/project-map/node-editors/configurator/qemu/configurator-qemu.component';
+import { ConfiguratorDialogCloudComponent } from './components/project-map/node-editors/configurator/cloud/configurator-cloud.component';
+import { UdpTunnelsComponent } from './components/preferences/common/udp-tunnels/udp-tunnels.component';
if (environment.production) {
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
@@ -367,7 +369,9 @@ if (environment.production) {
ConfiguratorDialogSwitchComponent,
ConfiguratorDialogVirtualBoxComponent,
CustomAdaptersTableComponent,
- ConfiguratorDialogQemuComponent
+ ConfiguratorDialogQemuComponent,
+ ConfiguratorDialogCloudComponent,
+ UdpTunnelsComponent
],
imports: [
BrowserModule,
@@ -473,7 +477,8 @@ if (environment.production) {
ConfiguratorDialogEthernetSwitchComponent,
ConfiguratorDialogSwitchComponent,
ConfiguratorDialogVirtualBoxComponent,
- ConfiguratorDialogQemuComponent
+ ConfiguratorDialogQemuComponent,
+ ConfiguratorDialogCloudComponent
],
bootstrap: [AppComponent]
})
diff --git a/src/app/cartography/models/node.ts b/src/app/cartography/models/node.ts
index 266a099a..b875d9fb 100644
--- a/src/app/cartography/models/node.ts
+++ b/src/app/cartography/models/node.ts
@@ -4,7 +4,9 @@ import { CustomAdapter } from '../../models/qemu/qemu-custom-adapter';
export class PortsMapping {
name: string;
+ interface?: string;
port_number: number;
+ type?: string;
}
export class Properties {
diff --git a/src/app/components/preferences/common/udp-tunnels/udp-tunnels.component.html b/src/app/components/preferences/common/udp-tunnels/udp-tunnels.component.html
new file mode 100644
index 00000000..ac5a49be
--- /dev/null
+++ b/src/app/components/preferences/common/udp-tunnels/udp-tunnels.component.html
@@ -0,0 +1,59 @@
+
+
+ Name |
+ {{element.name}} |
+
+
+
+ Local port |
+ {{element.rport}} |
+
+
+
+ Type |
+ {{element.rhost}} |
+
+
+
+ Remote port |
+ {{element.lport}} |
+
+
+
+ Actions |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/components/preferences/common/udp-tunnels/udp-tunnels.component.ts b/src/app/components/preferences/common/udp-tunnels/udp-tunnels.component.ts
new file mode 100644
index 00000000..6052b28c
--- /dev/null
+++ b/src/app/components/preferences/common/udp-tunnels/udp-tunnels.component.ts
@@ -0,0 +1,47 @@
+import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core";
+import { Server } from '../../../../models/server';
+import { PortsMappingEntity } from '../../../../models/ethernetHub/ports-mapping-enity';
+import { BuiltInTemplatesConfigurationService } from '../../../../services/built-in-templates-configuration.service';
+
+
+@Component({
+ selector: 'app-udp-tunnels',
+ templateUrl: './udp-tunnels.component.html',
+ styleUrls: ['../../preferences.component.scss']
+})
+export class UdpTunnelsComponent implements OnInit {
+ @Input() dataSourceUdp: PortsMappingEntity[] = [];
+ displayedColumns: string[] = ['name', 'lport', 'rhost', 'rport', 'action'];
+ newPort: PortsMappingEntity = {
+ name: '',
+ port_number: 0,
+ };
+ portTypes: string[] = [];
+ etherTypes: string[] = [];
+
+ constructor(
+ private builtInTemplatesConfigurationService: BuiltInTemplatesConfigurationService
+ ) {}
+
+ ngOnInit() {
+ this.getConfiguration();
+ }
+
+ getConfiguration() {
+ this.etherTypes = this.builtInTemplatesConfigurationService.getEtherTypesForEthernetSwitches();
+ this.portTypes = this.builtInTemplatesConfigurationService.getPortTypesForEthernetSwitches();
+ }
+
+ onAddUdpInterface() {
+ this.dataSourceUdp = this.dataSourceUdp.concat([this.newPort]);
+
+ this.newPort = {
+ name: '',
+ port_number: 0,
+ };
+ }
+
+ delete(port: PortsMappingEntity) {
+ this.dataSourceUdp = this.dataSourceUdp.filter(n => n !== port);
+ }
+}
diff --git a/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts b/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts
index 0bc7fb9c..b92cad39 100644
--- a/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts
+++ b/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts
@@ -8,6 +8,7 @@ import { ConfiguratorDialogEthernetSwitchComponent } from '../../../node-editors
import { ConfiguratorDialogSwitchComponent } from '../../../node-editors/configurator/switch/configurator-switch.component';
import { ConfiguratorDialogVirtualBoxComponent } from '../../../node-editors/configurator/virtualbox/configurator-virtualbox.component';
import { ConfiguratorDialogQemuComponent } from '../../../node-editors/configurator/qemu/configurator-qemu.component';
+import { ConfiguratorDialogCloudComponent } from '../../../node-editors/configurator/cloud/configurator-cloud.component';
@Component({
@@ -18,7 +19,6 @@ export class ConfigActionComponent {
@Input() server: Server;
@Input() node: Node;
private conf = {
- width: '600px',
autoFocus: false
};
dialogRef;
@@ -33,7 +33,7 @@ export class ConfigActionComponent {
} else if (this.node.node_type === 'ethernet_switch') {
this.dialogRef = this.dialog.open(ConfiguratorDialogEthernetSwitchComponent, this.conf);
} else if (this.node.node_type === 'cloud') {
-
+ this.dialogRef = this.dialog.open(ConfiguratorDialogCloudComponent, this.conf);
} else if (this.node.node_type === 'dynamips') {
} else if (this.node.node_type === 'iou') {
diff --git a/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.html b/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.html
index e69de29b..6aaf6fd7 100644
--- a/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.html
+++ b/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.html
@@ -0,0 +1,67 @@
+Configurator for node {{name}}
+
+
+
+
+
+
+
diff --git a/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.ts b/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.ts
index e69de29b..c87cdf19 100644
--- a/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.ts
+++ b/src/app/components/project-map/node-editors/configurator/cloud/configurator-cloud.component.ts
@@ -0,0 +1,101 @@
+import { Component, OnInit, Input, ViewChild } from "@angular/core";
+import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
+import { Node } from '../../../../../cartography/models/node';
+import { Server } from '../../../../../models/server';
+import { NodeService } from '../../../../../services/node.service';
+import { ToasterService } from '../../../../../services/toaster.service';
+import { MatDialogRef } from '@angular/material';
+import { CustomAdaptersTableComponent } from '../../../../../components/preferences/common/custom-adapters-table/custom-adapters-table.component';
+import { QemuBinary } from '../../../../../models/qemu/qemu-binary';
+import { BuiltInTemplatesConfigurationService } from '../../../../../services/built-in-templates-configuration.service';
+import { PortsMappingEntity } from '../../../../../models/ethernetHub/ports-mapping-enity';
+import { UdpTunnelsComponent } from '../../../../../components/preferences/common/udp-tunnels/udp-tunnels.component';
+
+
+@Component({
+ selector: 'app-configurator-cloud',
+ templateUrl: './configurator-cloud.component.html',
+ styleUrls: ['../configurator.component.scss']
+})
+export class ConfiguratorDialogCloudComponent implements OnInit {
+ server: Server;
+ node: Node;
+ name: string;
+ generalSettingsForm: FormGroup;
+ consoleTypes: string[] = [];
+ binaries: QemuBinary[] = [];
+ onCloseOptions = [];
+ bootPriorities = [];
+ diskInterfaces: string[] = [];
+
+ portsMappingEthernet: PortsMappingEntity[] = [];
+ portsMappingTap: PortsMappingEntity[] = [];
+ portsMappingUdp: PortsMappingEntity[] = [];
+
+ displayedColumns: string[] = ['adapter_number', 'port_name', 'adapter_type', 'actions'];
+ networkTypes = [];
+
+ @ViewChild("udpTunnels", {static: false}) udpTunnels: UdpTunnelsComponent;
+
+ constructor(
+ public dialogRef: MatDialogRef,
+ public nodeService: NodeService,
+ private toasterService: ToasterService,
+ private formBuilder: FormBuilder,
+ private builtInTemplatesConfigurationService: BuiltInTemplatesConfigurationService,
+ ) {
+ this.generalSettingsForm = this.formBuilder.group({
+ name: new FormControl('', Validators.required)
+ });
+ }
+
+ ngOnInit() {
+ this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => {
+ this.node = node;
+ this.name = node.name;
+ this.getConfiguration();
+
+ this.portsMappingEthernet = this.node.properties.ports_mapping
+ .filter((elem) => elem.type === 'ethernet');
+
+ this.portsMappingTap = this.node.properties.ports_mapping
+ .filter((elem) => elem.type === 'tap');
+
+ this.portsMappingUdp = this.node.properties.ports_mapping
+ .filter((elem) => elem.type === 'udp');
+ })
+ }
+
+ getConfiguration() {
+ this.consoleTypes = this.builtInTemplatesConfigurationService.getConsoleTypesForCloudNodes();
+ }
+
+ onSaveClick() {
+ if (this.generalSettingsForm.valid) {
+ this.portsMappingUdp = this.udpTunnels.dataSourceUdp;
+
+ this.node.properties.ports_mapping = this.portsMappingUdp.concat(this.portsMappingEthernet).concat(this.portsMappingTap);
+
+ // this.node.custom_adapters = [];
+ // this.customAdapters.adapters.forEach(n => {
+ // this.node.custom_adapters.push({
+ // adapter_number: n.adapter_number,
+ // adapter_type: n.adapter_type
+ // })
+ // });
+
+ // this.node.properties.adapters = this.node.custom_adapters.length;
+
+ this.nodeService. updateNode(this.server, this.node).subscribe(() => {
+ this.toasterService.success(`Node ${this.node.name} updated.`);
+ this.onCancelClick();
+ });
+ } else {
+ this.toasterService.error(`Fill all required fields.`);
+ }
+ }
+
+ onCancelClick() {
+ this.dialogRef.close();
+ }
+}