The current configuration is shown in the following figure:
[SW1]int g0/0/1
[SW1-GigabitEthernet0/0/1]
[SW1-GigabitEthernet0/0/1]dis this
#
interface GigabitEthernet0/0/1
port link-type trunk
undo port trunk allow-pass vlan 1
port trunk allow-pass vlan 2 to 4094
#
return
When the port link type needs to be modified or deleted, an error is reported Error: please update the default configuration
[SW1-GigabitEthernet0/0/1]
[SW1-GigabitEthernet0/0/1]port link-type access
Error: Please renew the default configurations.
[SW1-GigabitEthernet0/0/1]
[SW1-GigabitEthernet0/0/1]undo port link-type
Error: Please renew the default configurations.
Causes of occurrence
The reason for the error is that you have added the port to a VLAN, so you will report an error when changing or deleting it.
For example, if you want to delete “parent folder”, you have to delete “child folder” first. It means to delete it layer by layer. The same is true of Huawei’s configuration commands, which are undo level by level.
|--Parent Folder
|---- subfolder
Solution
To undo all commands except “port link type trunk”, you can change the link type or undo the command.
[SW1-GigabitEthernet0/0/1]dis this
#
interface GigabitEthernet0/0/1
port link-type trunk
undo port trunk allow-pass vlan 1
#
return
[SW1-GigabitEthernet0/0/1]
[SW1-GigabitEthernet0/0/1]undo port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/1]
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 1
[SW1-GigabitEthernet0/0/1]
[SW1-GigabitEthernet0/0/1]dis this
#
interface GigabitEthernet0/0/1
port link-type trunk
#
return
[SW1-GigabitEthernet0/0/1]
[SW1-GigabitEthernet0/0/1]undo port link-type
[SW1-GigabitEthernet0/0/1]
[SW1-GigabitEthernet0/0/1]dis this
#
interface GigabitEthernet0/0/1
#
return
Application scenario: you need to create a new version switching page in the Vue project, which is translated as versionswitch according to the Chinese name, so you build a versionswitch.vue. You find that errors have been reported all the time, and if you change the name to vesionchange.vue, no errors have been reported. After a search, it is found that components cannot be named with switch, nor can they be named with switchye mark>.
Different from Java, C/C + + and other languages, python does not provide switch/case statements, which makes me feel very strange. We can implement the switch/case statement in the following ways.
Use if elif… elif… Else to realize switch/case
You can use if elif… Elif.. else sequence to replace the switch/case statement, this is the easiest way to think of. However, with the increase of branches and frequent modification, this alternative method is not very good for debugging and maintenance.
Switch/case using dictionary
Switch/case can be realized by dictionary, which is easy to maintain and can reduce the amount of code. The following is the switch/case implementation using dictionary simulation:
Through the above example, it can be proved that the switch/case statement can be fully implemented through Python dictionary, and it is flexible enough. especially at runtime, it is convenient to add or delete a switch/case option in the dictionary.
Switch/case can be implemented by using scheduling method in class
If you are not sure which method to use in a class, you can use a scheduling method to determine it at run time. The code is as follows:
It struck me as odd that, unlike languages such as Java, C\C++, Switch /case statements are not available in Python. We can implement the switch/ Case statement in several ways.
Use the if… Elif… Elif… Else to realize the switch/case
You can use if… Elif… elif.. An else sequence instead of a switch/case statement is the easiest way to think about it. However, with more branches and frequent modifications, this alternative is not easy to debug and maintain.
Use a dictionary to implement switch/ Case
A dictionary can be used to implement switch/ Case in a way that is easy to maintain and reduces the amount of code. The following is a switch/ Case implementation using a dictionary simulation:
The above example shows that the Switch /case statement can be fully implemented with a Python dictionary, and is flexible enough. is especially handy at run time to add or remove a switch/case option from a dictionary.
Switch/Case can be implemented in a class using scheduling methods
If you are not sure which method to use in a class, you can use a scheduling method at run time to determine. The code is as follows:
A compiler, the compiler error error: jump to case label [- fpermissive], the error: crosses initialization of 'XXXX' </ code>, to simple combing the related content
I. Problem code
int main()
{
int test = 2;
switch(test)
{
case 1:
int i = 1;
cout << i;
break;
case 2:
cout << i;
break;
default:
cout << "error" << endl;
}
}
//test.cpp: In function 'int main()':
//test.cpp: error: jump to case label [-fpermissive]
// case 2:
// ^
//test.cpp: error: crosses initialization of 'int i'
// int b = 1;
//test.cpp: error: jump to case label [-fpermissive]
// default:
// ^
//test.cpp:11:8: error: crosses initialization of 'int i'
// int b = 1;
As can be seen from the above code, since there is no separate block in switch to qualify the declaration period of variable I, the scope of the variable is the initialization point to the end of switch. In this case, the compiler will report an error because we are not sure whether this variable will be used in other cases and whether it was initialized before it was used. For example, if test has a value of 2 and case 2 is executed directly, an undefined variable will cause an exception. This is a compiler error crosses initialization </ code>.
After inspection, it is found that the compiler will report an error no matter whether the other branches contain defined variables or not, as long as the variables are not braced in the case.
int main()
{
int test = 2;
switch(test)
{
case 1:
int i = 1;
cout << i;
break;
case 2:
cout << 3;
break;
default:
cout << "error" << endl;
}
}
//test.cpp: In function 'int main()':
//test.cpp: error: jump to case label [-fpermissive]
// case 2:
// ^
//test.cpp: error: crosses initialization of 'int i'
// int i = 1;
//test.cpp: error: jump to case label [-fpermissive]
// default:
// ^
//test.cpp: error: crosses initialization of 'int i'
// int i = 1;
The code of case 1 is enclosed with {}, and the scope of variable I is clearly set to avoid access by other cases
2. The scope of variable I is put outside the switch, and every case in the switch can be accessed
The
switch statement is a kind of goto statement, so goto has the same properties. The following goto statement will not be executed, variable I will definitely be defined, but will report the same error as above. This means that there can be no variables between goto and the tag. Variables must appear before the goto or after the tag.
int main()
{
if(0)
{
goto end;
}
int i = 1;
end:
cout << i;
}
//test.cpp: In function 'int main()':
//test.cpp error: jump to label 'end' [-fpermissive]
// end:
// ^
//test.cpp error: from here [-fpermissive]
// goto end;
// ^
//test.cpp: error: crosses initialization of 'int i'
// int i = 1;
In the above example, it is possible to initialize a variable before the goto tag or after the end tag
boot today found CentOS8.1 system can not boot!! I recall that I updated some system packages yesterday. At that time, the updated system was not restarted, and the updated system was not detected. It was an oversight!
take a closer look at the log and it turns out that the Switch Root is wrong, as shown below:
prompt error log generation, a simple look, want to get the U disk first, then follow up.
is inserted into the U disk, no device is detected, exit is performed, and sda is identified after repeated twice. As shown below:
then U disk mounted to/sysroot, prompt data to test with U disk,, FSCK detection, the log file/run/initramfs/rdsosreport. TXT is copied to the U disk, and then uninstall U disk. As shown below:
try manually mounting CentOS8 system disk to /sysroot and find the partition mount corresponding to CentOS8. As shown below:
then exit and the system starts normally! Fortunately, it’s not a big problem.
come in the system, think under the analysis of the cause, to fundamentally solve it…
open the log file rdsosreport.txt in the U disk, find the error fragment log analysis:
[ 79.300190] xxx systemd[1]: Reached target Switch Root.[ 79.300600] xxx systemd[1]: Starting Switch Root...[ 79.304948] xxx systemctl[2113]: Failed to switch root: Specified switch root path '/sysroot' does not seem to be an OS tree. os-release file is missing.[ 79.305456] xxx systemd[1]: initrd-switch-root.service: Main process exited, code=exited, status=1/FAILURE[ 79.305593] xxx systemd[1]: initrd-switch-root.service: Failed with result 'exit-code'.[ 79.305789] xxx systemd[1]: Failed to start Switch Root.[ 79.305811] xxx systemd[1]: initrd-switch-root.service: Triggering OnFailure= dependencies.[ 79.306342] xxx systemd[1]: Starting Setup Virtual Console...[ 79.364641] xxx systemd[1]: Started Setup Virtual Console.[ 79.365205] xxx systemd[1]: Started Emergency Shell.[ 79.365348] xxx systemd[1]: Reached target Emergency Mode.[ 79.380910] xxx systemd[1]: Received SIGRTMIN+21 from PID 1675 (plymouthd).
see the key record:
Failed to switch root: Specified switch root path '/sysroot' does not seem to be an OS tree. os-release file is missing.
because the root path was not mounted successfully, /sysroot had no content, and the os-release file was not found.
, can you imagine if the os-release file for the system is gone?Open the /etc/cenos-release file and find the content, that’s not the problem with this file!
to calmly analyze problems, to learn to analyze and solve problems, this ability is very important.
systematically study, master the knowledge of a field is very necessary. The idea and process of solving the problem depends on your understanding of the system!
note: this article is original and shall not be reproduced on any platform without permission. For reprint, contact the author ~