Disclosure of Invention
The embodiment of the invention provides a method and a device for adding user information in a HUE, which can synchronize the user information in an HDFS (Hadoop distributed File System) to the HUE.
In a first aspect, an embodiment of the present invention provides a method for adding user information in a HUE, including:
receiving an adding request for indicating that target user information is added in the HUE;
generating a user information file according to the adding request;
storing the user information file to a server where the HUE is located;
and calling a command of the HUE so as to add the target user information in the HUE according to the user information file stored in the server.
Optionally, the generating a user information file according to the addition request includes:
analyzing the adding request to obtain user name information, user affiliated grouping information and user password information;
respectively converting the user name information, the grouping information to which the user belongs and the user password information into JSON strings to obtain a user name information JSON string, a grouping information JSON string to which the user belongs and a user password information JSON string;
and storing the user name information JSON string, the grouping information JSON string to which the user belongs and the user password information JSON string into a JSON file to obtain the user information file.
Optionally, the invoking the command of the HUE to add the target user information in the HUE according to the user information file stored in the server includes:
calling a first shell command of the HUE to read the user information file from the server, and adding a target user in the HUE according to the user name information JSON string stored in the user information file;
calling a second shell command of the HUE to set a login password for the target user according to the user password information JSON string stored in the user information file;
and calling a third shell command of the HUE to set a group to which the target user belongs according to the group information JSON string to which the user belongs, which is stored in the user information file.
Optionally, after the third shell command invoking the HUE, further comprising:
and configuring operation authority for the target user according to the received authority configuration instruction.
Alternatively,
after the generating the user information file according to the addition request, further comprising: storing the user information file in a predefined target directory;
the storing the user information file to a server where the HUE is located includes: and calling a Python script to copy the user information file stored in the target directory to the server where the HUE is located.
In a second aspect, an embodiment of the present invention further provides an apparatus for adding user information in a HUE, including: the device comprises a request receiving unit, a file generating unit, a file unloading unit and an information adding unit;
the request receiving unit is used for receiving an adding request for indicating that target user information is added in the HUE;
the file generating unit is used for generating a user information file according to the adding request received by the request receiving unit;
the file unloading unit is used for storing the user information file generated by the file generating unit to a server where the HUE is located;
the information adding unit is used for calling a command of the HUE so as to add the target user information in the HUE according to the user information file stored in the server by the file unloading unit.
Optionally, the file generating unit includes: a file parsing subunit, a JSON string conversion subunit, and a JSON string storage subunit, wherein,
the file analysis subunit is used for analyzing the addition request to obtain user name information, user affiliated group information and user password information;
the JSON string conversion subunit is used for respectively converting the user name information, the grouping information to which the user belongs and the user password information which are analyzed by the file analysis subunit into JSON strings to obtain a user name information JSON string, a grouping information JSON string to which the user belongs and a user password information JSON string;
the JSON string storage subunit is configured to store the user name information JSON string converted by the JSON string conversion subunit, the group information JSON string to which the user belongs, and the user password information JSON string into a JSON file, so as to obtain the user information file.
Optionally, the information adding unit includes: a first command invoking subunit, a second command invoking subunit, and a third command invoking subunit, wherein,
the first command calling subunit is configured to call a first shell command of the HUE to read the user information file from the server, and add a target user to the HUE according to the user name information JSON string stored in the user information file;
the second command calling subunit is configured to call a second shell command of the HUE to set a login password for the target user according to the user password information JSON string stored in the user information file;
and the third command calling subunit is used for calling a third shell command of the HUE so as to set a group to which the target user belongs according to the group information JSON string to which the user belongs, which is stored in the user information file.
Optionally, the apparatus for adding user information in HUE further comprises: a right configuration unit;
and the authority configuration unit is used for configuring operation authority for the target user added in the HUE by the information adding unit according to the received authority configuration instruction.
Alternatively,
the file generating unit is further used for storing the generated user information file into a predefined target directory;
and the file dump unit is used for calling a Python script so as to copy the user information file stored in the target directory to the server where the HUE is located.
According to the method and the device for adding the user information into the HUE, provided by the embodiment of the invention, after the adding request for indicating the addition of the target user information into the HUE is received, the user information file is generated according to the adding request, the generated user information file is stored in the server where the HUE is located, and then the command of the HUE is called, so that the target user information is added into the HUE according to the called command and the user information file stored in the server. Therefore, after the user information in the HDFS is used as the target user information to send the corresponding adding request, the user information in the HDFS can be added into the HUE, the synchronization of the user information in the HUE and the user information in the HDFS is achieved, the user can normally manage the data in the HDFS through the HUE, and the user is guaranteed to have good using experience.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer and more complete, the technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention, and based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without creative efforts belong to the scope of the present invention.
As shown in fig. 1, an embodiment of the present invention provides a method for adding user information in a HUE, where the method may include the following steps:
step 101: receiving an adding request for indicating that target user information is added in the HUE;
step 102: generating a user information file according to the adding request;
step 103: storing the user information file to a server where the HUE is located;
step 104: and calling a command of the HUE to add the target user information in the HUE according to the user information file stored in the server.
According to the method for adding the user information in the HUE, after an adding request for indicating that the target user information is added to the HUE is received, a user information file is generated according to the adding request, the generated user information file is stored in a server where the HUE is located, and then a command of the HUE is called, so that the target user information is added to the HUE according to the user information file stored in the server through the called command. Therefore, after the user information in the HDFS is used as the target user information to send the corresponding adding request, the user information in the HDFS can be added into the HUE, the synchronization of the user information in the HUE and the user information in the HDFS is achieved, the user can normally manage the data in the HDFS through the HUE, and the user is guaranteed to have good using experience.
Optionally, on the basis of the method for adding user information in HUE shown in fig. 1, step 102 generates a user information file according to the received addition request, and as shown in fig. 2, this step may be specifically implemented by the following sub-steps:
step 201: analyzing the adding request to obtain user name information, user affiliated grouping information and user password information;
step 202: converting the user name information, the grouping information to which the user belongs and the user password information into JSON strings respectively to obtain corresponding JSON strings of the user name information, the grouping information to which the user belongs and the JSON strings of the user password information;
step 203: and storing the acquired user name information JSON string, the grouping information JSON string to which the user belongs and the user password information JSON string into a JSON file to obtain a user information file.
The received adding request carries information such as a user name, a user belonging group, a user password and the like, the information carried by the adding request is converted into a user name information JSON string, a user belonging group information JSON string, a user password information JSON string and the like to be stored in a JSON file, and then the JSON file in which the user name information JSON string, the user belonging group information JSON string and the user password information JSON string are stored is determined as a user information file. Wherein, the suffix of the JSON file is JSON.
Firstly, JSON strings such as a user name information JSON string, a grouping information JSON string to which a user belongs, a user password information JSON string and the like are stored in a user information file, the user name, the grouping to which the user belongs and the user password can be determined according to the user name information JSON string, the grouping information JSON string to which the user belongs and the user password information JSON string, the user name, the grouping to which the user belongs and the user login password can be set when user information is added into the HUE according to the user information file, and the user can normally log in and manage data after the user information is added into the HUE.
Secondly, because the JSON string is a lightweight data exchange format, the user name information, the grouping information to which the user belongs and the user password information are converted into corresponding JSON strings, and the converted JSON strings are stored in a JSON file to serve as a user information file, so that the called command of the HUE can identify the information stored in the user information file, the command of the HUE can be ensured to smoothly add the user information in the HUE according to the user information file, and the implementability of the user information adding method can be further ensured.
Alternatively, on the basis of the method for generating the user information file according to the addition request shown in fig. 2, as shown in fig. 3, the process of adding the target user information in the HUE in step 104 by calling the command of the HUE may be specifically realized by the following sub-steps:
step 301: calling a first shell command of the HUE to read a user information file from the server, and adding a target user in the HUE according to a user name information JSON string stored in the user information file;
step 302: calling a second shell command of the HUE to set a login password for the target user according to the user password information JSON string stored in the user information file;
step 303: and calling a third shell command of the HUE to set a belonged group for the target user according to the belonged group information JSON string of the user stored in the user information file.
After the user information file is stored in a server where the HUE is located, a first shell command of the HUE is called firstly, a target user is added into the HUE according to a user name information JSON string stored in the user information file on the server, then a second shell command of the HUE is called, a login password is set for the target user which is just added according to a user password information JSON string stored in the user information file, and then a third shell command of the HUE is called, so that a group which the user belongs to is set for the target user which is just added according to a group information JSON string which the user belongs to and is stored in the user information file. And the first shell command, the second shell command and the third shell command are all default commands of the HUE.
By calling the shell command of the HUE, target users are added in the HUE according to the user name information JSON string, the user password information JSON string and the user belonging grouping information JSON string stored in the user information file, a login password and a belonging grouping are set for the added target users, and then the users can log in on the HUE through the user names and the login passwords, so that data are managed. The process of adding the target user, setting the login password and the belonged group is realized by calling the shell command, manual operation is not needed, and convenience of adding user information in the HUE is improved.
Optionally, on the basis of the method shown in fig. 3, which is implemented by calling a shell command of the HUE to add user information to the HUE, after the group to which the target user belongs is set by calling a third shell command in step 303, the operation right may be further configured for the target user according to the received right configuration instruction.
Add target user in HUE to after setting up login password and affiliated group for target user, further can configure operation authority for target user, with the operation of logging in after the HUE to the user carries out the management and control, guarantee the security through the data that the HUE managed.
In the embodiment of the invention, the authority configuration instruction can be sent by the user independently, and can also be acquired from the user information file, and the specific mode for acquiring the authority configuration instruction can be flexibly determined according to the requirements of service implementation. In addition, the operation authority configured for the target user specifically means the operation authority of Apache allocated for the user.
Alternatively, on the basis of the method for adding user information in the HUE shown in fig. 1, after the user information file is generated according to the addition request in step 102, the generated user information file may be stored in a predefined target directory. Correspondingly, when the user information file is stored in the server where the HUE is located in step 103, the user information file stored in the target directory may be copied to the server where the HUE is located by calling the Python script.
After the generated user information file is stored in a predefined target directory, the self-realized Python script is called, so that the server where the HUE is located for copying the user information file stored in the target directory can be stored, the user information file does not need to be stored in the server where the HUE is located in a manual operation mode, and the process of adding the user information on the HUE is more convenient.
Optionally, on the basis of the method for adding user information to the HUE provided in each of the above embodiments, after the user information is added to the HUE, a monitoring audit may be performed on each piece of user information, that is, an operation performed by the user corresponding to each piece of user information through the HUE is monitored, so as to facilitate tracing of illegal operations of the user, which is beneficial to improving the security of the HUE.
The following describes in further detail the method for adding user information to a HUE provided in the embodiment of the present invention by combining the methods for adding user information to a HUE provided in the above embodiments, and as shown in fig. 4, the method may specifically include the following steps:
step 401: an addition request is received indicating to add target user information in the HUE.
In the embodiment of the present invention, an addition request sent by a user through a foreground is received, where the addition request is used to instruct to add target user information in the HUE, where the target user information may be information of one user or information of one user group, and one user group includes multiple users.
Step 402: and generating a user information file according to the adding request, and storing the generated user information file into a predefined target directory.
In the embodiment of the invention, the user name information, the grouping information to which the user belongs and the user password information carried by the adding request are obtained by analyzing the adding request, the user name information, the grouping information to which the user belongs and the user password information are converted into a user name information JSON string, a grouping information JSON string to which the user belongs and a user password information JSON string, the user name information JSON string, the grouping information JSON string to which the user belongs and the user password information JSON string are stored into a JSON file, and the JSON file in which the user name information JSON string, the grouping information JSON string to which the user belongs and the user password information JSON string are stored is used as the user information file. And finally, storing the obtained user information file into a predefined target directory.
Step 403: and judging whether the user information file is successfully stored in the target directory, if so, executing the step 404, and otherwise, executing the step 411.
In the embodiment of the present invention, if the user information file is successfully generated and the generated user information file is successfully stored in the predefined target directory, the following steps may be continued to add the user information to the HUE, and step 404 is executed accordingly, otherwise, the user information cannot be added to the HUE, and step 411 is executed accordingly.
Step 404: and copying the user information file to a server where the HUE is located.
In the embodiment of the invention, the self-realized Python script is called, and the user information file stored in the target directory is copied to the server where the HUE is located.
Step 405: and calling a first shell command of the HUE, and adding a target user in the HUE.
In the embodiment of the invention, the user information file is read from the server where the HUE is located by calling the first shell command of the HUE, and the target user is added in the HUE according to the user name information JSON string stored in the user information file.
Step 406: and judging whether the target user is successfully added into the HUE, if so, executing the step 407, otherwise, executing the step 411.
In the embodiment of the present invention, after the first shell command is invoked, it is determined whether the target user is successfully added to the HUE, if so, the step of subsequently adding user information may be continued, and step 407 is correspondingly performed, otherwise, the operation of adding user information to the HUE cannot be continued, and step 411 is correspondingly performed.
Step 407: and calling a second shell command of the HUE, and setting a login password for the target user.
In the embodiment of the invention, the second shell command of the HUE is called, and the login password is set for the added target user according to the user password information JSON string stored in the user information file.
Step 408: and judging whether the login password is successfully set for the target user, if so, executing the step 409, otherwise, executing the step 411.
In the embodiment of the present invention, after the second shell command is called, it is determined whether the login password is successfully set for the target user, if so, the step of subsequently adding the user information may be continued, and step 409 is correspondingly performed, otherwise, the operation of adding the user information to the HUE may not be continued, and step 411 is correspondingly performed.
Step 409: and calling a third shell command of the HUE to set the affiliated group for the target user.
In the embodiment of the invention, the second shell command of the HUE is called, and the added target user is set with the affiliated group according to the group information JSON string of the user, which is stored in the user information file.
Step 410: and judging whether the grouping belonging to the target user is successfully set, if so, executing a step 412, and otherwise, executing a step 411.
In the embodiment of the present invention, after the third shell command is invoked, it is determined whether the belonging group is successfully set for the target user, if so, it may be determined that the target user information has been successfully added to the HUE, and step 412 is executed accordingly, otherwise, it is determined that the addition of the target user information to the HUE fails, and step 411 is executed accordingly.
Step 411: and determining that the target user information is failed to be added into the HUE, and ending the current process.
Step 412: and determining that the target user information is successfully added to the HUE.
As shown in fig. 5 and 6, the embodiment of the present invention provides an apparatus for adding user information to a HUE. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. From a hardware level, as shown in fig. 5, a hardware structure diagram of a device where the apparatus for adding user information to the HUE provided in the embodiment of the present invention is located is shown, where the device in the embodiment may generally include other hardware, such as a forwarding chip responsible for processing a packet, in addition to the processor, the memory, the network interface, and the nonvolatile memory shown in fig. 5. Taking a software implementation as an example, as shown in fig. 6, as a logical apparatus, the apparatus is formed by reading, by a CPU of a device in which the apparatus is located, corresponding computer program instructions in a non-volatile memory into a memory for execution. The device for adding user information in the HUE provided by the embodiment comprises: a request receiving unit 601, a file generating unit 602, a file unloading unit 603, and an information adding unit 604;
a request receiving unit 601 configured to receive an addition request indicating that target user information is added in the HUE;
a file generating unit 602, configured to generate a user information file according to the addition request received by the request receiving unit 601;
a file dump unit 603, configured to store the user information file generated by the file generation unit 602 in the server where the HUE is located;
an information adding unit 604, configured to invoke a command of the HUE to add the target user information in the HUE according to the user information file stored in the server by the file dump unit 603.
Alternatively, on the basis of the apparatus for adding user information to the HUE shown in fig. 6, as shown in fig. 7, the file generating unit 602 includes: a file parsing subunit 6021, a JSON string conversion subunit 6022, and a JSON string storage subunit 6023, wherein,
a file analysis subunit 6021, configured to analyze the addition request to obtain user name information, group information to which the user belongs, and user password information;
a JSON string converting subunit 6022, configured to convert the user name information, the group information to which the user belongs, and the user password information, which are analyzed by the file analyzing subunit 6021, into JSON strings, respectively, and obtain a user name information JSON string, a group information JSON string to which the user belongs, and a user password information JSON string;
a JSON string storing subunit 6023, configured to store the user name information JSON string, the group information JSON string to which the user belongs, and the user password information JSON string converted by the JSON string converting subunit 6022 into a JSON file, so as to obtain a user information file.
Alternatively, in addition to the apparatus for adding user information in a HUE shown in fig. 7, as shown in fig. 8, the information adding unit 604 includes: a first command invoking sub-unit 6041, a second command invoking sub-unit 6042, and a third command invoking sub-unit 6043, wherein,
a first command calling subunit 6041, configured to call a first shell command of the HUE, so as to read the user information file from the server, and add a target user in the HUE according to the user name information JSON string stored in the user information file;
a second command calling subunit 6042, configured to call a second shell command of the HUE, so as to set a login password for the target user according to the user password information JSON string stored in the user information file;
and a third command invoking subunit 6043, configured to invoke a third shell command of the HUE, so as to set a belonging group for the target user according to the group information JSON string to which the user belongs, which is stored in the user information file.
Optionally, on the basis of the apparatus for adding user information to the HUE shown in fig. 8, as shown in fig. 9, the apparatus for adding user information to the HUE further comprises: a right configuration unit 605;
and an authority configuring unit 605, configured to configure an operation authority for the target user added in the HUE by the information adding unit 604 according to the received authority configuration instruction.
Optionally, on the basis of the apparatus for adding user information to a HUE provided in any one of fig. 6 to 9, the file generating unit 602 is further configured to store the generated user information file in a predefined target directory, and the file unloading unit 603 is configured to call a Python script to copy the user information file stored in the target directory to a server where the HUE is located.
It should be noted that, because the contents of information interaction, execution process, and the like between the units in the apparatus are based on the same concept as the method embodiment of the present invention, specific contents may refer to the description in the method embodiment of the present invention, and are not described herein again.
In addition, in the method and apparatus for adding user information to HUE provided in the foregoing embodiments, HUE refers to Apache HUE.
The embodiment of the present invention further provides a readable medium, which includes an execution instruction, and when a processor of a storage controller executes the execution instruction, the storage controller executes the method for adding user information in a HUE provided in the foregoing embodiments.
An embodiment of the present invention further provides a storage controller, including: a processor, a memory, and a bus;
the memory is used for storing execution instructions, the processor is connected with the memory through the bus, and when the memory controller runs, the processor executes the execution instructions stored in the memory, so that the memory controller executes the method for adding user information in the HUE provided by the above embodiments.
In summary, the method and apparatus for adding user information to HUE provided in the embodiments of the present invention at least have the following beneficial effects:
1. in the embodiment of the invention, after an adding request for indicating adding target user information into the HUE is received, a user information file is generated according to the adding request, the generated user information file is stored in a server where the HUE is located, and then a command of the HUE is called, so that the target user information is added into the HUE according to the user information file stored in the server through the called command. Therefore, after the user information in the HDFS is used as the target user information to send the corresponding adding request, the user information in the HDFS can be added into the HUE, the synchronization of the user information in the HUE and the user information in the HDFS is achieved, the user can normally manage the data in the HDFS through the HUE, and the user is guaranteed to have good using experience.
2. In the embodiment of the invention, a user can input the adding instruction through the operation interface so as to conveniently add the user information in the HUE, and the user information can be added to the HUE in real time according to the requirement, so that the convenience and timeliness of adding the user information in the HUE are improved.
3. In the embodiment of the invention, JSON strings such as a user name information JSON string, a user affiliated grouping information JSON string and a user password information JSON string are stored in the user information file, the user name, the user affiliated grouping and the user password can be determined according to the user name information JSON string, the user affiliated grouping information JSON string and the user password information JSON string, and then the user name, the user affiliated grouping and the user login password can be set when the user information is added into the HUE according to the user information file, so that the user can normally log in and manage data after the user information is added into the HUE.
4. In the embodiment of the invention, the JSON string is a lightweight data exchange format, the user name information, the grouping information to which the user belongs and the user password information are converted into the corresponding JSON string, and the converted JSON string is stored in the JSON file to be used as the user information file, so that the called command of the HUE can identify the information stored in the user information file, the command of the HUE can be ensured to smoothly add the user information in the HUE according to the user information file, and the implementability of the user information adding method can be ensured.
5. In the embodiment of the invention, a target user is added into the HUE by calling a shell command of the HUE according to the user name information JSON string, the user password information JSON string and the user belonging grouping information JSON string stored in the user information file, and a login password and a belonging grouping are set for the added target user, and then the user can log in on the HUE through the user name and the login password to further manage data. The process of adding the target user, setting the login password and the belonged group is realized by calling the shell command, manual operation is not needed, and convenience of adding user information in the HUE is improved.
6. In the embodiment of the present invention, after a target user is added to the HUE and a login password and an affiliated group are set for the target user, an operation authority may be further configured for the target user to manage and control the operation of the user after logging in the HUE, thereby ensuring the security of data managed by the HUE.
7. In the embodiment of the invention, after the generated user information file is stored in the predefined target directory, the self-realized Python script is called, so that the server where the HUE is located can be copied from the user information file stored in the target directory, and the user information file is not required to be stored in the server where the HUE is located in a manual operation mode, so that the process of adding the user information on the HUE is more convenient.
8. In the embodiment of the present invention, on the basis of the method for adding user information to a HUE provided in each of the above embodiments, after the user information is added to the HUE, a monitoring audit may be performed on each piece of user information, that is, an operation performed by a user corresponding to each piece of user information through the HUE is monitored, so as to facilitate tracing of illegal operations of the user, which is beneficial to improving the security of the HUE.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a" does not exclude the presence of other similar elements in a process, method, article, or apparatus that comprises the element.
Those of ordinary skill in the art will understand that: all or part of the steps for realizing the method embodiments can be completed by hardware related to program instructions, the program can be stored in a computer readable storage medium, and the program executes the steps comprising the method embodiments when executed; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it is to be noted that: the above description is only a preferred embodiment of the present invention, and is only used to illustrate the technical solutions of the present invention, and not to limit the protection scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.