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

add missing features to existing resources #60

Merged
12 commits merged into from Oct 11, 2023
Merged

add missing features to existing resources #60

12 commits merged into from Oct 11, 2023

Conversation

ghost
Copy link

@ghost ghost commented Dec 15, 2022

Implementing the missing features of existing resources (new actions, new attributes) in this PR.

List of requirements compiled from #30

Some server attributes have already been implemented before this PR.

(!) = Blocked by other PR

  • Images have Actions
  • Servers have metrics
  • Servers Action add_to_placement_group
  • Servers Action change_alias_ips
  • Servers Action change_dns_ptr
  • Servers Action remove_from_placement_group
  • Server attribute backup_window
  • Server attribute iso (resource type)
  • Server attribute labels (currently hash)
  • (!) lib: implement load balancer #55 Server attribute load_balancers (currently array) (resource type)
  • Server attribute placement_group (resource type)
  • Server attribute private_net (currently array) (resource type)
  • Server attribute protection ({"delete"=>false, "rebuild"=>false})
  • Server attribute public_net (currently hash), has sub fields that are resource types
    • primary IPs
    • floating IPs
    • firewalls (this one is a bit harder to handle as next to the ID it has the additional field status, which describes the relationship between the server and the firewall)
      • open issue: the ID is in a hash in the :id key, so the parsed firewall object also is in the :id key
  • Server attribute volumes (currently list) (resource type)
  • Network Action change_ip_range
  • Floating IPs parameter name on create
  • Floating IPs parameter name on update
  • Image parameter status on get all
  • Image parameter include_deprecated on get all
  • Placement groups parameter label_selector on get all
  • Server parameter automount on create
  • Server parameter firewalls on create
  • Server parameter placement_group on create
  • Server parameter public_net on create
  • Server parameter volumes on create
  • SSH key parameter fingerprint on get all
  • Volume parameter status on get all

TODO after #55 merged:

  • add it_supports_search to load balancer spec
  • add it_supports_search to load balancer type spec

Closes #30

@ghost ghost changed the title 30 complete resources add missing features to existing resources Dec 15, 2022
@ghost ghost mentioned this pull request Dec 19, 2022
2 tasks
Stefan Koch added 12 commits June 22, 2023 11:45
For many resource types if an API response contains other resources we parse
that data as an object. For example, the API response for a server includes the
image info for that server. This image info can be represented as a `Image`
object.

We're also refactoring the method `EntryLoader#_load`, because it's getting too
long.
@ghost ghost marked this pull request as ready for review June 22, 2023 09:49
@ghost
Copy link
Author

ghost commented Jun 22, 2023

Solved the problematic firewalls: [{ id: 12345, status: "applied" }] with a raw_data on our Future object.

Accessing the Firewall object with server.public_net[:firewalls][0][:id] # type Firewall would be weird. A user can expect to get the firewall on server.public_net[:firewalls][0]. But then we lose the applied status information.

Luckily, server.public_net[:firewalls][0] does not really hold a Firewall object, it holds a Future which transparently forwards every method to a Firewall object. I added a method raw_data to this Future, which returns the actual Hash/JSON data.

Users can now request the hidden data (e.g. applied status) like this:

# basically a Firewall object (in reality a Future, but forwards everything to Firewall)
server.public_net[:firewalls][0]

# get the { id: 12345, status: 'applied' } hash
server.public_net[:firewalls][0].raw_data

@ghost
Copy link
Author

ghost commented Jun 22, 2023

Since this is still an MR from my fork and tests do not run. I think all tests should be green, at least they are locally:

  • bundle exec rubocop: OK
  • LEGACY_TESTS=y bundle exec rspec -t '~doubles': OK
  • bundle exec rspec -t doubles --order rand: OK

@ghost ghost merged commit 04d3013 into tonobo:master Oct 11, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement] Add missing fields / endpoints to Images + Servers
1 participant