CN111221655A - Method and device for managing resources of OpenStack platform - Google Patents

Method and device for managing resources of OpenStack platform Download PDF

Info

Publication number
CN111221655A
CN111221655A CN202010016692.4A CN202010016692A CN111221655A CN 111221655 A CN111221655 A CN 111221655A CN 202010016692 A CN202010016692 A CN 202010016692A CN 111221655 A CN111221655 A CN 111221655A
Authority
CN
China
Prior art keywords
url
target
service
resource
target service
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010016692.4A
Other languages
Chinese (zh)
Other versions
CN111221655B (en
Inventor
葛丰增
蒋善坤
谢东
于昊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Huimao Electronic Port Co Ltd
Original Assignee
Shandong Huimao Electronic Port Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Huimao Electronic Port Co Ltd filed Critical Shandong Huimao Electronic Port Co Ltd
Priority to CN202010016692.4A priority Critical patent/CN111221655B/en
Publication of CN111221655A publication Critical patent/CN111221655A/en
Application granted granted Critical
Publication of CN111221655B publication Critical patent/CN111221655B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/30Authentication, i.e. establishing the identity or authorisation of security principals
    • G06F21/31User authentication
    • G06F21/33User authentication using certificates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • G06F9/5072Grid computing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0645Rental transactions; Leasing transactions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45587Isolation or security of virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/21Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/2141Access rights, e.g. capability lists, access control lists, access tables, access matrices
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention provides a method and a device for managing resources of an OpenStack platform, wherein the method comprises the following steps: determining a target service URL of a target service of the OpenStack platform; generating a resource URL (uniform resource locator) of a target resource aiming at the OpenStack platform according to the target service URL of the target service; generating an HTTP request aiming at the target resource according to the resource URL; and sending the HTTP request to the OpenStack platform. The invention provides a method and a device for managing resources of an OpenStack platform, which can more conveniently manage the resources of the OpenStack platform.

Description

Method and device for managing resources of OpenStack platform
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for managing resources of an OpenStack platform.
Background
The OpenStack platform provides a cloud computing management platform which is simple to implement, can be expanded in a large scale, is rich and has a unified standard. OpenStack is powerful, the project is complicated, the interface is numerous, and how to manage the resources of the OpenStack platform is a very important topic.
In the prior art, the management of resources of the OpenStack platform is mainly realized in a manual mode, and the operation is complex and very inconvenient.
Disclosure of Invention
The embodiment of the invention provides a method and a device for managing resources of an OpenStack platform, which can more conveniently manage the resources of the OpenStack platform.
In a first aspect, an embodiment of the present invention provides a method for managing resources of an OpenStack platform, including:
determining a target service URL (Uniform Resource Locator) of a target service of the OpenStack platform;
generating a resource URL (uniform resource locator) of a target resource aiming at the OpenStack platform according to the target service URL of the target service;
generating an HTTP (Hypertext transfer protocol) request aiming at the target resource according to the resource URL;
and sending the HTTP request to the OpenStack platform.
Alternatively,
the determining a target service URL of a target service of the OpenStack platform includes:
obtaining a service directory of the OpenStack platform, where the service directory includes at least one service URL of each service in at least one service in the OpenStack platform, where the at least one service URL of each service includes: a service URL serving each partition of the OpenStack platform;
determining at least one service URL of the target service from the service directory;
determining a service URL of the target service in a target partition from at least one service URL of the target service, wherein the target partition is a partition where a current tenant of the OpenStack platform is located;
and taking the service URL of the target service in the target partition as the target service URL.
Alternatively,
the generating a resource URL of a target resource for the OpenStack platform according to the target service URL of the target service includes:
a1: judging whether the target service URL contains the tenant identification of the current tenant, if so, executing the step A2, otherwise, executing the step A3;
a2: adding a resource identifier of a target resource which needs to be operated by the current tenant and information of target operation which needs to be performed on the target resource by the current tenant into the target service URL to generate the resource URL;
a3: adding the tenant identification of the current tenant into the target service URL, generating an intermediate URL, and executing A4;
a4: and adding the resource identifier of the target resource and the information of the target operation in the intermediate URL to generate the resource URL.
Alternatively,
the determining whether the target service URL includes the tenant identifier of the current tenant includes:
and judging whether the number of the '/' in the target service URL is smaller than a preset value, if so, determining that the target service URL does not contain the tenant identification of the current tenant, and otherwise, determining that the target service URL contains the tenant identification of the current tenant.
Alternatively,
the generating an HTTP request for the target resource according to the resource URL includes:
obtaining a token of the OpenStack platform;
creating an HTTP message header of the HTTP request;
building a request body of the HTTP request;
an entity that composes the HTTP request;
building a response entity of the HTTP request;
generating the HTTP request according to the resource URL, the token, the HTTP message header, the request body, the entity and the response entity.
In a second aspect, an embodiment of the present invention provides an apparatus for managing resources of an OpenStack platform, where the apparatus includes:
the determining module is used for determining a target service URL of a target service of the OpenStack platform;
a resource URL generating module, configured to generate a resource URL of a target resource for the OpenStack platform according to a target service URL of the target service;
the request generation module is used for generating an HTTP request aiming at the target resource according to the resource URL;
and the sending module is used for sending the HTTP request to the OpenStack platform.
Alternatively,
the determining module is configured to perform:
obtaining a service directory of the OpenStack platform, where the service directory includes at least one service URL of each service in at least one service in the OpenStack platform, where the at least one service URL of each service includes: a service URL serving each partition of the OpenStack platform;
determining at least one service URL of the target service from the service directory;
determining a service URL of the target service in a target partition from at least one service URL of the target service, wherein the target partition is a partition where a current tenant of the OpenStack platform is located;
and taking the service URL of the target service in the target partition as the target service URL.
Alternatively,
the resource URL generation module is used for executing:
a1: judging whether the target service URL contains the tenant identification of the current tenant, if so, executing the step A2, otherwise, executing the step A3;
a2: adding a resource identifier of a target resource which needs to be operated by the current tenant and information of target operation which needs to be performed on the target resource by the current tenant into the target service URL to generate the resource URL;
a3: adding the tenant identification of the current tenant into the target service URL, generating an intermediate URL, and executing A4;
a4: and adding the resource identifier of the target resource and the information of the target operation in the intermediate URL to generate the resource URL.
Alternatively,
the resource URL generation module, when executing the determination of whether the target service URL includes the tenant identifier of the current tenant, is specifically configured to:
and judging whether the number of the '/' in the target service URL is smaller than a preset value, if so, determining that the target service URL does not contain the tenant identification of the current tenant, and otherwise, determining that the target service URL contains the tenant identification of the current tenant.
Alternatively,
the request generation module is used for executing:
obtaining a token of the OpenStack platform;
creating an HTTP message header of the HTTP request;
building a request body of the HTTP request;
an entity that composes the HTTP request;
building a response entity of the HTTP request;
generating the HTTP request according to the resource URL, the token, the HTTP message header, the request body, the entity and the response entity.
In the embodiment of the invention, the target service URL of the target service of the OpenStack platform can be automatically determined, the resource URL can be automatically generated, and further the HTTP request can be automatically generated.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flowchart of a method for managing resources of an OpenStack platform according to an embodiment of the present invention;
FIG. 2 is a flowchart of another method for managing resources of an OpenStack platform according to an embodiment of the present invention;
fig. 3 is a schematic diagram of an apparatus for managing resources of an OpenStack platform according to an embodiment of the present invention.
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.
The OpenStack platform is an open-source cloud computing management platform project, and free software and an open source code project are authorized by an Apache license. The OpenStack platform is formed by combining several main components to complete specific work, and the core components comprise nova, swift, glance, keystone, neutron, circumferentially, horizons, ceilometer and the like. OpenStack supports almost all types of cloud environments, and the project aims to provide a cloud computing management platform which is simple to implement, can be expanded in a large scale, is rich and has a unified standard.
Some basic concepts of OpenStack:
user: the so-called User stands for somebody or something who is able to gain access through a keystone. The User accesses the service through its own credentials, such as username & password or api keys.
Tenant: tenant, a Tenant, represents a project in nova, and is capable of aggregating some resources in some services. For example, a tent can have some virtual machines in nova, some images in gland, some networks in quantum, users bound to a certain tent by default.
Role: representing a group of users that have some degree of access to the resource. For example, access to vms in nova, images in gland. Users can be added to all tents or to a certain tent. The user has obtained the right to access the resource obtained for the corresponding role in the corresponding tennt.
service: services of a certain type, e.g. nova, quantum, gland, etc., are all services
endPoint-the entry point to access the service, an http path.
A scanned token: after the accessible tents are obtained, and a decision is made to access a certain tents, a scanned token is needed to be obtained, the scanned token is bound with a specific tent, and metadata of the tent and roles in the tents can be provided.
As shown in fig. 1, an embodiment of the present invention provides a method for managing resources of an OpenStack platform, including:
step 101: determining a target service URL of a target service of the OpenStack platform;
step 102: generating a resource URL (uniform resource locator) of a target resource aiming at the OpenStack platform according to the target service URL of the target service;
step 103: generating an HTTP request aiming at the target resource according to the resource URL;
step 104: and sending the HTTP request to the OpenStack platform.
In the embodiment of the invention, the target service URL of the target service of the OpenStack platform can be automatically determined, the resource URL can be automatically generated, and further the HTTP request can be automatically generated.
In an embodiment of the present invention, the determining a target service URL of a target service of an OpenStack platform includes:
obtaining a service directory of the OpenStack platform, where the service directory includes at least one service URL of each service in at least one service in the OpenStack platform, where the at least one service URL of each service includes: a service URL serving each partition of the OpenStack platform;
determining at least one service URL of the target service from the service directory;
determining a service URL of the target service in a target partition from at least one service URL of the target service, wherein the target partition is a partition where a current tenant of the OpenStack platform is located;
and taking the service URL of the target service in the target partition as the target service URL.
In the embodiment of the present invention, the OpenStack platform is divided into multiple partitions, for example: southern zoning, northern zoning, and the like. Each service has a corresponding service URL in each partition, and the service URLs for the same service are different in different partitions. Therefore, when determining the target service URL of the target service, the determination needs to be based on the partition where the current tenant is located. For example: and if the current tenant belongs to the south partition, the service URL of the target service in the south partition is taken as the target service URL.
In the embodiment of the present invention, the service directory may be obtained by the following codes: list <? An extensions Service > serviceCatalog ═ os. Wherein, the serviceCatalog is a service catalog.
In the embodiment of the present invention, when determining at least one service URL of a target service, the following may be implemented: and traversing the service directory, acquiring the pointList according to the name and the type of the required service, traversing the pointList, and determining the target service URL of the target service in the target partition according to the target partition where the current tenant is located. Wherein, the pointList contains the service URLs of all partitions of the target service. The service required here means a service for acquiring a pointList, and specifically, the pointList may be acquired by at least one of the following services: the server comprises an ironic service of baremetal, a place service of place, a neutron service of network, a cinderv3 service of volumev3, a manila service of share, a keystone service of identity, a cinderv2 service of volumev2, a manivac 2 service of share 2, a heat service of ordering, a brightness service of image, a radosgw-switch service of object-store and a nova service of computer.
Traversing the service directory, obtaining the pointList by the name and type of the required service, and can be realized by the following codes:
Figure BDA0002359157590000081
traversing pointList, determining a target service URL of a target service in a target partition according to the target partition where the current tenant is located, and can be realized by the following codes:
Figure BDA0002359157590000082
Figure BDA0002359157590000091
in an embodiment of the present invention, the generating a resource URL of a target resource for the OpenStack platform according to a target service URL of the target service includes:
a1: judging whether the target service URL contains the tenant identification of the current tenant, if so, executing the step A2, otherwise, executing the step A3;
a2: adding a resource identifier of a target resource which needs to be operated by the current tenant and information of target operation which needs to be performed on the target resource by the current tenant into the target service URL to generate the resource URL;
a3: adding the tenant identification of the current tenant into the target service URL, generating an intermediate URL, and executing A4;
a4: and adding the resource identifier of the target resource and the information of the target operation in the intermediate URL to generate the resource URL.
Due to the OpenStack platform version problem, the obtained target service URL may or may not include the tenant identity. If the operation path of the target resource of the OpenStack platform does not contain the tenant identification, the tenant identification cannot be used due to security problems, and therefore the tenant identification needs to be added into the operation path of the target resource of a user. The operation path here refers to an HTTP request for a target resource.
In the embodiment of the present invention, step a3 may be implemented by the following codes:
int num=url.split("/").length;
if(num==4){
url=url+"/"+projectid;
}
in addition, the tenant identity of the current tenant may be acquired by:
String projectid=os.getToken().getProject().getId()。
in the embodiment of the present invention, the resource Identifier refers to a resource uuid (universal Unique Identifier). The information of the target operation may be the name or code number of the target operation.
For example, the resource URL ═ target service URL + "/server/" + server _ id + "/action", where server _ id is the resource identification and "/action" is the information of the target operation.
In an embodiment of the present invention, the determining whether the target service URL includes the tenant identifier of the current tenant includes:
and judging whether the number of the '/' in the target service URL is smaller than a preset value, if so, determining that the target service URL does not contain the tenant identification of the current tenant, and otherwise, determining that the target service URL contains the tenant identification of the current tenant.
In the OpenStack platform, the format of the URL containing the tenant identity is:
https:// IP PORT/version/project ID; the format of the URL that does not contain the tenant identity is:
https:// IP PORT/version. It can be seen that the URL containing the tenant identity is added with "/project id", and the corresponding regular expressions are different, and in short, the number of "/" in the URL containing the tenant identity is different from that in the URL not containing the tenant identity. Therefore, whether the tenant identity is included in the target service URL can be determined according to the number of "/". Specifically, the preset value may be determined according to the number of "/" in the URL containing the tenant identity, for example: if the number of "/" in the URL containing the tenant identity is 4, the preset value is 4.
In an embodiment of the present invention, the generating an HTTP request for the target resource according to the resource URL includes:
obtaining a token of the OpenStack platform;
creating an HTTP message header of the HTTP request;
building a request body of the HTTP request;
an entity that composes the HTTP request;
building a response entity of the HTTP request;
generating the HTTP request according to the resource URL, the token, the HTTP message header, the request body, the entity and the response entity.
In this embodiment of the present invention, generating a token for an OpenStack platform may be implemented by the following codes:
token=os.getToken().getId()。
in the embodiment of the present invention, the HTTP message header for constructing the HTTP request may be implemented by the following codes:
org.springframework.http.HttpHeaders headers
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
headers.set("X-Auth-Token",token)。
in the embodiment of the present invention, the requesting entity for constructing the HTTP request may be implemented by the following codes:
Map<String,Object>body=new HashMap<>();
body.put("testName","testValue")。
in this embodiment of the present invention, the entity that composes the HTTP request may be implemented by the following codes:
HttpEntity<Map<String,Object>>requestEntity=new HttpEntity<>(body,headers);
if the HTTP Method does not require a body, the body may be null.
In this embodiment of the present invention, the response entity for constructing the HTTP request may be implemented by the following codes:
ResponseEntity < TestResponse > ResponseEntity. In addition, the code can also realize that: a possible returned body class TestResponse is confirmed.
In the embodiment of the present invention, sending an HTTP request to an OpenStack platform may be implemented by the following codes:
import org.springframework.web.client.RestTemplate;
RestTemplate rest=new RestTemplate();
responseEntity=rest.exchange(url,HttpMethod.GET,requestEntity,TestResponse.class)。
as shown in fig. 2, an embodiment of the present invention provides a method for managing resources of an OpenStack platform, including the following steps:
step 201: and acquiring a service directory of the OpenStack platform.
The service directory includes at least one service URL of each service in at least one service in the OpenStack platform, where the at least one service URL of each service includes: service URLs that serve each partition of the OpenStack platform.
Before obtaining the service directory of the OpenStack platform, the method may further include:
confirming an OpenStack platform deployment node IP to be connected, a partition where a current tenant is located, a tenant identification (specifically, the tenant identification can be a tenant name), and nscapedToken for identity verification of the tenant.
Step 202: at least one service URL of the target service is determined from the service directory.
Step 203: and determining a service URL of the target service in a target partition from at least one service URL of the target service, wherein the target partition is a partition where a current tenant of the OpenStack platform is located.
Step 204: and taking the service URL of the target service in the target partition as the target service URL.
Step 205: and judging whether the target service URL contains the tenant identification of the current tenant, if so, executing the step 206, otherwise, executing the step 207.
Step 206: adding the resource identifier of the target resource which needs to be operated by the current tenant and the information of the target operation which needs to be performed on the target resource by the current tenant into the target service URL, generating a resource URL, and executing step 209.
Step 207: and adding the tenant identification of the current tenant into the target service URL to generate an intermediate URL.
Step 208: and adding the resource identifier of the target resource and the information of the target operation in the intermediate URL to generate a resource URL, and executing step 209.
Step 209: token for obtaining OpenStack platform
Step 210: the HTTP message header of the HTTP request is established, the request body of the HTTP request is established, the entity of the HTTP request is established, and the response entity of the HTTP request is established.
Step 211: and generating the HTTP request according to the resource URL, the token, the HTTP message header, the request body, the entity and the response entity.
Step 212: and sending the HTTP request to an OpenStack platform.
The method for managing the resources of the OpenStack platform provided by the embodiment of the invention can automatically acquire the URL, increases the integrity of codes, reduces the redundancy, can reduce the error probability when the URL is acquired manually, and saves the time and the labor cost.
As shown in fig. 3, an embodiment of the present invention provides an apparatus for managing resources of an OpenStack platform, including:
a determining module 301, configured to determine a target service URL of a target service of an OpenStack platform;
a resource URL generating module 302, configured to generate a resource URL of a target resource for the OpenStack platform according to a target service URL of the target service;
a request generating module 303, configured to generate an HTTP request for the target resource according to the resource URL;
a sending module 304, configured to send the HTTP request to the OpenStack platform.
In an embodiment of the present invention, the determining module is configured to perform:
obtaining a service directory of the OpenStack platform, where the service directory includes at least one service URL of each service in at least one service in the OpenStack platform, where the at least one service URL of each service includes: a service URL serving each partition of the OpenStack platform;
determining at least one service URL of the target service from the service directory;
determining a service URL of the target service in a target partition from at least one service URL of the target service, wherein the target partition is a partition where a current tenant of the OpenStack platform is located;
and taking the service URL of the target service in the target partition as the target service URL.
In an embodiment of the present invention, the resource URL generation module is configured to execute:
a1: judging whether the target service URL contains the tenant identification of the current tenant, if so, executing the step A2, otherwise, executing the step A3;
a2: adding a resource identifier of a target resource which needs to be operated by the current tenant and information of target operation which needs to be performed on the target resource by the current tenant into the target service URL to generate the resource URL;
a3: adding the tenant identification of the current tenant into the target service URL, generating an intermediate URL, and executing A4;
a4: and adding the resource identifier of the target resource and the information of the target operation in the intermediate URL to generate the resource URL.
In an embodiment of the present invention, when the determining whether the target service URL includes the tenant identifier of the current tenant is performed, the resource URL generating module is specifically configured to:
and judging whether the number of the '/' in the target service URL is smaller than a preset value, if so, determining that the target service URL does not contain the tenant identification of the current tenant, and otherwise, determining that the target service URL contains the tenant identification of the current tenant.
In an embodiment of the present invention, the request generating module is configured to perform:
obtaining a token of the OpenStack platform;
creating an HTTP message header of the HTTP request;
building a request body of the HTTP request;
an entity that composes the HTTP request;
building a response entity of the HTTP request;
generating the HTTP request according to the resource URL, the token, the HTTP message header, the request body, the entity and the response entity.
The method and the device for managing the resources of the OpenStack platform provided by the embodiment of the invention can be realized through OpenStack4j. The simple and fluid API and intelligent error handling provided by OpenStack4j will make management of OpenStack simple and robust and reduce error rates.
OpenStack4j is an open source OpenStack client, i.e., a class library, that provides java apis for accessing and managing OpenStack. Client applications of OpenStack can be developed quickly using OpenStack4j.
OpenStack4j allows configuration and control of the OpenStack system, and abstracts several categories as follows: ientity V2, Identity V3, computer, Image, Network, Block Storage, Object Storage, Telemetry, organization, etc. It provides 100% streaming API. This includes support for identity, computation, images, networks, block storage, telemetry, data processing, and many extensions (lbaas, fwaas, quota sets, etc.).
Specifically, the method and the device for managing resources of an OpenStack platform provided in the embodiment of the present invention may be implemented by an oscientv 3, where oscientv 3 is a client of OpenStack4j.
OSClientV3 may be implemented by the following code:
introducing a package org, opentagck 4j, api, OSClient, OSClientV3;
Config config=Config.newConfig().withSSLVerificationDisabled();
OSClientV3 os=((IOSClientBuilder.V3)((IOSClientBuilder.V3)
((IOSClientBuilder.V3)OSFactory.builderV3()
.endpoint("https://"+IP+":"+"5000"+"/v3"))
.withConfig(config)).perspective(Facing.PUBLIC))
.scopeToProject(Identifier.byName(projectName),Identifier.byName("Default"))
.token(unscopedToken)
.authenticate().useRegion(regionName);
it should be understood that the illustrated structure of the embodiment of the present invention does not form a specific limitation on the device for managing resources of the OpenStack platform. In further embodiments of the invention, the means for managing resources of the OpenStack platform may comprise more or fewer components than shown, or combine certain components, or split certain components, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Because the information interaction, execution process, and other contents between the units in the device 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.
The present invention also provides a computer readable medium storing instructions for causing a computer to perform the method of managing resources of an OpenStack platform as described herein. Specifically, a system or an apparatus equipped with a storage medium on which software program codes that realize the functions of any of the above-described embodiments are stored may be provided, and a computer (or a CPU or MPU) of the system or the apparatus is caused to read out and execute the program codes stored in the storage medium.
In this case, the program code itself read from the storage medium can realize the functions of any of the above-described embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
Examples of the storage medium for supplying the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (e.g., CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD + RW), a magnetic tape, a nonvolatile memory card, and a ROM. Alternatively, the program code may be downloaded from a server computer via a communications network.
Further, it should be clear that the functions of any one of the above-described embodiments may be implemented not only by executing the program code read out by the computer, but also by causing an operating system or the like operating on the computer to perform a part or all of the actual operations based on instructions of the program code.
Further, it is to be understood that the program code read out from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion unit connected to the computer, and then causes a CPU or the like mounted on the expansion board or the expansion unit to perform part or all of the actual operations based on instructions of the program code, thereby realizing the functions of any of the above-described embodiments.
It should be noted that not all steps and modules in the above flows and system structure diagrams are necessary, and some steps or modules may be omitted according to actual needs. The execution order of the steps is not fixed and can be adjusted as required. The system structure described in the above embodiments may be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by a plurality of physical entities, or some components in a plurality of independent devices may be implemented together.
In the above embodiments, the hardware unit may be implemented mechanically or electrically. For example, a hardware element may comprise permanently dedicated circuitry or logic (such as a dedicated processor, FPGA or ASIC) to perform the corresponding operations. The hardware elements may also comprise programmable logic or circuitry, such as a general purpose processor or other programmable processor, that may be temporarily configured by software to perform the corresponding operations. The specific implementation (mechanical, or dedicated permanent, or temporarily set) may be determined based on cost and time considerations.
While the invention has been shown and described in detail in the drawings and in the preferred embodiments, it is not intended to limit the invention to the embodiments disclosed, and it will be apparent to those skilled in the art that various combinations of the code auditing means in the various embodiments described above may be used to obtain further embodiments of the invention, which are also within the scope of the invention.

Claims (10)

1. The method for managing resources of the OpenStack platform is characterized by comprising the following steps:
determining a target service Uniform Resource Locator (URL) of a target service of an OpenStack platform;
generating a resource URL (uniform resource locator) of a target resource aiming at the OpenStack platform according to the target service URL of the target service;
generating a hypertext transfer protocol (HTTP) request aiming at the target resource according to the resource URL;
and sending the HTTP request to the OpenStack platform.
2. The method of claim 1,
the determining a target service URL of a target service of the OpenStack platform includes:
obtaining a service directory of the OpenStack platform, where the service directory includes at least one service URL of each service in at least one service in the OpenStack platform, where the at least one service URL of each service includes: a service URL serving each partition of the OpenStack platform;
determining at least one service URL of the target service from the service directory;
determining a service URL of the target service in a target partition from at least one service URL of the target service, wherein the target partition is a partition where a current tenant of the OpenStack platform is located;
and taking the service URL of the target service in the target partition as the target service URL.
3. The method of claim 1,
the generating a resource URL of a target resource for the OpenStack platform according to the target service URL of the target service includes:
a1: judging whether the target service URL contains the tenant identification of the current tenant, if so, executing the step A2, otherwise, executing the step A3;
a2: adding a resource identifier of a target resource which needs to be operated by the current tenant and information of target operation which needs to be performed on the target resource by the current tenant into the target service URL to generate the resource URL;
a3: adding the tenant identification of the current tenant into the target service URL, generating an intermediate URL, and executing A4;
a4: and adding the resource identifier of the target resource and the information of the target operation in the intermediate URL to generate the resource URL.
4. The method of claim 3,
the determining whether the target service URL includes the tenant identifier of the current tenant includes:
and judging whether the number of the '/' in the target service URL is smaller than a preset value, if so, determining that the target service URL does not contain the tenant identification of the current tenant, and otherwise, determining that the target service URL contains the tenant identification of the current tenant.
5. The method according to any one of claims 1 to 4,
the generating an HTTP request for the target resource according to the resource URL includes:
obtaining a token of the OpenStack platform;
creating an HTTP message header of the HTTP request;
building a request body of the HTTP request;
an entity that composes the HTTP request;
building a response entity of the HTTP request;
generating the HTTP request according to the resource URL, the token, the HTTP message header, the request body, the entity and the response entity.
6. An apparatus for managing resources of an OpenStack platform, comprising:
the determining module is used for determining a target service Uniform Resource Locator (URL) of a target service of the OpenStack platform;
a resource URL generating module, configured to generate a resource URL of a target resource for the OpenStack platform according to a target service URL of the target service;
the request generation module is used for generating a hypertext transfer protocol (HTTP) request aiming at the target resource according to the resource URL;
and the sending module is used for sending the HTTP request to the OpenStack platform.
7. The apparatus of claim 6,
the determining module is configured to perform:
obtaining a service directory of the OpenStack platform, where the service directory includes at least one service URL of each service in at least one service in the OpenStack platform, where the at least one service URL of each service includes: a service URL serving each partition of the OpenStack platform;
determining at least one service URL of the target service from the service directory;
determining a service URL of the target service in a target partition from at least one service URL of the target service, wherein the target partition is a partition where a current tenant of the OpenStack platform is located;
and taking the service URL of the target service in the target partition as the target service URL.
8. The apparatus of claim 6,
the resource URL generation module is used for executing:
a1: judging whether the target service URL contains the tenant identification of the current tenant, if so, executing the step A2, otherwise, executing the step A3;
a2: adding a resource identifier of a target resource which needs to be operated by the current tenant and information of target operation which needs to be performed on the target resource by the current tenant into the target service URL to generate the resource URL;
a3: adding the tenant identification of the current tenant into the target service URL, generating an intermediate URL, and executing A4;
a4: and adding the resource identifier of the target resource and the information of the target operation in the intermediate URL to generate the resource URL.
9. The apparatus of claim 8,
the resource URL generation module, when executing the determination of whether the target service URL includes the tenant identifier of the current tenant, is specifically configured to:
and judging whether the number of the '/' in the target service URL is smaller than a preset value, if so, determining that the target service URL does not contain the tenant identification of the current tenant, and otherwise, determining that the target service URL contains the tenant identification of the current tenant.
10. The apparatus according to any one of claims 6 to 9,
the request generation module is used for executing:
obtaining a token of the OpenStack platform;
creating an HTTP message header of the HTTP request;
building a request body of the HTTP request;
an entity that composes the HTTP request;
building a response entity of the HTTP request;
generating the HTTP request according to the resource URL, the token, the HTTP message header, the request body, the entity and the response entity.
CN202010016692.4A 2020-01-08 2020-01-08 Method and device for managing resources of OpenStack platform Active CN111221655B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010016692.4A CN111221655B (en) 2020-01-08 2020-01-08 Method and device for managing resources of OpenStack platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010016692.4A CN111221655B (en) 2020-01-08 2020-01-08 Method and device for managing resources of OpenStack platform

Publications (2)

Publication Number Publication Date
CN111221655A true CN111221655A (en) 2020-06-02
CN111221655B CN111221655B (en) 2023-04-07

Family

ID=70828173

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010016692.4A Active CN111221655B (en) 2020-01-08 2020-01-08 Method and device for managing resources of OpenStack platform

Country Status (1)

Country Link
CN (1) CN111221655B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111970286A (en) * 2020-08-21 2020-11-20 北京恒华伟业科技股份有限公司 User login method and device and web server
CN114265671A (en) * 2022-03-03 2022-04-01 浙江省邮电工程建设有限公司 Hybrid expansion method of virtual machine room

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107341044A (en) * 2017-07-13 2017-11-10 郑州云海信息技术有限公司 A kind of distributive data center unified monitoring framework and method
CN107463438A (en) * 2017-08-03 2017-12-12 郑州云海信息技术有限公司 Information processing method, device and system for more Openstack environment
CN107566493A (en) * 2017-09-06 2018-01-09 中国科学院信息工程研究所 A kind of agent node creation method, service means for acting as agent and system towards complicated user's request
CN108123996A (en) * 2016-11-18 2018-06-05 Sap欧洲公司 Application management service instance
CN109254831A (en) * 2018-09-06 2019-01-22 山东师范大学 Virtual machine network method for managing security based on cloud management platform

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108123996A (en) * 2016-11-18 2018-06-05 Sap欧洲公司 Application management service instance
CN107341044A (en) * 2017-07-13 2017-11-10 郑州云海信息技术有限公司 A kind of distributive data center unified monitoring framework and method
CN107463438A (en) * 2017-08-03 2017-12-12 郑州云海信息技术有限公司 Information processing method, device and system for more Openstack environment
CN107566493A (en) * 2017-09-06 2018-01-09 中国科学院信息工程研究所 A kind of agent node creation method, service means for acting as agent and system towards complicated user's request
CN109254831A (en) * 2018-09-06 2019-01-22 山东师范大学 Virtual machine network method for managing security based on cloud management platform

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
SDNLAB君: "OpenStack操作之Restful API", 《SDNLAB》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111970286A (en) * 2020-08-21 2020-11-20 北京恒华伟业科技股份有限公司 User login method and device and web server
CN114265671A (en) * 2022-03-03 2022-04-01 浙江省邮电工程建设有限公司 Hybrid expansion method of virtual machine room

Also Published As

Publication number Publication date
CN111221655B (en) 2023-04-07

Similar Documents

Publication Publication Date Title
US10419289B2 (en) System and method for configuration management service
US20190207812A1 (en) Hybrid cloud network configuration management
US10110631B2 (en) Introducing encryption, authentication, and authorization into a publication and subscription engine
US8321503B2 (en) Context-specific network resource addressing model for distributed services
TWI735429B (en) Authentication method, device, system and electronic equipment for client login server end
US10116642B2 (en) Identity management over multiple identity providers
WO2017016252A1 (en) Token generation and authentication method, and authentication server
CN104094554A (en) Implicit SSL certificate management without server name indication (SNI)
CN110580305B (en) Method, apparatus, system and medium for generating identifier
CN108287894B (en) Data processing method, device, computing equipment and storage medium
CN111221655B (en) Method and device for managing resources of OpenStack platform
US20210092111A1 (en) Network traffic distribution using certificate scanning in agent-based architecture
WO2022108529A1 (en) Model construction method and apparatus, and medium and electronic device
CN111988418B (en) Data processing method, device, equipment and computer readable storage medium
WO2015074391A1 (en) Method and apparatus for mounting peripheral components on multiple virtual machines
US11522864B1 (en) Secure identity transfer
US10785056B1 (en) Sharing a subnet of a logically isolated network between client accounts of a provider network
CN111327680B (en) Authentication data synchronization method, device, system, computer equipment and storage medium
JP2015505626A (en) Integrate server applications with many authentication providers
CN112769863B (en) Method and device for processing service request message data, electronic equipment and readable storage medium
CN114969045A (en) Account creating method, Internet of things multi-tenant system, equipment, program and medium
JP6280471B2 (en) Connection management method, program, and connection management system
CN109189753B (en) Method and device for adding user information in HUE
Moore et al. Zest: Rest over zeromq
US20210136079A1 (en) Technology for computing resource liaison

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant