-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor of openstack runner manager (#345)
* Add refactored RunnerManager which uses the CloudRunnerManager and GitHubRunnerManager. * Add CloudRunnerManager interface for managing the cloud side of runner instance. * Add OpenStackRunnerManager as a openstack implementation of the CloudRunnerManager. * Add GitHubRunnerManager for managing the GitHub side of runner instance.
- Loading branch information
Showing
29 changed files
with
3,210 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!-- markdownlint-disable --> | ||
|
||
<a href="../src/apis/managed_requests.py#L0"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
# <kbd>module</kbd> `managed_requests` | ||
Get configured requests session instance | ||
|
||
|
||
--- | ||
|
||
<a href="../src/apis/managed_requests.py#L10"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
## <kbd>function</kbd> `get_requests_session` | ||
|
||
```python | ||
get_requests_session(proxy: ProxyConfig) → Session | ||
``` | ||
|
||
Get managed requests session instance. | ||
|
||
|
||
|
||
**Args:** | ||
|
||
- <b>`proxy`</b>: HTTP proxy configurations. | ||
|
||
|
||
|
||
**Returns:** | ||
Requests session with proxy and retry setup. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,246 @@ | ||
<!-- markdownlint-disable --> | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L0"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
# <kbd>module</kbd> `openstack_cloud.openstack_cloud` | ||
Class for accessing OpenStack API for managing servers. | ||
|
||
|
||
|
||
--- | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L41"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
## <kbd>class</kbd> `OpenstackInstance` | ||
Represents an OpenStack instance. | ||
|
||
|
||
|
||
**Attributes:** | ||
|
||
- <b>`server_id`</b>: ID of server assigned by OpenStack. | ||
- <b>`server_name`</b>: Name of the server on OpenStack. | ||
- <b>`instance_id`</b>: ID used by OpenstackCloud class to manage the instances. See docs on the OpenstackCloud. | ||
- <b>`addresses`</b>: IP addresses assigned to the server. | ||
- <b>`status`</b>: Status of the server. | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L60"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
### <kbd>method</kbd> `__init__` | ||
|
||
```python | ||
__init__(server: Server, prefix: str) | ||
``` | ||
|
||
Construct the object. | ||
|
||
|
||
|
||
**Args:** | ||
|
||
- <b>`server`</b>: The OpenStack server. | ||
- <b>`prefix`</b>: The name prefix for the servers. | ||
|
||
|
||
|
||
**Raises:** | ||
|
||
- <b>`ValueError`</b>: Provided server should not be managed under this prefix. | ||
|
||
|
||
|
||
|
||
|
||
--- | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L126"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
## <kbd>class</kbd> `OpenstackCloud` | ||
Client to interact with OpenStack cloud. | ||
|
||
The OpenStack server name is managed by this cloud. Caller refers to the instances via instance_id. If the caller needs the server name, e.g., for logging, it can be queried with get_server_name. | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L134"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
### <kbd>method</kbd> `__init__` | ||
|
||
```python | ||
__init__(clouds_config: dict[str, dict], cloud: str, prefix: str) | ||
``` | ||
|
||
Create the object. | ||
|
||
|
||
|
||
**Args:** | ||
|
||
- <b>`clouds_config`</b>: The openstack clouds.yaml in dict format. | ||
- <b>`cloud`</b>: The name of cloud to use in the clouds.yaml. | ||
- <b>`prefix`</b>: Prefix attached to names of resource managed by this instance. Used for identifying which resource belongs to this instance. | ||
|
||
|
||
|
||
|
||
--- | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L335"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
### <kbd>method</kbd> `cleanup` | ||
|
||
```python | ||
cleanup() → None | ||
``` | ||
|
||
Cleanup unused key files and openstack keypairs. | ||
|
||
--- | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L224"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
### <kbd>method</kbd> `delete_instance` | ||
|
||
```python | ||
delete_instance(instance_id: str) → None | ||
``` | ||
|
||
Delete a openstack instance. | ||
|
||
|
||
|
||
**Args:** | ||
|
||
- <b>`instance_id`</b>: The instance ID of the instance to delete. | ||
|
||
--- | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L204"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
### <kbd>method</kbd> `get_instance` | ||
|
||
```python | ||
get_instance(instance_id: str) → OpenstackInstance | None | ||
``` | ||
|
||
Get OpenStack instance by instance ID. | ||
|
||
|
||
|
||
**Args:** | ||
|
||
- <b>`instance_id`</b>: The instance ID. | ||
|
||
|
||
|
||
**Returns:** | ||
The OpenStack instance if found. | ||
|
||
--- | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L312"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
### <kbd>method</kbd> `get_instances` | ||
|
||
```python | ||
get_instances() → tuple[OpenstackInstance, ] | ||
``` | ||
|
||
Get all OpenStack instances. | ||
|
||
|
||
|
||
**Returns:** | ||
The OpenStack instances. | ||
|
||
--- | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L345"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
### <kbd>method</kbd> `get_server_name` | ||
|
||
```python | ||
get_server_name(instance_id: str) → str | ||
``` | ||
|
||
Get server name on OpenStack. | ||
|
||
|
||
|
||
**Args:** | ||
|
||
- <b>`instance_id`</b>: ID used to identify a instance. | ||
|
||
|
||
|
||
**Returns:** | ||
The OpenStack server name. | ||
|
||
--- | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L259"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
### <kbd>method</kbd> `get_ssh_connection` | ||
|
||
```python | ||
get_ssh_connection(instance: OpenstackInstance) → Connection | ||
``` | ||
|
||
Get SSH connection to an OpenStack instance. | ||
|
||
|
||
|
||
**Args:** | ||
|
||
- <b>`instance`</b>: The OpenStack instance to connect to. | ||
|
||
|
||
|
||
**Raises:** | ||
|
||
- <b>`SSHError`</b>: Unable to get a working SSH connection to the instance. | ||
- <b>`KeyfileError`</b>: Unable to find the keyfile to connect to the instance. | ||
|
||
|
||
|
||
**Returns:** | ||
SSH connection object. | ||
|
||
--- | ||
|
||
<a href="../src/openstack_cloud/openstack_cloud.py#L149"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
### <kbd>method</kbd> `launch_instance` | ||
|
||
```python | ||
launch_instance( | ||
instance_id: str, | ||
image: str, | ||
flavor: str, | ||
network: str, | ||
cloud_init: str | ||
) → OpenstackInstance | ||
``` | ||
|
||
Create an OpenStack instance. | ||
|
||
|
||
|
||
**Args:** | ||
|
||
- <b>`instance_id`</b>: The instance ID to form the instance name. | ||
- <b>`image`</b>: The image used to create the instance. | ||
- <b>`flavor`</b>: The flavor used to create the instance. | ||
- <b>`network`</b>: The network used to create the instance. | ||
- <b>`cloud_init`</b>: The cloud init userdata to startup the instance. | ||
|
||
|
||
|
||
**Raises:** | ||
|
||
- <b>`OpenStackError`</b>: Unable to create OpenStack server. | ||
|
||
|
||
|
||
**Returns:** | ||
The OpenStack instance created. | ||
|
||
|
Oops, something went wrong.