Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset Factory HLD #2

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
df77d3a
Updating Contributors
ixodie Dec 15, 2022
87a2bd0
Reset Factory HLD
Mohammedz93 Jan 5, 2023
00d25b9
Merge branch 'master' into js-Updating-Contributors
ixodie Jan 5, 2023
59306d7
Merge branch 'master' into js-Updating-Contributors
lucyhyde Jan 11, 2023
2c43fa5
HLD Fixes
Mohammedz93 Jan 23, 2023
6e7fe8a
Add error flow + fixes
Mohammedz93 Jan 23, 2023
2dab30a
Merge branch 'master' into reset_factory_hld
Mohammedz93 Jan 23, 2023
77276b2
Typo fix
Mohammedz93 Jan 23, 2023
903a1a3
Merge branch 'reset_factory_hld' of https://github.com/Mohammedz93/SO…
Mohammedz93 Jan 23, 2023
4e0fafa
Change diagram
Mohammedz93 Jan 24, 2023
77e26df
Fix diagram
Mohammedz93 Jan 24, 2023
ecd0ae2
Update EVPN_VXLAN_HLD.md (#1227)
nkelapur Feb 2, 2023
b25dd7c
Update EVPN HLD on Fastboot limitation (#1233)
adyeung Feb 2, 2023
f7b57b4
Collecting dump during SAI failure (#1212)
dgsudharsan Feb 2, 2023
4cbf1f3
Merge branch 'master' into reset_factory_hld
Mohammedz93 Feb 3, 2023
02dbd98
HLD Fixes
Mohammedz93 Feb 3, 2023
0001a01
Merge branch 'master' into js-Updating-Contributors
ixodie Feb 7, 2023
fe99d1d
Enhance show acl commands
bingwang-ms Feb 10, 2023
61e3b5c
Add sample output for show acl rule
bingwang-ms Feb 10, 2023
e936175
Merge pull request #1187 from ixodie/js-Updating-Contributors
zhangyanzhao Feb 14, 2023
5cc845d
Updated Community Calendar for Menu (#1249)
kannankvs Feb 15, 2023
8b5a0a9
Updated Supported Platform for Nvidia (#1250)
kannankvs Feb 15, 2023
516f2fe
Updated supported platform for md file (#1251)
kannankvs Feb 15, 2023
7a434f5
Revert "Updating Contributors"
zhangyanzhao Feb 16, 2023
931ab25
Merge pull request #1266 from sonic-net/revert-1187-js-Updating-Contr…
zhangyanzhao Feb 16, 2023
bcb7451
Fix for Contributing organization in Webpage (#1263)
kannankvs Feb 22, 2023
ce054f6
Updated Asic details for Ragile platform (#1270)
kannankvs Feb 22, 2023
c30ff69
Config Reload Enhancement (#1203)
dgsudharsan Feb 23, 2023
ab996b4
FIB Suppress Announcements of Routes Not Installed in HW (#1103)
stepanblyschak Feb 23, 2023
3b67a4f
Updated partner logo
kannankvs Mar 7, 2023
03de906
Merge pull request #1278 from kannankvs/logo_update_general
zhangyanzhao Mar 13, 2023
c5def30
HLD update: Adding support for FPGA devices in PDDF (#1232)
FuzailBrcm Mar 15, 2023
72d30c2
Merge branch 'master' into improve_show_acl_commands
bingwang-ms Mar 15, 2023
8f92c6e
Merge pull request #1261 from bingwang-ms/improve_show_acl_commands
bingwang-ms Mar 15, 2023
f822930
Updated name change for Ragile platform
kannankvs Mar 7, 2023
17644f9
Merge pull request #1279 from kannankvs/ragile_name_change
zhangyanzhao Mar 16, 2023
ee884d9
Merge branch 'master' into reset_factory_hld
liat-grozovik Mar 16, 2023
668987f
dos2unix run on shell script. And added # in first line of script (#1…
kannankvs Mar 22, 2023
821db23
Improve HLD for show acl enhancement
bingwang-ms Mar 23, 2023
3a1def9
Merge pull request #1303 from bingwang-ms/improve_show_acl_cmd
bingwang-ms Mar 24, 2023
fa2fb32
Add DASH resources to CRM HLD. (#1265)
oleksandrivantsiv Mar 27, 2023
62b3866
Updated MoM (#1300)
kannankvs Mar 29, 2023
13a97bd
Static DNS HLD (#1262)
oleksandrivantsiv Mar 29, 2023
c1f016d
P4 Runtime App read path performance improvement HLD. (#1255)
rhalstea Mar 29, 2023
c89a1a6
TSC Election Process (#1301)
bhagatgit Mar 29, 2023
074b1f9
Delete config_reload duplicate image to fix `git clone` (#1302)
mdanish-kh Mar 30, 2023
931a1ed
[dualtor][active-active] Add doc for show command (#1304)
lolyu Mar 30, 2023
8f51c93
Dell S6000 platform build image update (#1313)
kannankvs Apr 5, 2023
7d64a8f
Updated the new member (#1314)
kannankvs Apr 5, 2023
6051d1a
Expected output for transceiver DOM CLI (#1306)
mihirpat1 Apr 6, 2023
020a60f
[dualtor][active-active] Add `config mux mode` section (#1319)
lolyu Apr 11, 2023
1e2e15a
Move tx_disable/tx_disabled_channel to TRANSCEIVER_STATUS table (#1316)
longhuan-cisco Apr 11, 2023
33613b7
Update static DNS HLD with minigraph changes (#1322)
oleksandrivantsiv Apr 13, 2023
9057607
Merge branch 'master' into reset_factory_hld
liat-grozovik Apr 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 202 additions & 0 deletions doc/reset_factory/ResetFactoryHLD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
# Reset Factory design #

## 1. Table of Content


* 1. [Table of Content](#TableofContent)
* 1.1. [Revision](#Revision)
* 1.2. [Scope](#Scope)
* 1.3. [Definitions/Abbreviations](#DefinitionsAbbreviations)
* 1.4. [Overview](#Overview)
* 1.5. [Requirements](#Requirements)
* 1.5.1. [Functional requirements](#FunctionalRequirements)
* 1.5.2. [Configuration and Management Requirements](#ConfigurationManagementRequirements)
* 2. [Design](#Design)
* 2.1. [High-Level Design](#High-LevelDesign)
* 3. [Functionality](#Functionality)
* 3.1. [Reset-Factory](#Reset-Factory)
* 3.2. [Config-setup Factory](#Config-setup-Factory)
* 4. [CLI](#CLI)
* 5. [Restrictions/Limitations](#RestrictionsLimitations)
* 6. [Test Plan](#TestPlan)
* 6.1. [Unit Test cases](#UnitTestcases)



### 1.1. Revision
| Rev | Date | Author | Change Description |
| :---: | :-----: | :--------------: | ------------------ |
| 0.1 | 01/2023 | Mohammed Zayadna | Phase 1 Design |

### 1.2. <a name='Scope'></a>Scope

This HLD document described the requirements, architecture details of Reset factory feature in switches Sonic OS based.

### 1.3. <a name='DefinitionsAbbreviations'></a>Definitions/Abbreviations
N/A


### 1.4. <a name='Overview'></a>Overview

A factory reset is a process that restores the switch to its original manufacturer settings. This can be useful if the device's configuration has become corrupt or if the user wishes to erase all personalized configurations.


### 1.5. <a name='Requirements'></a>Requirements
#### 1.5.1. <a name='FunctionalRequirements'></a>Functional requirements
1. It should support resetting configuration to factory default settings.

2. It should clear logs and tech-support files, users history files and home directories.

3. It should reboot the system to load and apply the new configuration.

4. It should stop sonic.target to ensure that files are not deleted while other daemons are utilizing them.

5. it should allow users/application to create their own factory default configurations or
extend the reset factory functionality.


#### 1.5.2. <a name='ConfigurationManagementRequirements'></a>Configuration and Management Requirements
We will create a command line tool /usr/bin/reset-factory which should provide following functionality:

1. default: reset configurations to factory default, clear all system logs and files.
Mohammedz93 marked this conversation as resolved.
Show resolved Hide resolved

2. keep-basic: preserves basic configurations only after boot. Logs and files will be deleted.

3. keep-all-config: preserves all configurations after boot. Logs and files will be deleted.

4. only-config: reset configurations to factory default. Logs and files will be preserved.


## 2 <a name='Design'></a>Design

### 2.1 <a name='High-LevelDesign'></a>High-Level Design
![diagram](diagram.png)

(flow description in the chapter below)

"reset-factory" script will create new config_db.json if needed using "config-setup factory" command.<br/>
In addition, it will clear system logs and files.<br/>

Steps:

1. Stops sonic.target:

systemctl stop sonic.target

2. If not "keep-all-config":

config-setup factory <None/keep-basic/only-config>

3. If not ("only-config" or “keep-basic”):

* Delete bash , vim and python history files under "/home".
Mohammedz93 marked this conversation as resolved.
Show resolved Hide resolved
* Delete any non-dotfiles in the home directories.

4. If not "only-config":
* Delete tech-support files under "/var/dump/"
* Delete all files under "/var/log"

5. Print to /var/log/systemlog:
New log file that won't be cleared in reset-factory.
It will allow user to track operations such as "reset-factory".

5. Reboot


## 3 <a name='Functionality'></a>Functionality
### 3.1 <a name='Reset-Factory'></a>Reset-Factory

##### Default
It will generate the default config_db.json file by running command:<br/>
config-setup factory<br/>
It will clear system logs and files.

##### Keep-basic

It will keep only basic configurations from the current “config_db.json”.<br/>
Command: config-setup factory keep-basic<br/>
It will clear system logs and files.<br/>

##### Keep-all-config
It will keep the same configuration but will clear system logs and files.

##### Only-config
It will generate the default config_db.json file by running command:<br/>
config-setup factory only-config<br/>
It won't clear system logs and files.

### 3.2 <a name='Config-SetupFactory'></a>Config-setup Factory

config-setup script provides the functionality of creating factory default configuration on demand.<br/>
Currently it generates new config_db.json file using:<br/>
```
sonic-cfggen -H -k ${HW_KEY} --preset ${DEFAULT_PRESET}
```

Also, it allows the user to extend/replace the functionality by adding hooks to the config-setup directory.

We will extend config-setup factory to support two new parameters (Keep-basic and Only-config).
We will pass the parameter to the hook script so user can extend/replace those flows also.

##### Keep-basic

It will filter current “config_db.json” according to a predefined template file:<br/>
/usr/share/sonic/templates/keep-basic.json.j2<br/>
It will keep the following tables:<br/>
DEVICE_METADATA, SSH_SERVER, PASSH, USER_MGMT, ROLE_MGMT, MGMT_PORT, MGMT_INTERFACE<br/>


##### Only-config
it will use the same default flow.

## 4 <a name='CLI'></a>CLI

#### reset-factory
```
==============================================================================
root@host:~$ sudo reset-factory --help
Usage: reset-factory < keep-all-config | only-config | keep-basic >

Create factory default configuration and save it to
to /etc/sonic/config_db.json.
Clears logs, system files and reboot the system.

keep-all-config - Preserves all configurations after boot. Logs and files will be deleted.
only-config - Reset configurations to factory default. Logs and files will be preserved.
keep-basic - Preserves basic configurations only after boot. Logs and files will be deleted.
==============================================================================
```

#### config-setup factory
```
==============================================================================
root@host:~$ sudo config-setup factory --help
Usage: config-setup factory < only-config | keep-basic >

Create factory default configuration and save it to
to /etc/sonic/config_db.json.

only-config - Reset configurations to factory default.
keep-basic - Preserves basic configurations.
==============================================================================
```

### 5 <a name='RestrictionsLimitations'></a>Restrictions/Limitations
TBD


### 6 <a name='TestPlan'></a>Test Plan
#### 6.1 <a name='UnitTestcases'></a>Unit Test cases
###### Good flow
- Run reset-factory without parameters
- Run reset-factory with keep-all-config/only-config/keep-basic
- Run config-setup factory without parameters
- Run config-setup factory with only-config/keep-basic

###### Negative flow
- reset-factory failure
- config-setup factory failure




Binary file added doc/reset_factory/diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.