Giter Site home page Giter Site logo

fog-scaleway's Introduction

Fog::Scaleway

Gem Travis Coveralls

Fog provider gem to support Scaleway.

Installation

Add this line to your application's Gemfile:

gem 'fog-scaleway'

And then execute:

$ bundle

Usage

Put your credentials to the fog configuration file:

default:
  scaleway_organization: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # Your organization ID
  scaleway_token: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx        # Your token
  scaleway_region: par1                                       # par1 or ams1

Create a connection to the service:

compute = Fog::Compute[:scaleway]

Manage servers and resources using the connection:

server = compute.servers.bootstrap

server.ssh('uname').first.stdout # => "Linux\r\n"

server.terminate

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test FOG_MOCK=true to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kaorimatz/fog-scaleway.

License

The gem is available as open source under the terms of the MIT License.

fog-scaleway's People

Contributors

kaorimatz avatar tas50 avatar timogoebel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fog-scaleway's Issues

Compute tasks endpoint does not exist anymore

A vagrant halt is broken using vagrant-scaleway. The machine is indeed powered off but vagrant returns an error. The issues comes from fog-scaleway, so I open this issue here.

➜  vagrant-scaleway git:(master) ✗ vagrant up
Bringing machine 'default' up with 'scaleway' provider...
==> default: Creating a server with the following settings...
==> default:  -- Commercial Type: DEV1-XL
==> default:  -- Image: 471029d5-e616-488f-8d13-8a02a3297e43
==> default:  -- Name: devenv
==> default: Starting the server...
==> default: Waiting for server to become "ready"...
==> default: Waiting for SSH to become available...
==> default: Machine is booted and ready for use!
➜  vagrant-scaleway git:(master) ✗ vagrant halt
==> default: Stopping the server...
Traceback (most recent call last):
	50: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/bin/vagrant:205:in `<main>'
	49: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/environment.rb:290:in `cli'
	48: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/cli.rb:67:in `execute'
	47: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/plugins/commands/halt/command.rb:30:in `execute'
	46: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/plugin/v2/command.rb:232:in `with_target_vms'
	45: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/plugin/v2/command.rb:232:in `each'
	44: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/plugin/v2/command.rb:242:in `block in with_target_vms'
	43: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/plugins/commands/halt/command.rb:31:in `block in execute'
	42: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:201:in `action'
	41: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:201:in `call'
	40: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/environment.rb:613:in `lock'
	39: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:215:in `block in action'
	38: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:243:in `action_raw'
	37: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/runner.rb:89:in `run'
	36: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/util/busy.rb:19:in `busy'
	35: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/runner.rb:89:in `block in run'
	34: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builder.rb:149:in `call'
	33: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
	32: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
	31: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
	30: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builtin/call.rb:53:in `call'
	29: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/runner.rb:89:in `run'
	28: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/util/busy.rb:19:in `busy'
	27: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/runner.rb:89:in `block in run'
	26: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builder.rb:149:in `call'
	25: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
	24: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:127:in `block in finalize_action'
	23: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
	22: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/vagrant-scaleway-0.4.1/lib/vagrant-scaleway/action/connect_scaleway.rb:30:in `call'
	21: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
	20: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/vagrant-scaleway-0.4.1/lib/vagrant-scaleway/action/stop_server.rb:17:in `call'
	19: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/models/compute/server.rb:115:in `poweroff'
	18: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/models/compute/server.rb:134:in `execute_action'
	17: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/models/compute/server.rb:134:in `tap'
	16: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/models/compute/server.rb:136:in `block in execute_action'
	15: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/model.rb:74:in `wait_for'
	14: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/wait_for.rb:6:in `wait_for'
	13: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/wait_for.rb:6:in `loop'
	12: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/wait_for.rb:7:in `block in wait_for'
	11: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/model.rb:75:in `block in wait_for'
	10: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/model.rb:48:in `reload'
	 9: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/models/compute/tasks.rb:13:in `get'
	 8: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/requests/compute/get_task.rb:6:in `get_task'
	 7: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/request_helper.rb:12:in `get'
	 6: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/compute.rb:128:in `request'
	 5: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/client.rb:17:in `request'
	 4: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/connection.rb:81:in `request'
	 3: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/excon-0.76.0/lib/excon/connection.rb:281:in `request'
	 2: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/excon-0.76.0/lib/excon/connection.rb:450:in `response'
	 1: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/excon-0.76.0/lib/excon/middlewares/response_parser.rb:12:in `response_call'
/Users/stanislas/.vagrant.d/gems/2.6.6/gems/excon-0.76.0/lib/excon/middlewares/expects.rb:13:in `response_call': Expected([200]) <=> Actual(403 Forbidden) (Excon::Error::Forbidden)
excon.error.response
  :body          => "{\"type\": \"authorization_required\", \"message\": \"Authorization required\"}"
  :cookies       => [
  ]
  :headers       => {
    "content-length"            => "71"
    "content-security-policy"   => "default-src 'none'; frame-ancestors 'none'"
    "content-type"              => "application/json"
    "date"                      => "Sun, 04 Oct 2020 11:21:52 GMT"
    "server"                    => "Scaleway API-Gateway"
    "strict-transport-security" => "max-age=63072000"
    "warning"                   => "299 - \"Deprecated API please use https://api.scaleway.com/instance/v1/zones/fr-par-1/\""
    "x-content-type-options"    => "nosniff"
    "x-frame-options"           => "DENY"
    "x-request-id"              => "3dde2e63-125a-497c-ac96-7dc623b99ec2"
  }
  :host          => "cp-PAR1.scaleway.com"
  :local_address => "10.66.66.2"
  :local_port    => 64477
  :path          => "/tasks/99fe428d-b512-4cbc-a751-0ff60b2ab8c1"
  :port          => 443
  :reason_phrase => "Forbidden"
  :remote_ip     => "51.159.69.134"
  :status        => 403
  :status_line   => "HTTP/1.1 403 Forbidden\r\n"
	50: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/bin/vagrant:205:in `<main>'
	49: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/environment.rb:290:in `cli'
	48: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/cli.rb:67:in `execute'
	47: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/plugins/commands/halt/command.rb:30:in `execute'
	46: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/plugin/v2/command.rb:232:in `with_target_vms'
	45: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/plugin/v2/command.rb:232:in `each'
	44: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/plugin/v2/command.rb:242:in `block in with_target_vms'
	43: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/plugins/commands/halt/command.rb:31:in `block in execute'
	42: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:201:in `action'
	41: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:201:in `call'
	40: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/environment.rb:613:in `lock'
	39: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:215:in `block in action'
	38: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:243:in `action_raw'
	37: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/runner.rb:89:in `run'
	36: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/util/busy.rb:19:in `busy'
	35: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/runner.rb:89:in `block in run'
	34: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builder.rb:149:in `call'
	33: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
	32: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
	31: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
	30: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builtin/call.rb:53:in `call'
	29: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/runner.rb:89:in `run'
	28: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/util/busy.rb:19:in `busy'
	27: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/runner.rb:89:in `block in run'
	26: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builder.rb:149:in `call'
	25: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
	24: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:127:in `block in finalize_action'
	23: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
	22: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/vagrant-scaleway-0.4.1/lib/vagrant-scaleway/action/connect_scaleway.rb:30:in `call'
	21: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
	20: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/vagrant-scaleway-0.4.1/lib/vagrant-scaleway/action/stop_server.rb:17:in `call'
	19: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/models/compute/server.rb:115:in `poweroff'
	18: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/models/compute/server.rb:134:in `execute_action'
	17: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/models/compute/server.rb:134:in `tap'
	16: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/models/compute/server.rb:136:in `block in execute_action'
	15: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/model.rb:74:in `wait_for'
	14: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/wait_for.rb:6:in `wait_for'
	13: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/wait_for.rb:6:in `loop'
	12: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/wait_for.rb:7:in `block in wait_for'
	11: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/model.rb:75:in `block in wait_for'
	10: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/model.rb:48:in `reload'
	 9: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/models/compute/tasks.rb:13:in `get'
	 8: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/requests/compute/get_task.rb:6:in `get_task'
	 7: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/request_helper.rb:12:in `get'
	 6: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/compute.rb:128:in `request'
	 5: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-scaleway-0.5.0/lib/fog/scaleway/client.rb:17:in `request'
	 4: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/fog-core-1.45.0/lib/fog/core/connection.rb:81:in `request'
	 3: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/excon-0.76.0/lib/excon/connection.rb:281:in `request'
	 2: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/excon-0.76.0/lib/excon/connection.rb:450:in `response'
	 1: from /Users/stanislas/.vagrant.d/gems/2.6.6/gems/excon-0.76.0/lib/excon/middlewares/response_parser.rb:12:in `response_call'
/Users/stanislas/.vagrant.d/gems/2.6.6/gems/excon-0.76.0/lib/excon/middlewares/expects.rb:13:in `response_call': Authorization required (Fog::Scaleway::Compute::AuthorizationRequired)

The request is :path => "/tasks/99fe428d-b512-4cbc-a751-0ff60b2ab8c1"

Made by

def get_task(task_id)
get("/tasks/#{task_id}")
end

According to https://developers.scaleway.com/en/products/instance/api/#endpoints there is not tasks endpoint.

I assume the poweroff call is made before this one, so that's why the server is indeed powered off.

ssh key updating does not work

First of all. Thanks for this gem. It's quite neat.
However, when I try to do the following,

account = Fog::Account.new(:provider => :scaleway, :scaleway_token => 'abcdef')
user = account.users.first
user.ssh_public_keys << {'key' => 'ssh-rsa base64 my-super-name'}
user.save

I get this error:

Fog::Scaleway::Account::InvalidRequestError: Validation Error
	phone_number:
		- extra keys not allowed

I didn't change the phone number at all. I know, Scaleway's documentation is bad. My question is: Am I doing something wrong or do we need to handle this? If I'm not mistaken, Scaleway doesn't allow updating the phone number through the control panel. Might this be an issue?

I also can't understand these lines of code:

            options[:ssh_public_keys] = ssh_public_keys.map do |k|
              { 'key' => k['key'] }
            end

options[:ssh_public_keys] is already an array of hashes with the key key, so why is the map needed?

Thanks you for your help. I'm happy to assist where I can.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.