Skip to content

Decouple resize action from AWS implementation #287

@WilliamMcCumstie

Description

@WilliamMcCumstie

When a node is powered off, it can be resized to a different instance. This can only occur when the machine is off and therefore a check has been added.

def resize_instance(machine)
unless machine.status == 'stopped'
raise RuntimeError, <<~ERROR.chomp
The instance must be stopped to resize it
ERROR
end
puts "Resizing #{machine.name} to #{instance_type}"
machine.modify_instance_type(instance_type)
end

This is going to cause issue as it relies on the output from machine.status to be stopped. This is the raw response from AWS and may not work with other providers.

Provider specific implementation should be abstracted into the Cloudware::Providers::<provider interface>::Machine classes. This way the code base is decoupled from idiosyncrasies of the individual providers.

In this case, something to the follow affect should be implemented:

module Cloudware
  module Providers
    class Base
      def is_stopped?
        raise NotImplementedError
      end
    end

    class AWSInterface
      def is_stopped?
        status == 'stopped'
      end
    end

    class AzureInterface
      def is_stopped?
        ...
      end
    end
  end
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions