Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Us48754 host reimage #78

Merged
merged 19 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions v1/api/swagger/components/schemas/HostState.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum:
- Connecting
- Booting
- Ready
- Reimaging Prep
- Replacing
- Releasing
- Allocating
Expand Down
32 changes: 32 additions & 0 deletions v1/api/swagger/paths/hosts@{hostId}@reimage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
summary: Reimage a specific host
post:
tags:
- hosts
summary: Reimage Host by ID
description: >-
Re-deploys a host to the same machine.
Only the Host OS is reinstalled, IP addresses, volumes, etc are not changed.
The host must be powered off. The host must also be in the Ready state.
operationId: reimage
parameters:
- name: hostId
in: path
description: ID of Host to reimage
required: true
schema:
type: string
responses:
'200':
description: success
content:
application/json:
schema:
$ref: ../components/schemas/Host.yaml
'400':
$ref: ../components/responses/InvalidContent.yaml
'401':
$ref: ../components/responses/Unauthorized.yaml
'404':
$ref: ../components/responses/NotFound.yaml
'500':
$ref: ../components/responses/InternalError.yaml
2 changes: 2 additions & 0 deletions v1/api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ paths:
$ref: paths/hosts@{hostId}@bootpxe.yaml
/hosts/{hostId}/boothdd:
$ref: paths/hosts@{hostId}@boothdd.yaml
/hosts/{hostId}/reimage:
$ref: paths/hosts@{hostId}@reimage.yaml
/hosts/{hostId}/replace:
$ref: paths/hosts@{hostId}@replace.yaml
/available-resources:
Expand Down
70 changes: 39 additions & 31 deletions v1/html/index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions v1/pkg/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Class | Method | HTTP request | Description
*HostsApi* | [**PowerOff**](docs/HostsApi.md#poweroff) | **Post** /hosts/{hostId}/poweroff | Power off Host by ID
*HostsApi* | [**PowerOn**](docs/HostsApi.md#poweron) | **Post** /hosts/{hostId}/poweron | Power on Host by ID
*HostsApi* | [**PowerReset**](docs/HostsApi.md#powerreset) | **Post** /hosts/{hostId}/powerreset | Reset Host by ID
*HostsApi* | [**Reimage**](docs/HostsApi.md#reimage) | **Post** /hosts/{hostId}/reimage | Reimage Host by ID
*HostsApi* | [**Replace**](docs/HostsApi.md#replace) | **Post** /hosts/{hostId}/replace | Replace Host by ID
*HostsApi* | [**Update**](docs/HostsApi.md#update) | **Put** /hosts/{hostId} | Update an existing Host
*IppoolsApi* | [**AllocateIPs**](docs/IppoolsApi.md#allocateips) | **Post** /ippools/{ippoolId}/allocation | Allocate IPs from the pool
Expand Down
49 changes: 49 additions & 0 deletions v1/pkg/client/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,54 @@ paths:
tags:
- hosts
summary: Set a specific host to attempt HDD boot
/hosts/{hostId}/reimage:
post:
description: Re-deploys a host to the same machine. Only the Host OS is reinstalled,
IP addresses, volumes, etc are not changed. The host must be powered off. The
host must also be in the Ready state.
operationId: reimage
parameters:
- description: ID of Host to reimage
in: path
name: hostId
required: true
schema:
type: string
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/Host'
description: success
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: invalid content
"401":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: unauthorized
"404":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: not found
"500":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: internal error
summary: Reimage Host by ID
tags:
- hosts
summary: Reimage a specific host
/hosts/{hostId}/replace:
post:
description: Re-deploys a host with a new machine that satisfies the current
Expand Down Expand Up @@ -3506,6 +3554,7 @@ components:
- Connecting
- Booting
- Ready
- Reimaging Prep
- Replacing
- Releasing
- Allocating
Expand Down
151 changes: 151 additions & 0 deletions v1/pkg/client/api_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,157 @@ func (a *HostsApiService) PowerReset(ctx _context.Context, hostId string) (Host,
return localVarReturnValue, localVarHTTPResponse, nil
}

/*
Reimage Reimage Host by ID
Re-deploys a host to the same machine. Only the Host OS is reinstalled, IP addresses, volumes, etc are not changed. The host must be powered off. The host must also be in the Ready state.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param hostId ID of Host to reimage
@return Host
*/
func (a *HostsApiService) Reimage(ctx _context.Context, hostId string) (Host, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodPost
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue Host
)

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/hosts/{hostId}/reimage"
localVarPath = strings.Replace(localVarPath, "{"+"hostId"+"}", _neturl.QueryEscape(parameterToString(hostId, "")) , -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}

// to determine the Content-Type header
localVarHTTPContentTypes := []string{}

// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}

// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}

// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if ctx != nil {
// API Key Authentication
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
var key string
if auth.Prefix != "" {
key = auth.Prefix + " " + auth.Key
} else {
key = auth.Key
}
localVarHeaderParams["Membership"] = key
}
}
if ctx != nil {
// API Key Authentication
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
var key string
if auth.Prefix != "" {
key = auth.Prefix + " " + auth.Key
} else {
key = auth.Key
}
localVarHeaderParams["Project"] = key
}
}
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, nil, err
}

localVarHTTPResponse, err := a.client.callAPI(r)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 200 {
var v Host
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 400 {
var v ErrorResponse
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 401 {
var v ErrorResponse
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 404 {
var v ErrorResponse
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 500 {
var v ErrorResponse
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

return localVarReturnValue, localVarHTTPResponse, nil
}

/*
Replace Replace Host by ID
Re-deploys a host with a new machine that satisfies the current host settings. Only the machine is replaced, IP addresses, volumes, etc are not changed. The host must be powered off. The host must also be in the Ready state or in the Failed state and in the Replace or Maintenace workflow.
Expand Down
35 changes: 35 additions & 0 deletions v1/pkg/client/docs/HostsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Method | HTTP request | Description
[**PowerOff**](HostsApi.md#PowerOff) | **Post** /hosts/{hostId}/poweroff | Power off Host by ID
[**PowerOn**](HostsApi.md#PowerOn) | **Post** /hosts/{hostId}/poweron | Power on Host by ID
[**PowerReset**](HostsApi.md#PowerReset) | **Post** /hosts/{hostId}/powerreset | Reset Host by ID
[**Reimage**](HostsApi.md#Reimage) | **Post** /hosts/{hostId}/reimage | Reimage Host by ID
[**Replace**](HostsApi.md#Replace) | **Post** /hosts/{hostId}/replace | Replace Host by ID
[**Update**](HostsApi.md#Update) | **Put** /hosts/{hostId} | Update an existing Host

Expand Down Expand Up @@ -368,6 +369,40 @@ Name | Type | Description | Notes
[[Back to README]](../README.md)


## Reimage

> Host Reimage(ctx, hostId)

Reimage Host by ID

Re-deploys a host to the same machine. Only the Host OS is reinstalled, IP addresses, volumes, etc are not changed. The host must be powered off. The host must also be in the Ready state.

### Required Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
**hostId** | **string**| ID of Host to reimage |

### Return type

[**Host**](Host.md)

### Authorization

[BearerAuth](../README.md#BearerAuth), [Membership](../README.md#Membership), [Project](../README.md#Project)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)


## Replace

> Host Replace(ctx, hostId)
Expand Down
9 changes: 9 additions & 0 deletions v1/pkg/client/interface_hosts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions v1/pkg/client/model_host_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
HOSTSTATE_CONNECTING HostState = "Connecting"
HOSTSTATE_BOOTING HostState = "Booting"
HOSTSTATE_READY HostState = "Ready"
HOSTSTATE_REIMAGING_PREP HostState = "Reimaging Prep"
HOSTSTATE_REPLACING HostState = "Replacing"
HOSTSTATE_RELEASING HostState = "Releasing"
HOSTSTATE_ALLOCATING HostState = "Allocating"
Expand Down
16 changes: 16 additions & 0 deletions v1/pkg/mockquakeclient/mock_hosts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.