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

feat: cloudhypervisor api client #522

Merged
merged 1 commit into from
Sep 27, 2022
Merged

feat: cloudhypervisor api client #522

merged 1 commit into from
Sep 27, 2022

Conversation

richardcase
Copy link
Member

What this PR does / why we need it:

This change adds a Cloud Hypervisor API client. This will be used in a
later implementation to enable Flintlock to talk to running instances of
Cloud Hypervisor.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Relates #417

Special notes for your reviewer:

This functionality will not be used initially.

Checklist:

  • squashed commits into logical changes
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

@richardcase richardcase added kind/feature New feature or request area/cloud-hypervisor Indicates an issue or PR related to Cloud Hypervisor labels Aug 23, 2022
VmmShutdown(ctx context.Context) error
// Info returns general information about the cloud-hypervisor Virtual Machine (VM) instance.
Info(ctx context.Context) (*VmInfo, error)
//Counters(ctx context.Context) *VmmCo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what dis?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thats a future todo that i forgot to remove. I have removed it now :)

Comment on lines 38 to 66
// PowerButton triggers a power button in the VM.
PowerButton(ctx context.Context) error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean? Like on/off?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well depends on what the power button is configured to do.

Copy link
Member Author

@richardcase richardcase Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the comment.

func (c *client) VmmPing(ctx context.Context) (*VmmPingResponse, error) {
resp := &VmmPingResponse{}

if err := c.builder.Clone().Path("vmm.ping").ToJSON(resp).Fetch(ctx); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to have all these "vmm.x" strings as consts

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I have moved these all to consts.

This change adds a Cloud Hypervisor API client. This will be used in a
later implementation to enable Flintlock to talk to running instances of
Cloud Hypervisor.

This functionality will not be used initially.

Signed-off-by: Richard Case <richard.case@outlook.com>
Clone().
Path(PathVmBoot).
AddValidator(CustomErrValidator(map[int]string{
404: "The VM instance could not boot because it is not created yet",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to have all these as consts, but happy to leave that as a TODO for later

Comment on lines +50 to +53
if err = json.Unmarshal(data, dest); err != nil {
return err
}
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be

Suggested change
if err = json.Unmarshal(data, dest); err != nil {
return err
}
return nil
return json.Unmarshal(data, dest)

but not bothered

@richardcase richardcase merged commit b655558 into liquidmetal-dev:main Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cloud-hypervisor Indicates an issue or PR related to Cloud Hypervisor kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants