Update notebook
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Build a simulation using the Python API\n"
|
||||
"# Build a simulation using the Python API\n",
|
||||
"\n",
|
||||
"Currently, this notbook manipulates the simulation by directly placing objects inside of the attributes of the network and domain. It should be refactored when proper methods exist for adding these objects.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -40,11 +42,11 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'uuid': 'f0c06262-1bd9-49ee-81f8-793fb4a5e58e',\n",
|
||||
" 'network': {'uuid': '455d6a1a-ca23-4135-b326-3ebf75022a45',\n",
|
||||
"{'uuid': '5304ed6d-de4c-408c-ae24-ada32852d196',\n",
|
||||
" 'network': {'uuid': 'fa17dfe8-81a1-4c7f-8c5b-8c2d3b1e8756',\n",
|
||||
" 'nodes': {},\n",
|
||||
" 'links': {}},\n",
|
||||
" 'domain': {'uuid': '9da912d5-4c07-4df6-94c2-b3630e178912', 'accounts': {}}}"
|
||||
" 'domain': {'uuid': '320cbb83-eb1b-4911-a4f0-fc46d8038a8a', 'accounts': {}}}"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
@@ -77,39 +79,7 @@
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'uuid': 'f0c06262-1bd9-49ee-81f8-793fb4a5e58e',\n",
|
||||
" 'network': {'uuid': '455d6a1a-ca23-4135-b326-3ebf75022a45',\n",
|
||||
" 'nodes': {'c7c91f06-f128-4891-84a2-83beceea3908': {'uuid': 'c7c91f06-f128-4891-84a2-83beceea3908',\n",
|
||||
" 'hostname': 'primaite_pc',\n",
|
||||
" 'operating_state': 0,\n",
|
||||
" 'NICs': {},\n",
|
||||
" 'file_system': {'uuid': '04ffd1e8-dea7-47ad-a088-4856df055ed1',\n",
|
||||
" 'folders': {}},\n",
|
||||
" 'applications': {},\n",
|
||||
" 'services': {},\n",
|
||||
" 'process': {}},\n",
|
||||
" 'dfcc395a-93ff-4dd5-9684-c80c5885d827': {'uuid': 'dfcc395a-93ff-4dd5-9684-c80c5885d827',\n",
|
||||
" 'hostname': 'google_server',\n",
|
||||
" 'operating_state': 0,\n",
|
||||
" 'NICs': {},\n",
|
||||
" 'file_system': {'uuid': 'aea8f406-05de-4a02-b65f-972aa1fed70e',\n",
|
||||
" 'folders': {}},\n",
|
||||
" 'applications': {},\n",
|
||||
" 'services': {},\n",
|
||||
" 'process': {}}},\n",
|
||||
" 'links': {}},\n",
|
||||
" 'domain': {'uuid': '9da912d5-4c07-4df6-94c2-b3630e178912', 'accounts': {}}}"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"my_pc = Node(hostname=\"primaite_pc\",)\n",
|
||||
"my_server = Node(hostname=\"google_server\")\n",
|
||||
@@ -117,9 +87,7 @@
|
||||
"# TODO: when there is a proper function for adding nodes, use it instead of manually adding.\n",
|
||||
"\n",
|
||||
"my_sim.network.nodes[my_pc.uuid] = my_pc\n",
|
||||
"my_sim.network.nodes[my_server.uuid] = my_server\n",
|
||||
"\n",
|
||||
"my_sim.describe_state()"
|
||||
"my_sim.network.nodes[my_server.uuid] = my_server\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -147,10 +115,10 @@
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"2023-08-20 18:34:59,328: NIC c3:08:90:23:29:cb/130.1.1.1 connected to Link c3:08:90:23:29:cb/130.1.1.1<-->40:4a:3f:2e:ee:2e\n",
|
||||
"2023-08-20 18:34:59,329: SwitchPort 40:4a:3f:2e:ee:2e connected to Link c3:08:90:23:29:cb/130.1.1.1<-->40:4a:3f:2e:ee:2e\n",
|
||||
"2023-08-20 18:34:59,331: NIC 69:50:cb:76:22:10/130.1.1.2 connected to Link 69:50:cb:76:22:10/130.1.1.2<-->18:5e:49:ed:21:55\n",
|
||||
"2023-08-20 18:34:59,331: SwitchPort 18:5e:49:ed:21:55 connected to Link 69:50:cb:76:22:10/130.1.1.2<-->18:5e:49:ed:21:55\n"
|
||||
"2023-08-20 18:42:51,310: NIC 5c:b6:26:c0:86:61/130.1.1.1 connected to Link 5c:b6:26:c0:86:61/130.1.1.1<-->01:ef:b1:a3:24:72\n",
|
||||
"2023-08-20 18:42:51,311: SwitchPort 01:ef:b1:a3:24:72 connected to Link 5c:b6:26:c0:86:61/130.1.1.1<-->01:ef:b1:a3:24:72\n",
|
||||
"2023-08-20 18:42:51,314: NIC f6:de:1e:63:8e:7f/130.1.1.2 connected to Link f6:de:1e:63:8e:7f/130.1.1.2<-->30:9e:c8:d4:5d:f3\n",
|
||||
"2023-08-20 18:42:51,315: SwitchPort 30:9e:c8:d4:5d:f3 connected to Link f6:de:1e:63:8e:7f/130.1.1.2<-->30:9e:c8:d4:5d:f3\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -172,74 +140,6 @@
|
||||
"my_sim.network.links[server_to_swtich.uuid] = server_to_swtich"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'uuid': 'f0c06262-1bd9-49ee-81f8-793fb4a5e58e',\n",
|
||||
" 'network': {'uuid': '455d6a1a-ca23-4135-b326-3ebf75022a45',\n",
|
||||
" 'nodes': {'c7c91f06-f128-4891-84a2-83beceea3908': {'uuid': 'c7c91f06-f128-4891-84a2-83beceea3908',\n",
|
||||
" 'hostname': 'primaite_pc',\n",
|
||||
" 'operating_state': 0,\n",
|
||||
" 'NICs': {'f181ea2b-59b6-4724-acf1-a8a7d4e2a1b2': {'uuid': 'f181ea2b-59b6-4724-acf1-a8a7d4e2a1b2',\n",
|
||||
" 'ip_adress': '130.1.1.1',\n",
|
||||
" 'subnet_mask': '255.255.255.0',\n",
|
||||
" 'gateway': '130.1.1.255',\n",
|
||||
" 'mac_address': 'c3:08:90:23:29:cb',\n",
|
||||
" 'speed': 100,\n",
|
||||
" 'mtu': 1500,\n",
|
||||
" 'wake_on_lan': False,\n",
|
||||
" 'dns_servers': [],\n",
|
||||
" 'enabled': False}},\n",
|
||||
" 'file_system': {'uuid': '04ffd1e8-dea7-47ad-a088-4856df055ed1',\n",
|
||||
" 'folders': {}},\n",
|
||||
" 'applications': {},\n",
|
||||
" 'services': {},\n",
|
||||
" 'process': {}},\n",
|
||||
" 'dfcc395a-93ff-4dd5-9684-c80c5885d827': {'uuid': 'dfcc395a-93ff-4dd5-9684-c80c5885d827',\n",
|
||||
" 'hostname': 'google_server',\n",
|
||||
" 'operating_state': 0,\n",
|
||||
" 'NICs': {'1fd281a0-83ae-49d9-9b40-6aae7b465cab': {'uuid': '1fd281a0-83ae-49d9-9b40-6aae7b465cab',\n",
|
||||
" 'ip_adress': '130.1.1.2',\n",
|
||||
" 'subnet_mask': '255.255.255.0',\n",
|
||||
" 'gateway': '130.1.1.255',\n",
|
||||
" 'mac_address': '69:50:cb:76:22:10',\n",
|
||||
" 'speed': 100,\n",
|
||||
" 'mtu': 1500,\n",
|
||||
" 'wake_on_lan': False,\n",
|
||||
" 'dns_servers': [],\n",
|
||||
" 'enabled': False}},\n",
|
||||
" 'file_system': {'uuid': 'aea8f406-05de-4a02-b65f-972aa1fed70e',\n",
|
||||
" 'folders': {}},\n",
|
||||
" 'applications': {},\n",
|
||||
" 'services': {},\n",
|
||||
" 'process': {}}},\n",
|
||||
" 'links': {'cfbf3c88-c2ac-40f2-9466-a92b99f7cfc9': {'uuid': 'cfbf3c88-c2ac-40f2-9466-a92b99f7cfc9',\n",
|
||||
" 'endpoint_a': 'f181ea2b-59b6-4724-acf1-a8a7d4e2a1b2',\n",
|
||||
" 'endpoint_b': '4e6abc87-b4b9-4f95-a9a9-59cac130c6ff',\n",
|
||||
" 'bandwidth': 100.0,\n",
|
||||
" 'current_load': 0.0},\n",
|
||||
" '2dab7fc3-470d-44d2-8593-feb8e96d71ae': {'uuid': '2dab7fc3-470d-44d2-8593-feb8e96d71ae',\n",
|
||||
" 'endpoint_a': '1fd281a0-83ae-49d9-9b40-6aae7b465cab',\n",
|
||||
" 'endpoint_b': 'e136553f-333e-4abf-b1f3-ce352ffa4630',\n",
|
||||
" 'bandwidth': 100.0,\n",
|
||||
" 'current_load': 0.0}}},\n",
|
||||
" 'domain': {'uuid': '9da912d5-4c07-4df6-94c2-b3630e178912', 'accounts': {}}}"
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"my_sim.describe_state()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -249,7 +149,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -259,7 +159,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -269,16 +169,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"FileSystemFile(uuid='3ecf7223-dafd-4973-8c3b-b85af4e177da', name='favicon.ico', size=40.0, file_type=<FileSystemFileType.PNG: '11'>, action_manager=None)"
|
||||
"FileSystemFile(uuid='253e4606-0f6d-4e57-8db0-6fa7e331ecea', name='favicon.ico', size=40.0, file_type=<FileSystemFileType.PNG: '11'>, action_manager=None)"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -297,7 +197,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -305,6 +205,7 @@
|
||||
"from primaite.simulator.system.software import SoftwareHealthState, SoftwareCriticality\n",
|
||||
"from primaite.simulator.network.transmission.transport_layer import Port\n",
|
||||
"\n",
|
||||
"# no applications exist yet so we will create our own.\n",
|
||||
"class MSPaint(Application):\n",
|
||||
" def describe_state(self):\n",
|
||||
" return super().describe_state()"
|
||||
@@ -312,7 +213,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -321,7 +222,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -337,7 +238,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -346,7 +247,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -354,39 +255,46 @@
|
||||
"my_sim.domain.accounts[acct.uuid] = acct"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Verify that the state dictionary contains no non-serialisable objects."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'uuid': 'f0c06262-1bd9-49ee-81f8-793fb4a5e58e',\n",
|
||||
" 'network': {'uuid': '455d6a1a-ca23-4135-b326-3ebf75022a45',\n",
|
||||
" 'nodes': {'c7c91f06-f128-4891-84a2-83beceea3908': {'uuid': 'c7c91f06-f128-4891-84a2-83beceea3908',\n",
|
||||
"{'uuid': '5304ed6d-de4c-408c-ae24-ada32852d196',\n",
|
||||
" 'network': {'uuid': 'fa17dfe8-81a1-4c7f-8c5b-8c2d3b1e8756',\n",
|
||||
" 'nodes': {'1fa46446-6681-4e25-a3ba-c4c2cc564630': {'uuid': '1fa46446-6681-4e25-a3ba-c4c2cc564630',\n",
|
||||
" 'hostname': 'primaite_pc',\n",
|
||||
" 'operating_state': 0,\n",
|
||||
" 'NICs': {'f181ea2b-59b6-4724-acf1-a8a7d4e2a1b2': {'uuid': 'f181ea2b-59b6-4724-acf1-a8a7d4e2a1b2',\n",
|
||||
" 'NICs': {'09ca02eb-7733-492c-9eff-f0d6b6ebeeda': {'uuid': '09ca02eb-7733-492c-9eff-f0d6b6ebeeda',\n",
|
||||
" 'ip_adress': '130.1.1.1',\n",
|
||||
" 'subnet_mask': '255.255.255.0',\n",
|
||||
" 'gateway': '130.1.1.255',\n",
|
||||
" 'mac_address': 'c3:08:90:23:29:cb',\n",
|
||||
" 'mac_address': '5c:b6:26:c0:86:61',\n",
|
||||
" 'speed': 100,\n",
|
||||
" 'mtu': 1500,\n",
|
||||
" 'wake_on_lan': False,\n",
|
||||
" 'dns_servers': [],\n",
|
||||
" 'enabled': False}},\n",
|
||||
" 'file_system': {'uuid': '04ffd1e8-dea7-47ad-a088-4856df055ed1',\n",
|
||||
" 'folders': {'f1fdf2ae-6377-4417-a28a-3edb4058712d': {'uuid': 'f1fdf2ae-6377-4417-a28a-3edb4058712d',\n",
|
||||
" 'file_system': {'uuid': '8b533e31-04e9-4838-839d-0656ace3e57a',\n",
|
||||
" 'folders': {'b450c223-872c-4fe0-90cc-9da80973eaad': {'uuid': 'b450c223-872c-4fe0-90cc-9da80973eaad',\n",
|
||||
" 'name': 'downloads',\n",
|
||||
" 'size': 1000.0,\n",
|
||||
" 'files': {'409b09a3-0d98-4c03-adf2-09190539be45': {'uuid': '409b09a3-0d98-4c03-adf2-09190539be45',\n",
|
||||
" 'files': {'8160e685-a76f-4171-8a12-3d6b32a9ea16': {'uuid': '8160e685-a76f-4171-8a12-3d6b32a9ea16',\n",
|
||||
" 'name': 'firefox_installer.zip',\n",
|
||||
" 'size': 1000.0,\n",
|
||||
" 'file_type': 'ZIP'}},\n",
|
||||
" 'is_quarantined': False}}},\n",
|
||||
" 'applications': {'cddee888-d1b9-4289-8512-bc0a6672c880': {'uuid': 'cddee888-d1b9-4289-8512-bc0a6672c880',\n",
|
||||
" 'applications': {'c82f1064-f35e-466b-88ae-3f61ba0e5161': {'uuid': 'c82f1064-f35e-466b-88ae-3f61ba0e5161',\n",
|
||||
" 'health_state': 'GOOD',\n",
|
||||
" 'health_state_red_view': 'GOOD',\n",
|
||||
" 'criticality': 'MEDIUM',\n",
|
||||
@@ -404,29 +312,29 @@
|
||||
" 'groups': []}},\n",
|
||||
" 'services': {},\n",
|
||||
" 'process': {}},\n",
|
||||
" 'dfcc395a-93ff-4dd5-9684-c80c5885d827': {'uuid': 'dfcc395a-93ff-4dd5-9684-c80c5885d827',\n",
|
||||
" '7f637689-6f91-4026-a685-48a9067f03e8': {'uuid': '7f637689-6f91-4026-a685-48a9067f03e8',\n",
|
||||
" 'hostname': 'google_server',\n",
|
||||
" 'operating_state': 0,\n",
|
||||
" 'NICs': {'1fd281a0-83ae-49d9-9b40-6aae7b465cab': {'uuid': '1fd281a0-83ae-49d9-9b40-6aae7b465cab',\n",
|
||||
" 'NICs': {'1abc7272-c516-4463-bd07-1a3cefe39313': {'uuid': '1abc7272-c516-4463-bd07-1a3cefe39313',\n",
|
||||
" 'ip_adress': '130.1.1.2',\n",
|
||||
" 'subnet_mask': '255.255.255.0',\n",
|
||||
" 'gateway': '130.1.1.255',\n",
|
||||
" 'mac_address': '69:50:cb:76:22:10',\n",
|
||||
" 'mac_address': 'f6:de:1e:63:8e:7f',\n",
|
||||
" 'speed': 100,\n",
|
||||
" 'mtu': 1500,\n",
|
||||
" 'wake_on_lan': False,\n",
|
||||
" 'dns_servers': [],\n",
|
||||
" 'enabled': False}},\n",
|
||||
" 'file_system': {'uuid': 'aea8f406-05de-4a02-b65f-972aa1fed70e',\n",
|
||||
" 'folders': {'beb5b535-cf6c-431d-94f6-d1097910130d': {'uuid': 'beb5b535-cf6c-431d-94f6-d1097910130d',\n",
|
||||
" 'file_system': {'uuid': 'ac9a6643-8349-4f7a-98c7-a1a9f97ce123',\n",
|
||||
" 'folders': {'befa5d92-0878-4da2-9dac-f993c0b4a554': {'uuid': 'befa5d92-0878-4da2-9dac-f993c0b4a554',\n",
|
||||
" 'name': 'static',\n",
|
||||
" 'size': 0,\n",
|
||||
" 'files': {},\n",
|
||||
" 'is_quarantined': False},\n",
|
||||
" '6644cd6c-1eca-4fe4-9313-e3481abb895e': {'uuid': '6644cd6c-1eca-4fe4-9313-e3481abb895e',\n",
|
||||
" '27383b5e-8884-4ec0-bb50-a5d43e460dfa': {'uuid': '27383b5e-8884-4ec0-bb50-a5d43e460dfa',\n",
|
||||
" 'name': 'root',\n",
|
||||
" 'size': 40.0,\n",
|
||||
" 'files': {'3ecf7223-dafd-4973-8c3b-b85af4e177da': {'uuid': '3ecf7223-dafd-4973-8c3b-b85af4e177da',\n",
|
||||
" 'files': {'253e4606-0f6d-4e57-8db0-6fa7e331ecea': {'uuid': '253e4606-0f6d-4e57-8db0-6fa7e331ecea',\n",
|
||||
" 'name': 'favicon.ico',\n",
|
||||
" 'size': 40.0,\n",
|
||||
" 'file_type': 'PNG'}},\n",
|
||||
@@ -434,18 +342,18 @@
|
||||
" 'applications': {},\n",
|
||||
" 'services': {},\n",
|
||||
" 'process': {}}},\n",
|
||||
" 'links': {'cfbf3c88-c2ac-40f2-9466-a92b99f7cfc9': {'uuid': 'cfbf3c88-c2ac-40f2-9466-a92b99f7cfc9',\n",
|
||||
" 'endpoint_a': 'f181ea2b-59b6-4724-acf1-a8a7d4e2a1b2',\n",
|
||||
" 'endpoint_b': '4e6abc87-b4b9-4f95-a9a9-59cac130c6ff',\n",
|
||||
" 'links': {'a449b1ff-50d9-4342-861e-44f2d4dfef37': {'uuid': 'a449b1ff-50d9-4342-861e-44f2d4dfef37',\n",
|
||||
" 'endpoint_a': '09ca02eb-7733-492c-9eff-f0d6b6ebeeda',\n",
|
||||
" 'endpoint_b': 'ee4557d9-a309-45dd-a6e0-5b572cc70ee5',\n",
|
||||
" 'bandwidth': 100.0,\n",
|
||||
" 'current_load': 0.0},\n",
|
||||
" '2dab7fc3-470d-44d2-8593-feb8e96d71ae': {'uuid': '2dab7fc3-470d-44d2-8593-feb8e96d71ae',\n",
|
||||
" 'endpoint_a': '1fd281a0-83ae-49d9-9b40-6aae7b465cab',\n",
|
||||
" 'endpoint_b': 'e136553f-333e-4abf-b1f3-ce352ffa4630',\n",
|
||||
" 'ebd7687b-ec69-4f1b-b2ba-86669aa95723': {'uuid': 'ebd7687b-ec69-4f1b-b2ba-86669aa95723',\n",
|
||||
" 'endpoint_a': '1abc7272-c516-4463-bd07-1a3cefe39313',\n",
|
||||
" 'endpoint_b': 'dc26b764-a07e-486a-99a4-798c8e0c187a',\n",
|
||||
" 'bandwidth': 100.0,\n",
|
||||
" 'current_load': 0.0}}},\n",
|
||||
" 'domain': {'uuid': '9da912d5-4c07-4df6-94c2-b3630e178912',\n",
|
||||
" 'accounts': {'563a1805-0b32-4ba6-9551-e127e5eb57a8': {'uuid': '563a1805-0b32-4ba6-9551-e127e5eb57a8',\n",
|
||||
" 'domain': {'uuid': '320cbb83-eb1b-4911-a4f0-fc46d8038a8a',\n",
|
||||
" 'accounts': {'5fdcfb66-84f3-4f0f-a3a7-d0cb0e1a5d51': {'uuid': '5fdcfb66-84f3-4f0f-a3a7-d0cb0e1a5d51',\n",
|
||||
" 'num_logons': 0,\n",
|
||||
" 'num_logoffs': 0,\n",
|
||||
" 'num_group_changes': 0,\n",
|
||||
@@ -455,7 +363,7 @@
|
||||
" 'enabled': True}}}}"
|
||||
]
|
||||
},
|
||||
"execution_count": 16,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -464,41 +372,25 @@
|
||||
"my_sim.describe_state()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Verify that the state dictionary contains no non-serialisable objects."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'{\"uuid\": \"f0c06262-1bd9-49ee-81f8-793fb4a5e58e\", \"network\": {\"uuid\": \"455d6a1a-ca23-4135-b326-3ebf75022a45\", \"nodes\": {\"c7c91f06-f128-4891-84a2-83beceea3908\": {\"uuid\": \"c7c91f06-f128-4891-84a2-83beceea3908\", \"hostname\": \"primaite_pc\", \"operating_state\": 0, \"NICs\": {\"f181ea2b-59b6-4724-acf1-a8a7d4e2a1b2\": {\"uuid\": \"f181ea2b-59b6-4724-acf1-a8a7d4e2a1b2\", \"ip_adress\": \"130.1.1.1\", \"subnet_mask\": \"255.255.255.0\", \"gateway\": \"130.1.1.255\", \"mac_address\": \"c3:08:90:23:29:cb\", \"speed\": 100, \"mtu\": 1500, \"wake_on_lan\": false, \"dns_servers\": [], \"enabled\": false}}, \"file_system\": {\"uuid\": \"04ffd1e8-dea7-47ad-a088-4856df055ed1\", \"folders\": {\"f1fdf2ae-6377-4417-a28a-3edb4058712d\": {\"uuid\": \"f1fdf2ae-6377-4417-a28a-3edb4058712d\", \"name\": \"downloads\", \"size\": 1000.0, \"files\": {\"409b09a3-0d98-4c03-adf2-09190539be45\": {\"uuid\": \"409b09a3-0d98-4c03-adf2-09190539be45\", \"name\": \"firefox_installer.zip\", \"size\": 1000.0, \"file_type\": \"ZIP\"}}, \"is_quarantined\": false}}}, \"applications\": {\"cddee888-d1b9-4289-8512-bc0a6672c880\": {\"uuid\": \"cddee888-d1b9-4289-8512-bc0a6672c880\", \"health_state\": \"GOOD\", \"health_state_red_view\": \"GOOD\", \"criticality\": \"MEDIUM\", \"patching_count\": 0, \"scanning_count\": 0, \"revealed_to_red\": false, \"installing_count\": 0, \"max_sessions\": 1, \"tcp\": true, \"udp\": true, \"ports\": [\"HTTP\"], \"opearting_state\": \"RUNNING\", \"execution_control_status\": \"manual\", \"num_executions\": 0, \"groups\": []}}, \"services\": {}, \"process\": {}}, \"dfcc395a-93ff-4dd5-9684-c80c5885d827\": {\"uuid\": \"dfcc395a-93ff-4dd5-9684-c80c5885d827\", \"hostname\": \"google_server\", \"operating_state\": 0, \"NICs\": {\"1fd281a0-83ae-49d9-9b40-6aae7b465cab\": {\"uuid\": \"1fd281a0-83ae-49d9-9b40-6aae7b465cab\", \"ip_adress\": \"130.1.1.2\", \"subnet_mask\": \"255.255.255.0\", \"gateway\": \"130.1.1.255\", \"mac_address\": \"69:50:cb:76:22:10\", \"speed\": 100, \"mtu\": 1500, \"wake_on_lan\": false, \"dns_servers\": [], \"enabled\": false}}, \"file_system\": {\"uuid\": \"aea8f406-05de-4a02-b65f-972aa1fed70e\", \"folders\": {\"beb5b535-cf6c-431d-94f6-d1097910130d\": {\"uuid\": \"beb5b535-cf6c-431d-94f6-d1097910130d\", \"name\": \"static\", \"size\": 0, \"files\": {}, \"is_quarantined\": false}, \"6644cd6c-1eca-4fe4-9313-e3481abb895e\": {\"uuid\": \"6644cd6c-1eca-4fe4-9313-e3481abb895e\", \"name\": \"root\", \"size\": 40.0, \"files\": {\"3ecf7223-dafd-4973-8c3b-b85af4e177da\": {\"uuid\": \"3ecf7223-dafd-4973-8c3b-b85af4e177da\", \"name\": \"favicon.ico\", \"size\": 40.0, \"file_type\": \"PNG\"}}, \"is_quarantined\": false}}}, \"applications\": {}, \"services\": {}, \"process\": {}}}, \"links\": {\"cfbf3c88-c2ac-40f2-9466-a92b99f7cfc9\": {\"uuid\": \"cfbf3c88-c2ac-40f2-9466-a92b99f7cfc9\", \"endpoint_a\": \"f181ea2b-59b6-4724-acf1-a8a7d4e2a1b2\", \"endpoint_b\": \"4e6abc87-b4b9-4f95-a9a9-59cac130c6ff\", \"bandwidth\": 100.0, \"current_load\": 0.0}, \"2dab7fc3-470d-44d2-8593-feb8e96d71ae\": {\"uuid\": \"2dab7fc3-470d-44d2-8593-feb8e96d71ae\", \"endpoint_a\": \"1fd281a0-83ae-49d9-9b40-6aae7b465cab\", \"endpoint_b\": \"e136553f-333e-4abf-b1f3-ce352ffa4630\", \"bandwidth\": 100.0, \"current_load\": 0.0}}}, \"domain\": {\"uuid\": \"9da912d5-4c07-4df6-94c2-b3630e178912\", \"accounts\": {\"563a1805-0b32-4ba6-9551-e127e5eb57a8\": {\"uuid\": \"563a1805-0b32-4ba6-9551-e127e5eb57a8\", \"num_logons\": 0, \"num_logoffs\": 0, \"num_group_changes\": 0, \"username\": \"admin\", \"password\": \"admin12\", \"account_type\": \"USER\", \"enabled\": true}}}}'"
|
||||
"'{\"uuid\": \"5304ed6d-de4c-408c-ae24-ada32852d196\", \"network\": {\"uuid\": \"fa17dfe8-81a1-4c7f-8c5b-8c2d3b1e8756\", \"nodes\": {\"1fa46446-6681-4e25-a3ba-c4c2cc564630\": {\"uuid\": \"1fa46446-6681-4e25-a3ba-c4c2cc564630\", \"hostname\": \"primaite_pc\", \"operating_state\": 0, \"NICs\": {\"09ca02eb-7733-492c-9eff-f0d6b6ebeeda\": {\"uuid\": \"09ca02eb-7733-492c-9eff-f0d6b6ebeeda\", \"ip_adress\": \"130.1.1.1\", \"subnet_mask\": \"255.255.255.0\", \"gateway\": \"130.1.1.255\", \"mac_address\": \"5c:b6:26:c0:86:61\", \"speed\": 100, \"mtu\": 1500, \"wake_on_lan\": false, \"dns_servers\": [], \"enabled\": false}}, \"file_system\": {\"uuid\": \"8b533e31-04e9-4838-839d-0656ace3e57a\", \"folders\": {\"b450c223-872c-4fe0-90cc-9da80973eaad\": {\"uuid\": \"b450c223-872c-4fe0-90cc-9da80973eaad\", \"name\": \"downloads\", \"size\": 1000.0, \"files\": {\"8160e685-a76f-4171-8a12-3d6b32a9ea16\": {\"uuid\": \"8160e685-a76f-4171-8a12-3d6b32a9ea16\", \"name\": \"firefox_installer.zip\", \"size\": 1000.0, \"file_type\": \"ZIP\"}}, \"is_quarantined\": false}}}, \"applications\": {\"c82f1064-f35e-466b-88ae-3f61ba0e5161\": {\"uuid\": \"c82f1064-f35e-466b-88ae-3f61ba0e5161\", \"health_state\": \"GOOD\", \"health_state_red_view\": \"GOOD\", \"criticality\": \"MEDIUM\", \"patching_count\": 0, \"scanning_count\": 0, \"revealed_to_red\": false, \"installing_count\": 0, \"max_sessions\": 1, \"tcp\": true, \"udp\": true, \"ports\": [\"HTTP\"], \"opearting_state\": \"RUNNING\", \"execution_control_status\": \"manual\", \"num_executions\": 0, \"groups\": []}}, \"services\": {}, \"process\": {}}, \"7f637689-6f91-4026-a685-48a9067f03e8\": {\"uuid\": \"7f637689-6f91-4026-a685-48a9067f03e8\", \"hostname\": \"google_server\", \"operating_state\": 0, \"NICs\": {\"1abc7272-c516-4463-bd07-1a3cefe39313\": {\"uuid\": \"1abc7272-c516-4463-bd07-1a3cefe39313\", \"ip_adress\": \"130.1.1.2\", \"subnet_mask\": \"255.255.255.0\", \"gateway\": \"130.1.1.255\", \"mac_address\": \"f6:de:1e:63:8e:7f\", \"speed\": 100, \"mtu\": 1500, \"wake_on_lan\": false, \"dns_servers\": [], \"enabled\": false}}, \"file_system\": {\"uuid\": \"ac9a6643-8349-4f7a-98c7-a1a9f97ce123\", \"folders\": {\"befa5d92-0878-4da2-9dac-f993c0b4a554\": {\"uuid\": \"befa5d92-0878-4da2-9dac-f993c0b4a554\", \"name\": \"static\", \"size\": 0, \"files\": {}, \"is_quarantined\": false}, \"27383b5e-8884-4ec0-bb50-a5d43e460dfa\": {\"uuid\": \"27383b5e-8884-4ec0-bb50-a5d43e460dfa\", \"name\": \"root\", \"size\": 40.0, \"files\": {\"253e4606-0f6d-4e57-8db0-6fa7e331ecea\": {\"uuid\": \"253e4606-0f6d-4e57-8db0-6fa7e331ecea\", \"name\": \"favicon.ico\", \"size\": 40.0, \"file_type\": \"PNG\"}}, \"is_quarantined\": false}}}, \"applications\": {}, \"services\": {}, \"process\": {}}}, \"links\": {\"a449b1ff-50d9-4342-861e-44f2d4dfef37\": {\"uuid\": \"a449b1ff-50d9-4342-861e-44f2d4dfef37\", \"endpoint_a\": \"09ca02eb-7733-492c-9eff-f0d6b6ebeeda\", \"endpoint_b\": \"ee4557d9-a309-45dd-a6e0-5b572cc70ee5\", \"bandwidth\": 100.0, \"current_load\": 0.0}, \"ebd7687b-ec69-4f1b-b2ba-86669aa95723\": {\"uuid\": \"ebd7687b-ec69-4f1b-b2ba-86669aa95723\", \"endpoint_a\": \"1abc7272-c516-4463-bd07-1a3cefe39313\", \"endpoint_b\": \"dc26b764-a07e-486a-99a4-798c8e0c187a\", \"bandwidth\": 100.0, \"current_load\": 0.0}}}, \"domain\": {\"uuid\": \"320cbb83-eb1b-4911-a4f0-fc46d8038a8a\", \"accounts\": {\"5fdcfb66-84f3-4f0f-a3a7-d0cb0e1a5d51\": {\"uuid\": \"5fdcfb66-84f3-4f0f-a3a7-d0cb0e1a5d51\", \"num_logons\": 0, \"num_logoffs\": 0, \"num_group_changes\": 0, \"username\": \"admin\", \"password\": \"admin12\", \"account_type\": \"USER\", \"enabled\": true}}}}'"
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"d = my_sim.describe_state()\n",
|
||||
"json.dumps(d)"
|
||||
"import json\n",
|
||||
"json.dumps(my_sim.describe_state())"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user