pax_global_header00006660000000000000000000000064132073673060014521gustar00rootroot0000000000000052 comment=be562e0a4ac2ff964e1131dadb4a0af65c5a8856 fog-profitbricks-4.1.0/000077500000000000000000000000001320736730600147755ustar00rootroot00000000000000fog-profitbricks-4.1.0/.gitignore000066400000000000000000000003241320736730600167640ustar00rootroot00000000000000*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp *.bundle *.so *.o *.a mkmf.log gemfiles/*.lock .fog .idea/fog-profitbricks-4.1.0/.rubocop.yml000066400000000000000000000005631320736730600172530ustar00rootroot00000000000000Metrics/LineLength: Enabled: false Style/EachWithObject: Enabled: false Style/Encoding: EnforcedStyle: when_needed Style/FormatString: Enabled: false Style/HashSyntax: EnforcedStyle: hash_rockets Style/SignalException: EnforcedStyle: only_raise Style/StringLiterals: Enabled: false # EnforcedStyle: double_quotes Style/IndentationWidth: Width: 2 fog-profitbricks-4.1.0/.ruby-gemset000066400000000000000000000000201320736730600172310ustar00rootroot00000000000000fog-profitbricksfog-profitbricks-4.1.0/.ruby-version000066400000000000000000000000051320736730600174350ustar00rootroot000000000000002.1.2fog-profitbricks-4.1.0/.travis.yml000066400000000000000000000010271320736730600171060ustar00rootroot00000000000000language: ruby before_install: - gem update bundler script: bundle exec rake travis matrix: include: - rvm: 1.9.3 gemfile: gemfiles/Gemfile.1.9.2+ env: COVERAGE=true - rvm: 2.0.0 gemfile: Gemfile env: COVERAGE=true - rvm: 2.1.1 gemfile: Gemfile env: COVERAGE=true - rvm: 2.2.0 gemfile: Gemfile env: COVERAGE=true - rvm: 2.3.0 gemfile: Gemfile env: COVERAGE=true - rvm: jruby-head gemfile: gemfiles/Gemfile.1.9.2+ env: COVERAGE=true fog-profitbricks-4.1.0/CONTRIBUTING.md000066400000000000000000000016051320736730600172300ustar00rootroot00000000000000## Getting Involved New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another. ### Coding * Pick a task: * Offer feedback on open [pull requests](https://github.com/fog/fog-profitbricks/pulls). * Review open [issues](https://github.com/fog/fog-profitbricks/issues) for things to help on. * [Create an issue](https://github.com/fog/fog-profitbricks/issues/new) to start a discussion on additions or features. * Fork the project, add your changes and tests to cover them in a topic branch. * Commit your changes and rebase against `fog/fog-profitbricks` to ensure everything is up to date. * [Submit a pull request](https://github.com/fog/fog-profitbricks/compare/) ### Non-Coding * Offer feedback on open [issues](https://github.com/fog/fog-profitbricks/issues). * Organize or volunteer at events.fog-profitbricks-4.1.0/CONTRIBUTORS.md000066400000000000000000000001501320736730600172500ustar00rootroot00000000000000* Ethan Devenport * Paulo Henrique Lopes Ribeiro fog-profitbricks-4.1.0/Gemfile000066400000000000000000000001451320736730600162700ustar00rootroot00000000000000source 'https://rubygems.org' # Specify your gem's dependencies in fog-profitbricks.gemspec gemspec fog-profitbricks-4.1.0/LICENSE.md000066400000000000000000000022051320736730600164000ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014-2014 [CONTRIBUTORS.md](https://github.com/fog/fog-profitbricks/blob/master/CONTRIBUTORS.md) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.fog-profitbricks-4.1.0/README.md000066400000000000000000001736141320736730600162700ustar00rootroot00000000000000# Fog::profitbricks ![Gem Version](https://badge.fury.io/rb/fog-profitbricks.svg) [![Build Status](https://travis-ci.org/fog/fog-profitbricks.svg?branch=master)](https://travis-ci.org/fog/fog-profitbricks) [![Dependency Status](https://gemnasium.com/fog/fog-profitbricks.svg)](https://gemnasium.com/fog/fog-profitbricks) [![Coverage Status](https://img.shields.io/coveralls/fog/fog-profitbricks.svg)](https://coveralls.io/r/fog/fog-profitbricks?branch=master) [![Code Climate](https://codeclimate.com/github/fog/fog-profitbricks/badges/gpa.svg)](https://codeclimate.com/github/fog/fog-profitbricks) Module for the 'fog' gem to support ProfitBricks Cloud API. ## Table of Contents * [Getting Started](#getting-started) * [Installation](#installation) * [Authentication](#authentication) * [Operations](#operations) * [Data Centers](#data-centers) * [List Data Centers](#list-data-centers) * [Retrieve a Data Center](#retrieve-a-data-center) * [Create a Data Centers](#create-a-data-center) * [Update a Data Centers](#update-a-data-center) * [Delete a Data Centers](#delete-a-data-center) * [Locations](#locations) * [List Locations](#list-locations) * [Get a Location](#get-a-location) * [Servers](#servers) * [List Servers](#list-servers) * [Retrieve a Server](#retrieve-a-server) * [Create a Server](#create-a-server) * [Update a Server](#update-a-server) * [Delete a Server](#delete-a-server) * [List Attached Volumes](#list-attached-volumes) * [Attach a Volume](#attach-a-volume) * [Retrieve an Attached Volume](#retrieve-an-attached-volume) * [Detach a Volume](#detach-a-volume) * [List Attached CD-ROMs](#list-attached-cd-roms) * [Attach a CD-ROM](#attach-a-cd-rom) * [Retrieve an Attached CD-ROM](retrieve-an-attached-cd-rom) * [Detach a CD-ROM](#detach-a-cd-rom) * [Reboot a Server](#reboot-a-server) * [Start a Server](#start-a-server) * [Stop a Server](#stop-a-server) * [Volumes](#volumes) * [List Volumes](#list-volumes) * [Get a Volume](#get-a-volume) * [Create a Volume](#create-a-volume) * [Update a Volume](#update-a-volume) * [Delete a Volume](#delete-a-volume) * [Create a Volume Snapshot](#create-a-volume-snapshot) * [Restore a Volume Snapshot](#restore-a-volume-snapshot) * [Snapshots](#snapshots) * [List Snapshots](#list-snapshots) * [Get a Snapshot](#get-a-snapshot) * [Update a Snapshot](#update-a-snapshot) * [Delete a Snapshot](#delete-a-snapshot) * [Load Balancers](#load-balancers) * [List Load Balancers](#list-load-balancers) * [Get a Load Balancer](#get-a-load-balancer) * [Create a Load Balancer](#create-a-load-balancer) * [Update a Load Balancer](#update-a-load-balancer) * [List Load Balanced NICs](#list-load-balanced-nics) * [Get a Load Balanced NIC](#get-a-load-balanced-nic) * [Associate NIC to a Load Balancer](#associate-nic-to-a-load-balancer) * [Remove a NIC Association](#remove-a-nic-association) * [Firewall Rules](#firewall-rules) * [List Firewall Rules](#list-firewall-rules) * [Get a Firewall Rule](#get-a-firewall-rule) * [Create a Firewall Rule](#create-a-firewall-rule) * [Update a Firewall Rule](#update-a-firewall-rule) * [Delete a Firewall Rule](#delete-a-firewall-rule) * [Images](#images) * [List Images](#list-images) * [Get an Image](#get-an-image) * [Update an Image](#update-an-image) * [Delete an Image](#delete-an-image) * [Network Interfaces (NICs)](#network-interfaces-nics) * [List NICs](#list-nics) * [Get a NIC](#get-a-nic) * [Create a NIC](#create-a-nic) * [Update a NIC](#update-a-nic) * [Delete a NIC](#delete-a-nic) * [IP Blocks](#ip-blocks) * [List IP Blocks](#list-ip-blocks) * [Get an IP Block](#get-an-ip-block) * [Create an IP Block](#create-an-ip-block) * [Delete an IP Block](#delete-an-ip-block) * [Requests](#requests) * [List Requests](#list-requests) * [Get a Request](#get-a-request) * [Get a Request Status](#get-a-request-status) * [LANs](#lans) * [List LANs](#list-lans) * [Create a LAN](#create-a-lan) * [Get a LAN](#get-a-lan) * [Update a LAN](#update-a-lan) * [Delete a LAN](#delete-a-lan) * [Contract Resources](#contract-resources) * [List Contract Resources](#list-contract-resources) * [User Management](#user-management) * [List Groups](#list-groups) * [Retrieve a Group](#retrieve-a-group) * [Create a Group](#create-a-group) * [Update a Group](#update-a-group) * [Delete a Group](#delete-a-group) * [List Shares](#list-shares) * [Retrieve a Share](#retrieve-a-share) * [Add a Share](#add-a-share) * [Update a Share](#update-a-share) * [Delete a Share](#delete-a-share) * [List Users in a Group](#list-users-in-a-group) * [Add User to Group](#add-user-to-group) * [Remove User from a Group](#remove-user-from-a-group) * [List Users](#list-users) * [Retrieve a User](#retrieve-a-user) * [Create a User](#create-a-user) * [Update a User](#update-a-user) * [Delete a User](#delete-a-user) * [List Resources](#list-resources) * [List All Resources of a Type](#list-all-resources-of-a-type) * [List a Specific Resource Type](#list-a-specific-resource-type) * [Contributing](#contributing) ## Getting Started Before you begin, you will need to have signed up for a ProfitBricks account. The credentials you create during sign-up will be used to authenticate against the API. For more information on ProfitBricks REST API, visit the [API documentation](https://devops.profitbricks.com/api/cloud/v3/) page. ### Installation Add this line to your application's Gemfile: gem 'fog-profitbricks' And then execute: $ bundle Or install it yourself as: $ gem install fog-profitbricks ### Authentication Provide your credentials when creating a compute object: ``` compute = Fog::Compute.new(:provider => 'ProfitBricks', :profitbricks_username => 'username', :profitbricks_password => 'password') ``` ## Operations ### Data Centers Virtual Data Centers (VDCs) are the foundation of the ProfitBricks platform. VDCs act as logical containers for all other objects you will be creating, e.g., servers. You can provision as many data centers as you want. Data centers have their own private network and are logically segmented from each other to create isolation. #### List Data Centers ``` compute.datacenters.all ``` --- #### Retrieve a Data Center The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | ``` compute.datacenters.get('datacenter_id') ``` --- #### Create a Data Center The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | name | string | The name of the data center. | Yes | | location | string | The physical location where the data center will be created. This will be where all of your servers live. | Yes | | name | string | A description for the data center, e.g. staging, production. | No| The following table outlines the locations currently supported: | VALUE| COUNTRY | CITY | |---|---|---| | us/las | United States | Las Vegas | | us/ewr | United States | Newark | | de/fra | Germany | Frankfurt | | de/fkb | Germany | Karlsruhe | ``` datacenter = compute.datacenters.create(:name => 'My data center', :location => 'us/las', :description => 'My data center description') ``` *NOTES*: - The value for `name` cannot contain the following characters: (@, /, , |, ‘’, ‘). - You cannot change a data center's `location` once it has been provisioned. --- #### Update a Data Center After retrieving a data center, either by getting it by id, or as a create response object, you can change it's properties and call the `update` method: ``` datacenter.name = 'My data center updated name' datacenter.update ``` The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | | --- | --- | --- | --- | | name | string | The new name of the data center. | No| | description | string | The new description of the data center. | No | --- #### Delete a Data Center This will remove all objects within the data center and remove the data center object itself. **NOTE**: This is a highly destructive operation which should be used with extreme caution. ``` datacenter.delete ``` --- ### Locations Locations represent regions where you can provision your Virtual Data Centers. #### List Locations ``` compute.locations.all ``` --- #### Get a Location Retrieves the attributes of a given location. The following table describes the request arguments: | NAME | TYPE | DESCRIPTION | REQUIRED | | --- | --- | --- | --- | | location_id | string | The resource's unique identifier consisting of country/city. | Yes| ``` compute.locations.get('us/las') ``` --- ### Servers #### List Servers You can retrieve a list of all servers within a data center. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | ``` compute.servers.all('datacenter_id') ``` --- #### Retrieve a Server Returns information about a server such as its configuration, provisioning status, etc. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | ``` compute.servers.get('datacenter_id', 'server-id') ``` --- #### Create a Server Creates a server within an existing data center. You can configure additional properties such as specifying a boot volume and connecting the server to an existing LAN. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | name | string | The hostname of the server. | Yes | | cores | int | The total number of cores for the server. | Yes | | ram | int | The amount of memory for the server in MB, e.g. 2048. Size must be specified in multiples of 256 MB with a minimum of 256 MB; however, if you set ramHotPlug to TRUE then you must use a minimum of 1024 MB. | Yes | | availabilityZone | string |The availability zone in which the server should exist. | No | | licenceType | string | Sets the OS type of the server. If undefined the OS type will be inherited from the boot image or boot volume. | No* | | bootVolume | string | Reference to a Volume used for booting. If not ‘null’ then bootCdrom has to be ‘null’. | No | | bootCdrom | string | Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null'. | No | | volumes | collection | A collection of volume IDs that you want to connect to the server. If the volume does not exist it will be created implicitly. | No | | nics | collection | A collection of NICs you wish to create at the time the server is provisioned. | No | | cpuFamily | string | Sets the CPU type. "AMD_OPTERON" or "INTEL_XEON". Defaults to "AMD_OPTERON". | No | The following table outlines the various licence types you can define: | LICENCE TYPE | COMMENT | |---|---| | WINDOWS | You must specify this if you are using your own, custom Windows image due to Microsoft's licensing terms. | | WINDOWS2016 | You must specify this if you are using your own, custom Windows image due to Microsoft's licensing terms. | | LINUX || | UNKNOWN | If you are using an image uploaded to your account your OS Type will inherit as UNKNOWN. | The following table outlines the availability zones currently supported: | LICENCE TYPE | COMMENT | |---|---| | AUTO | Automatically Selected Zone | | ZONE_1 | Fire Zone 1 | | ZONE_2 | Fire Zone 2 | ``` compute.servers.create(:datacenter_id => 'datacenter_id', :name => 'My server', :cores => 2, :ram => 2048, :availability_zone => 'AUTO', :licence_type => 'LINUX') ``` **NOTE**: When creating a volume, you must specify either the `licence_type` or an `image`. --- #### Update a Server Perform updates to attributes of a server. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | | name | string | The name of the server. | No | | cores | int | The number of cores for the server. | No | | ram | int | The amount of memory in the server. | No | | availabilityZone | string | The new availability zone for the server. | No | | licenceType | string | The licence type for the server. | No | | bootVolume | string | Reference to a Volume used for booting. If not ‘null’ then bootCdrom has to be ‘null’ | No | | bootCdrom | string | Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null'. | No | After retrieving a server, either by getting it by id, or as a create response object, you can change it's properties and call the `update` method: ``` server = compute.servers.get('datacenter_id', 'server-id') server.name = 'Updated server name' server.ram = 1024 server.update ``` --- #### Delete a Server This will remove a server from a data center. NOTE: This will not automatically remove the storage volume(s) attached to a server. A separate API call is required to perform that action. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.delete ``` --- #### List Attached Volumes Retrieves a list of volumes attached to the server. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `get_volumes` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.get_volumes ``` --- #### Attach a Volume This will attach a pre-existing storage volume to the server. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | | storage-id | string | The unique ID of a storage volume. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `attach_volume` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.attach_volume('storage-id') ``` --- #### Retrieve an Attached Volume This will retrieve the properties of an attached volume. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | | volume-id | string | The unique ID of the attached volume. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `get_attached_volume` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.get_attached_volume('volume-id') ``` --- #### Detach a Volume This will detach the volume from the server. Depending on the volume "hot_unplug" settings, this may result in the server being rebooted. This will NOT delete the volume from your data center. You will need to make a separate request to delete a volume. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | | volume-id | string | The unique ID of the attached volume. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `detach_volume` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.detach_volume('volume-id') ``` --- #### List Attached CD-ROMs Retrieves a list of CD-ROMs attached to the server. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `get_cdroms` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.get_cdroms ``` --- #### Attach a CD-ROM You can attach a CD-ROM to an existing server. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | | cdrom-image-id | string | The unique ID of a CD-ROM. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `attach_cdrom` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.attach_cdrom('cdrom-image-id') ``` --- #### Retrieve an Attached CD-ROM You can retrieve a specific CD-ROM attached to the server. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | | cdrom-id | string | The unique ID of the attached CD-ROM. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `get_attached_cdrom` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.get_attached_cdrom('cdrom-id') ``` --- #### Detach a CD-ROM This will detach a CD-ROM from the server. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | | cdrom-id | string | The unique ID of the attached CD-ROM. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `detach_cdrom` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.detach_cdrom('cdrom-id') ``` --- #### Reboot a Server This will force a hard reboot of the server. Do not use this method if you want to gracefully reboot the machine. This is the equivalent of powering off the machine and turning it back on. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `reboot` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.reboot ``` --- #### Start a Server This will start a server. If the server's public IP was deallocated then a new IP will be assigned. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `start` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.start ``` --- #### Stop a Server This will stop a server. The machine will be forcefully powered off, billing will cease, and the public IP, if one is allocated, will be deallocated. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | After retrieving a server, either by getting it by id, or as a create response object, you can call the `stop` method directly on the object: ``` server = compute.servers.get('datacenter_id', 'server-id') server.stop ``` --- ### Volumes #### List Volumes Retrieve a list of volumes within the data center. If you want to retrieve a list of volumes attached to a server please see the [Servers](#servers) section for examples on how to do so. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | ``` compute.volumes.all('datacenter_id') ``` --- #### Get a Volume Retrieves the attributes of a given volume. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | volume-id | string | The unique ID of the volume. | Yes | ``` compute.volumes.get('datacenter_id', 'volume-id') ``` --- #### Create a Volume Creates a volume within the data center. This will NOT attach the volume to a server. Please see the [Servers](#servers) section for details on how to attach storage volumes. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | name | string | The name of the volume. | No | | size | int | The size of the volume in GB. | Yes | | bus | string | The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. | No | | image | string | The image or snapshot ID. | Yes* | | type | string | The volume type, HDD or SSD. | Yes | | licenceType | string | The licence type of the volume. Options: LINUX, WINDOWS, WINDOWS2016, UNKNOWN, OTHER | Yes* | | imagePassword | string | One-time password is set on the Image for the appropriate account. This field may only be set in creation requests. When reading, it always returns null. Password has to contain 8-50 characters. Only these characters are allowed: [abcdefghjkmnpqrstuvxABCDEFGHJKLMNPQRSTUVX23456789] | Yes* | | sshKeys | string | SSH keys to allow access to the volume via SSH | Yes* | | availabilityZone | string | The storage availability zone assigned to the volume. Valid values: AUTO, ZONE_1, ZONE_2, or ZONE_3. This only applies to HDD volumes. Leave blank or set to AUTO when provisioning SSD volumes. | No | *You will need to provide either the `image` or the `licenceType` parameters. `licenceType` is required, but if `image` is supplied, it is already set and cannot be changed. Similarly either the `imagePassword` or `sshKeys` parameters need to be supplied when creating a volume. We recommend setting a valid value for `imagePassword` even when using `sshKeys` so that it is possible to authenticate using the remote console feature of the DCD. ``` volume = compute.volumes.create(:datacenter_id => 'datacenter_id', :size => 5, :type => 'HDD', :licence_type => 'LINUX') ``` --- #### Update a Volume You can update -- in full or partially -- various attributes on the volume; however, some restrictions are in place: You can increase the size of an existing storage volume. You cannot reduce the size of an existing storage volume. The volume size will be increased without reboot if the hot plug settings have been set to true. The additional capacity is not added to any partition therefore you will need to partition it afterwards. Once you have increased the volume size you cannot decrease the volume size. Since an existing volume is being modified , none of the request parameters are specifically required as long as the changes being made satisfy the requirements for creating a volume. After retrieving a volume, either by getting it by id, or as a create response object, you can change it's properties and call the `update` method: ``` volume = compute.volumes.get('datacenter_id', 'volume-id') volume.name = 'My volume' volume.update ``` --- #### Delete a Volume Deletes the specified volume. This will result in the volume being removed from your data center. Use this with caution. After retrieving a volume, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` volume = compute.volumes.get('datacenter_id', 'volume-id') volume.delete ``` --- #### Create a Volume Snapshot Creates a snapshot of a volume within the data center. You can use a snapshot to create a new storage volume or to restore a storage volume. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | name | string | The name of the snapshot. || | description | string | The description of the snapshot. || After retrieving a volume, either by getting it by id, or as a create response object, you can call the `create_snapshot` method directly on the object: ``` volume = compute.volumes.get('datacenter_id', 'volume-id') volume.create_snapshot('My snapshot', 'My snapshot description') ``` --- #### Restore a Volume Snapshot This will restore a snapshot onto a volume. A snapshot is created as just another image that can be used to create new volumes or to restore an existing volume. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | snapshotId | string | The ID of the snapshot. | Yes | After retrieving a volume, either by getting it by id, or as a create response object, you can call the `restore_snapshot` method directly on the object: ``` volume = compute.volumes.get('datacenter_id', 'volume-id') volume.restore_snapshot('snapshotId') ``` --- ### Snapshots #### List Snapshots You can retrieve a list of all snapshots. ``` compute.snapshots.all ``` --- #### Get a Snapshot Retrieves the attributes of a specific snapshot. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | snapshotId | string | The ID of the snapshot. | Yes | ``` compute.snapshots.get('snapshotId') ``` --- #### Update a Snapshot Perform updates to attributes of a snapshot. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | snapshotId | string | The ID of the snapshot. | Yes | | name | string | The name of the snapshot. || | description | string | The description of the snapshot. || | cpuHotPlug | bool | This volume is capable of CPU hot plug (no reboot required) || | cpuHotUnplug | bool | This volume is capable of CPU hot unplug (no reboot required) || | ramHotPlug | bool | This volume is capable of memory hot plug (no reboot required) || | ramHotUnplug | bool | This volume is capable of memory hot unplug (no reboot required) || | nicHotPlug | bool | This volume is capable of NIC hot plug (no reboot required) || | nicHotUnplug | bool | This volume is capable of NIC hot unplug (no reboot required) || | discVirtioHotPlug | bool | This volume is capable of Virt-IO drive hot plug (no reboot required) || | discVirtioHotUnplug | bool | This volume is capable of Virt-IO drive hot unplug (no reboot required) || | discScsiHotPlug | bool | This volume is capable of SCSI drive hot plug (no reboot required) || | discScsiHotUnplug | bool | This volume is capable of SCSI drive hot unplug (no reboot required) || | licencetype | string | The snapshot's licence type: LINUX, WINDOWS, WINDOWS2016, or UNKNOWN. || After retrieving a snapshot, either by getting it by id, or as a create response object, you can change it's properties and call the `update` method: ``` snapshot = compute.snapshots.get('snapshotId') snapshot.name = 'Updated snapshot name' snapshot.description = 'Updated snapshot description' snapshot.nic_hot_plug = true snapshot.nic_hot_unplug = true snapshot.update ``` --- #### Delete a Snapshot Deletes the specified snapshot. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | snapshotId | string | The ID of the snapshot. | Yes | After retrieving a snapshot, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` snapshot = compute.snapshots.get('snapshotId') snapshot.delete ``` --- ### Load Balancers #### List Load Balancers Retrieve a list of load balancers within the data center. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | ``` compute.load_balancers.all('datacenter_id') ``` --- #### Get a Load Balancer Retrieves the attributes of a given load balancer. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | load_balancer_id | string | The unique ID of the load balancer. | Yes | ``` compute.load_balancers.get('datacenter_id', 'load_balancer_id') ``` --- #### Create a Load Balancer Creates a load balancer within the data center. Load balancers can be used for public or private IP traffic. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | name | string | The name of the load balancer. | Yes | | ip | string | IPv4 address of the load balancer. All attached NICs will inherit this IP. | No | | dhcp | bool | Indicates if the load balancer will reserve an IP using DHCP. | No | | balancednics | string collection | List of NICs taking part in load-balancing. All balanced nics inherit the IP of the load balancer. | No | ``` compute.load_balancers.create(:datacenter_id => 'datacenter_id', :name => 'My load balancer') ``` --- #### Update a Load Balancer Perform updates to attributes of a load balancer. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | name | string | The name of the load balancer. | No | | ip | string | The IP of the load balancer. | No | | dhcp | bool | Indicates if the load balancer will reserve an IP using DHCP. | No | After retrieving a load balancer, either by getting it by id, or as a create response object, you can change it's properties and call the `update` method: ``` load_balancer = compute.load_balancers.get('datacenter_id', 'load_balancer_id') load_balancer.name = 'Updated load balancer name' load_balancer.update ``` --- #### Delete a Load Balancer Deletes the specified load balancer. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | load_balancer_id | string | The unique ID of the load balancer. | Yes | After retrieving a load balancer, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` load_balancer = compute.load_balancers.get('datacenter_id', 'load_balancer_id') load_balancer.delete ``` --- #### List Load Balanced NICs This will retrieve a list of NICs associated with the load balancer. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | load_balancer_id | string | The unique ID of the load balancer. | Yes | After retrieving a load balancer, either by getting it by id, or as a create response object, you can call the `get_nics` method directly on the object: ``` load_balancer = compute.load_balancers.get('datacenter_id', 'load_balancer_id') load_balancer.get_nics ``` --- #### Get a Load Balanced NIC Retrieves the attributes of a given load balanced NIC. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | load_balancer_id | string | The unique ID of the load balancer. | Yes | | nic_id | string | The unique ID of the load balancer. | Yes | After retrieving a load balancer, either by getting it by id, or as a create response object, you can call the `get_nic` method directly on the object: ``` load_balancer = compute.load_balancers.get('datacenter_id', 'load_balancer_id') load_balancer.get_nic('nic_id') ``` --- #### Associate NIC to a Load Balancer This will associate a NIC to a Load Balancer, enabling the NIC to participate in load-balancing. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | load_balancer_id | string | The unique ID of the load balancer. | Yes | | nic_id | string | The unique ID of the load balancer. | Yes | After retrieving a load balancer, either by getting it by id, or as a create response object, you can call the `associate_nic` method directly on the object: ``` load_balancer = compute.load_balancers.get('datacenter_id', 'load_balancer_id') load_balancer.associate_nic('nic_id') ``` --- #### Remove a NIC Association Removes the association of a NIC with a load balancer. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | load_balancer_id | string | The unique ID of the load balancer. | Yes | | nic_id | string | The unique ID of the load balancer. | Yes | After retrieving a load balancer, either by getting it by id, or as a create response object, you can call the `remove_nic_association` method directly on the object: ``` load_balancer = compute.load_balancers.get('datacenter_id', 'load_balancer_id') load_balancer.remove_nic_association('nic_id') ``` --- ### Firewall Rules #### List Firewall Rules Retrieves a list of firewall rules associated with a particular NIC. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server_id | string | The unique ID of the server. | Yes | | nic_id | string | The unique ID of the NIC. | Yes | ``` compute.firewall_rules.all('datacenter_id', 'server_id', 'nic_id') ``` --- #### Get a Firewall Rule Retrieves the attributes of a given firewall rule. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server_id | string | The unique ID of the server. | Yes | | nic_id | string | The unique ID of the NIC. | Yes | | firewall_rule_id | string | The unique ID of the firewall rule. | Yes | ``` fwr = compute.firewall_rules.get('datacenter_id', 'server_id', 'nic_id', 'firewall_rule_id') ``` --- #### Create a Firewall Rule This will add a firewall rule to the NIC. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server_id | string | The unique ID of the server. | Yes | | nic_id | string | The unique ID of the NIC. | Yes | | name | string | The name of the Firewall Rule. || | protocol | string | The protocol for the rule: TCP, UDP, ICMP, ANY. | Yes | | sourceMac | string | Only traffic originating from the respective MAC address is allowed. Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address. || | sourceIp | string | Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs. || | targetIp | string | In case the target NIC has multiple IP addresses, only traffic directed to the respective IP address of the NIC is allowed. Value null allows all target IPs. || | portRangeStart | string | Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd value null to allow all ports. || | portRangeEnd | string | Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd null to allow all ports. || | icmpType | string | Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types. || | icmpCode | string | Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes. || ``` fwr = compute.firewall_rules.create(:datacenter_id => 'datacenter_id', :server_id => 'server-id', :nic_id => 'nic_id', :name => 'My firewall rule', :protocol => 'ANY') ``` --- #### Update a Firewall Rule Perform updates to attributes of a firewall rule. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server_id | string | The unique ID of the server. | Yes | | nic_id | string | The unique ID of the NIC. | Yes | | firewall_rule_id | string | The unique ID of the firewall rule. | Yes | | name | string | The name of the Firewall Rule. || | sourceMac | string | Only traffic originating from the respective MAC address is allowed. Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address. || | sourceIp | string | Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs. || | targetIp | string | In case the target NIC has multiple IP addresses, only traffic directed to the respective IP address of the NIC is allowed. Value null allows all target IPs. || | portRangeStart | string | Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd value null to allow all ports. || | portRangeEnd | string | Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd null to allow all ports. || | icmpType | string | Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types. || | icmpCode | string | Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes. || After retrieving a firewall rule, either by getting it by id, or as a create response object, you can change its properties and call the `update` method: ``` fwr = compute.firewall_rules.get('datacenter_id', 'server_id', 'nic_id', 'firewall_rule_id') fwr.name = 'Updated firewall rule name' fwr.update ``` --- #### Delete a Firewall Rule Removes the specific firewall rule. | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server_id | string | The unique ID of the server. | Yes | | nic_id | string | The unique ID of the NIC. | Yes | | firewall_rule_id | string | The unique ID of the firewall rule. | Yes | After retrieving a firewall rule, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` fwr = compute.firewall_rules.get('datacenter_id', 'server_id', 'nic_id', 'firewall_rule_id') fwr.delete ``` --- ### Images #### List Images Retrieve a list of images. ``` compute.images.all ``` --- #### Get an Image Retrieves the attributes of a specific image. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | image-id | string | The unique ID of the image. | Yes | ``` compute.images.get('image-id') ``` --- #### Update an Image Perform updates to attributes of an image. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | image-id | string | The unique ID of the image. | Yes | | name | string | The name of the image. || | description | string | The description of the image. || | licencetype | string | The image's licence type: LINUX, WINDOWS, WINDOWS2016, or UNKNOWN. || | cpuHotPlug | bool | This volume is capable of CPU hot plug (no reboot required) || | cpuHotUnplug | bool | This volume is capable of CPU hot unplug (no reboot required) || | ramHotPlug | bool | This volume is capable of memory hot plug (no reboot required) || | ramHotUnplug | bool | This volume is capable of memory hot unplug (no reboot required) || | nicHotPlug | bool | This volume is capable of NIC hot plug (no reboot required) || | nicHotUnplug | bool | This volume is capable of NIC hot unplug (no reboot required) || | discVirtioHotPlug | bool | This volume is capable of Virt-IO drive hot plug (no reboot required) || | discVirtioHotUnplug | bool | This volume is capable of Virt-IO drive hot unplug (no reboot required) || | discScsiHotPlug | bool | This volume is capable of SCSI drive hot plug (no reboot required) || | discScsiHotUnplug | bool | This volume is capable of SCSI drive hot unplug (no reboot required) || After retrieving an image, either by getting it by id, or as a create response object, you can change it's properties and call the `update` method: ``` image = compute.snapshots.get('snapshotId') image.name = 'Updated snapshot name' image.description = 'Updated snapshot description' image.ram_hot_plug = true image.ram_hot_unplug = true image.update ``` --- #### Delete an Image Deletes the specified image. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | image-id | string | The unique ID of the image. | Yes | After retrieving an image, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` image = compute.images.get('image-id') image.delete ``` --- ### Network Interfaces (NICs) #### List NICs Retrieve a list of LANs within the data center. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | ``` compute.nics.all('datacenter_id') ``` --- #### Get a NIC Retrieves the attributes of a given NIC. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server-id | string | The unique ID of the server. | Yes | | nic-id | string | The unique ID of the NIC. | Yes | ``` compute.nics.get('datacenter_id', 'server-id', 'nic-id') ``` --- #### Create a NIC Adds a NIC to the target server. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server_id | string| The unique ID of the server. | Yes | | name | string | The name of the NIC. || | ips | string collection | IPs assigned to the NIC. This can be a collection. || | dhcp | bool | Set to FALSE if you wish to disable DHCP on the NIC. Default: TRUE. || | lan | int | The LAN ID the NIC will sit on. If the LAN ID does not exist it will be created. | Yes | | nat | bool | Indicates the private IP address has outbound access to the public internet. || | firewallActive | bool | Once you add a firewall rule this will reflect a true value. || | firewallrules | string collection | A list of firewall rules associated to the NIC represented as a collection. || ``` compute.nics.create(:datacenter_id => 'datacenter_id', :server_id => 'server_id', :name = 'Internal NIC', :dhcp => true, :lan => 1) ``` --- #### Update a NIC You can update -- in full or partially -- various attributes on the NIC; however, some restrictions are in place: The primary address of a NIC connected to a load balancer can only be changed by changing the IP of the load balancer. You can also add additional reserved, public IPs to the NIC. The user can specify and assign private IPs manually. Valid IP addresses for private networks are 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server_id | string| The unique ID of the server. | Yes | | nic-id | string| The unique ID of the NIC. | Yes | | name | string | The name of the NIC. || | ips | string collection | IPs assigned to the NIC represented as a collection. || | dhcp | bool | Boolean value that indicates if the NIC is using DHCP or not. || | lan | int | The LAN ID the NIC sits on. || | nat | bool | Indicates the private IP address has outbound access to the public internet. || After retrieving a NIC, either by getting it by id, or as a create response object, you can call the `update` method directly on the object: ``` nic = compute.nics.get('datacenter_id', 'server-id', 'nic-id') nic.name = 'Internal NIC updated' nic.ips = ['10.0.0.7'] nic.update ``` --- #### Delete a NIC Deletes the specified NIC. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | server_id | string| The unique ID of the server. | Yes | | nic-id | string| The unique ID of the NIC. | Yes | After retrieving a NIC, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` nic = compute.nics.get('datacenter_id', 'server-id', 'nic-id') nic.delete ``` --- ### IP Blocks #### List IP Blocks Retrieve a list of IP Blocks. ``` compute.ip_blocks.all ``` --- #### Get an IP Block Retrieves the attributes of a specific IP Block. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | ipblock-id | string | The unique ID of the IP block. | Yes | ``` compute.ip_blocks.get('ipblock-id') ``` --- #### Create an IP Block Creates an IP block. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | location | string | This must be one of the locations: us/las, de/fra, de/fkb. | Yes | | size | int | The size of the IP block you want. | Yes | | name | string | A descriptive name for the IP block | No | ``` compute.ip_blocks.create(:location => 'de/fkb', :size => 1, :name => 'Fog test IP block') ``` --- #### Delete an IP Block Deletes the specified IP Block. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | ipblock-id | string | The unique ID of the IP block. | Yes | After retrieving an IP block, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` ipb = compute.ip_blocks.get('ipblock-id') ipb.delete ``` ``` compute.ip_blocks.get('ipblock-id') ``` --- ### Requests #### List Requests Retrieve a list of requests. ``` compute.requests.all ``` --- #### Get a Request Retrieves the attributes of a specific request. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | request-id | string | The unique ID of the request. | Yes | ``` compute.requests.get('request-id') ``` --- #### Get a Request Status Retrieves the status of a request. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | request-id | string | The unique ID of the request. | Yes | ``` compute.requests.get_status('request-id') ``` --- ### LANs #### List LANs Retrieve a list of LANs within the data center. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | ``` compute.lans.all('datacenter_id') ``` --- #### Create a LAN Creates a LAN within a data center. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | name | string | The name of your LAN. || | public | bool | Boolean indicating if the LAN faces the public Internet or not. || | nics | string collection | A collection of NICs associated with the LAN. || ``` compute.lans.create(:datacenter_id => 'datacenter_id', :name => 'My lan', :public => false) ``` --- #### Get a LAN Retrieves the attributes of a given LAN. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | lan-id | string | The unique ID of the LAN. | Yes | ``` compute.lans.get('datacenter_id', 'lan-id') ``` --- #### Update a LAN Perform updates to attributes of a LAN. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | lan-id | string | The unique ID of the LAN. | Yes | | name | string | A descriptive name for the LAN. || | public | bool | Boolean indicating if the LAN faces the public Internet or not. || After retrieving a LAN, either by getting it by id, or as a create response object, you can change it's properties and call the `update` method: ``` lan = compute.lans.get('datacenter_id', 'lan-id') lan.name = 'Updated LAN name' lan.update ``` --- #### Delete a LAN Deletes the specified LAN. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | datacenter_id | string | The unique ID of the data center. | Yes | | lan-id | string | The unique ID of the LAN. | Yes | After retrieving a LAN, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` lan = compute.lans.get('datacenter_id', 'lan-id') lan.delete ``` --- ### Contract Resources Checking the amount of available resources under a contract can help you to avoid provisioning errors resulting from the attempt to provision more resources than are available. #### List Contract Resources Returns information about the resource limits for a particular contract and the current resource usage. ``` compute.contract_resources.all ``` The amount of data included in the response payload will vary slightly depending on the credentials supplied when making the request. If the credentials supplied belong to the "Contract Owner", then all the available information is returned. --- ### User Management #### List Groups Retrieve a full list of all groups. ``` compute.groups.all ``` --- #### Retrieve a Group Retrieves detailed information about a specific group. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | group-id | string | The ID of the specific group to retrieve. | Yes | ``` compute.groups.get('group-id') ``` --- #### Create a Group Create a new group and set group privileges. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | name | string | A name for the group. | Yes | | createDataCenter | bool | The group will be allowed to create virtual data centers. Defaults to `false`. || | createSnapshot | bool | The group will be allowed to create snapshots. Defaults to `false`. || | reserveIp | bool | The group will be allowed to reserve IP addresses. Defaults to `false`. || | accessActivityLog | bool | The group will be allowed to access the activity log. Defaults to `false`. || ``` compute.groups.create(:name => 'fogTestGroup', :create_datacenter => true) ``` --- #### Update a Group Perform updates to attributes of a group. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | group-id | string | The ID of the specific group to update. | Yes | | name | string | A name for the group. | Yes | | createDataCenter | bool | The group will be allowed to create virtual data centers. Defaults to `false`. || | createSnapshot | bool | The group will be allowed to create snapshots. Defaults to `false`. || | reserveIp | bool | The group will be allowed to reserve IP addresses. Defaults to `false`. || | accessActivityLog | bool | The group will be allowed to access the activity log. Defaults to `false`. || After retrieving a group, either by getting it by id, or as a create response object, you can change it's properties and call the `update` method: ``` group = compute.groups.get('group-id') group.name = 'fogTestGroupUpdated' group.reserve_ip = true group.update ``` --- #### Delete a Group Delete a single group.

Resources that are assigned to the group are NOT deleted, but are no longer accessible to the group members unless the member is a Contract Owner, Admin, or Resource Owner. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | group-id | string | The ID of the specific group to delete. | Yes | After retrieving a group, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` group = compute.groups.get('group-id') group.delete ``` --- #### List Shares Retrieves a full list of all the resources that are shared through this group and lists the permissions granted to the group members for each shared resource. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | group-id | string | The ID of the specific group. | Yes | ``` compute.shares.all(group-id ) ``` --- #### Retrieve a Share Retrieves the details of a specific shared resource available to the specified group. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | group-id | string | The ID of the specific group. | Yes | | resource-id | string | The ID of the specific resource. | Yes | ``` compute.shares.get(group-id, resource-id) ``` --- #### Add a Share Adds a specific resource share to a group and optionally allows the setting of permissions for that resource. As an example, you might use this to grant permissions to use an image or snapshot to a specific group. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | group-id | string | The ID of the specific group to add a resource to. | Yes | | resource-id | string | The ID of the specific resource to add. | Yes | | editPrivilege | bool | The group has permission to edit privileges on this resource. || | sharePrivilege | bool | The group has permission to share this resource. || ``` compute.shares.create(:group_id => group-id, :resource_id => resource-id, :share_privilege => true) ``` --- #### Update a Share Update the permissions that a group has for a specific resource share. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | group-id | string | The ID of the specific group to add a resource to. | Yes | | resource-id | string | The ID of the specific resource to add. | Yes | | editPrivilege | bool | The group has permission to edit privileges on this resource. || | sharePrivilege | bool | The group has permission to share this resource. || After retrieving a group, either by getting it by id, or as a create response object, you can change it's properties and call the `update` method: ``` share = compute.shares.get(group-id, resource-id) share.edit_privilege = true share.update ``` --- #### Delete a Share Remove a resource share from a specified group. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | group-id | string | The ID of the specific group to add a resource to. | Yes | | resource-id | string | The ID of the specific resource to add. | Yes | After retrieving a group, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` share = compute.shares.get(group-id, resource-id) share.delete ``` --- #### List Users in a Group Retrieves a full list of all the users that are members of a particular group. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | group-id | string | The ID of the specific group to retrieve a user list for. | Yes | ``` compute.users.list_group_users(group-id) ``` --- #### Add User to Group Add an existing user to a group. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | group-id | string | The ID of the specific group you want to add a user to. | Yes | | user-id | string | The ID of the specific user to add to the group. | Yes | ``` compute.users.add_group_user(group-id, user-id) ``` --- #### Remove User from a Group Remove a user from a group. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | group-id | string | The ID of the specific group you want to remove a user from. | Yes | | user-id | string | The ID of the specific user to remove from the group. | Yes | ``` compute.users.remove_group_user(group-id, user-id) ``` --- #### List Users Retrieve a list of all the users that have been created under a contract. ``` compute.users.all ``` --- #### Retrieve a User Retrieve details about a specific user including what groups and resources the user is associated with. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | user-id | string | The ID of the specific user to retrieve information about. | Yes | ``` compute.users.get(user-id) ``` --- #### Create a User Creates a new user under a particular contract. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | firstname | string | User's first name. | Yes | | lastname | string | User's last name. | Yes | | email | string | User's e-mail address. | Yes | | password | string | A password for the user. | Yes | | administrator | bool | Assign administrative rights to the user. || | forceSecAuth | bool | Indicates if secure (two-factor) authentication should be enforced for the user. || ``` compute.users.create(:firstname => 'Fog', :lastname => 'Testuser', :email => 'email@address.com', :password => 'P4$$w0rd', :administrator => false, :force_sec_auth => false) ``` --- #### Update a User Update details about a specific user including their privileges.

**Note**: The password attribute is immutable. It is not allowed in update requests. It is recommended that a new user log into the DCD and change their password. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | firstname | string | User's first name. | Yes | | lastname | string | User's last name. | Yes | | email | string | User's e-mail address. | Yes | | administrator | bool | Assign administrative rights to the user. | Yes | | forceSecAuth | bool | Indicates if secure (two-factor) authentication should be enforced for the user. | Yes | After retrieving a user, either by getting it by id, or as a create response object, you can change it's properties and call the `update` method: ``` user = compute.users.get(user-id) user.force_sec_auth = true user.update ``` --- #### Delete a User Blacklists the user, disabling them. The user is not completely purged, therefore if a need to create a user with the same name in the future is anticipated, we suggest renaming the user before it is deleted. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | user-id | string | The ID of the specific user to delete. | Yes | After retrieving a user, either by getting it by id, or as a create response object, you can call the `delete` method directly on the object: ``` user = compute.users.get(user-id) user.delete ``` --- #### List Resources Retrieve a list of all resources and optionally their group associations.

**Please Note**: This API call can take a significant amount of time to return when there are a large number of provisioned resources. You may wish to consult the next section on how to list resources of a particular type. ``` compute.resources.all ``` --- #### List All Resources of a Type Retrieve a list of all resources and optionally their group associations.

**Please Note**: This API call can take a significant amount of time to return when there are a large number of provisioned resources. You may wish to consult the next section on how to list resources of a particular type. The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | resource-type | string | The specific type of resources to retrieve information about. | Yes | The values available for resource-type are listed in this table: | RESOURCETYPE| DESCRIPTION | |---|---| | datacenter | A virtual data center. | | image | A private image that has been uploaded to ProfitBricks. | | snapshot | A snapshot of a storage volume. | | ipblock | An IP block that has been reserved. | ``` compute.resources.get_by_type('datacenter') ``` --- #### List a Specific Resource Type The following table describes the request arguments: | NAME| TYPE | DESCRIPTION | REQUIRED | |---|---|---|---| | resource-type | string | The specific type of resources to retrieve information about. | Yes | | resource-id | string | The ID of the specific resource to retrieve information about. | Yes | The values available for resource-type are listed in this table: | RESOURCETYPE| DESCRIPTION | |---|---| | datacenter | A virtual data center. | | image | A private image that has been uploaded to ProfitBricks. | | snapshot | A snapshot of a storage volume. | | ipblock | An IP block that has been reserved. | ``` compute.resources.get_resource_by_type('datacenter', resource-id) ``` --- ## Contributing 1. Fork it ( https://github.com/fog/fog-profitbricks/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request fog-profitbricks-4.1.0/Rakefile000066400000000000000000000010731320736730600164430ustar00rootroot00000000000000require "bundler/gem_tasks" require "rake/testtask" task :default => :travis task :travis => ["test", "test:travis"] task :console do exec "pry -r fog/profitbricks -I ./lib" end Rake::TestTask.new do |t| t.libs.push %w(spec) t.test_files = FileList["spec/**/*_spec.rb"] t.verbose = true end namespace :test do mock = ENV["FOG_MOCK"] || "true" task :travis do sh("export PROFITBRICKS_USERNAME=username && export PROFITBRICKS_PASSWORD=abc123xyz && export FOG_MOCK=#{mock} && bundle exec shindont") end end desc "Default Task" task :default => [:test] fog-profitbricks-4.1.0/examples/000077500000000000000000000000001320736730600166135ustar00rootroot00000000000000fog-profitbricks-4.1.0/examples/pb_demo.rb000066400000000000000000000067711320736730600205600ustar00rootroot00000000000000require 'fog/profitbricks' Excon.defaults[:connection_timeout] = 200 compute = Fog::Compute.new(:provider => 'ProfitBricks', :profitbricks_username => ENV['PROFITBRICKS_USERNAME'], :profitbricks_password => ENV['PROFITBRICKS_PASSWORD']) # Create datacenter. datacenter = compute.datacenters.create(:name => 'fog-demo', :location => 'us/las', :description => 'fog-profitbricks demo') datacenter.wait_for { ready? } # Rename datacenter. datacenter.name = 'rename fog-demo' datacenter.update # Create public LAN. lan = compute.lans.create(:datacenter_id => datacenter.id, :name => 'public', :public => true) # Define system volume. system_volume = { :name => 'system', :size => 5, :image_alias => "ubuntu:latest", :image_password => 'volume2016', :ssh_keys => ['ssh-rsa AAAAB3NzaC1yc2EAAAADA=='], :type => 'HDD' } # Define public firewall rules. fw1 = { :name => 'Allow SSH', :protocol => 'TCP', :port_range_start => 22, :port_range_end => 22 } fw2 = { :name => 'Allow Ping', :protocol => 'ICMP', :icmp_type => 8, :icmp_code => 0 } # Define public network interface. public_nic = { :name => 'public', :lan => lan.id, :dhcp => true, :firewall_active => true, :firewall_rules => [fw1, fw2] } # Create a server with the above system volume and public network interface. server1 = compute.servers.create(:datacenter_id => datacenter.id, :name => 'server1', :cores => 1, :cpu_family => 'AMD_OPTERON', :ram => 2048, :volumes => [system_volume], :nics => [public_nic]) server1.wait_for { ready? } # Change CPU family from AMD_OPTERON to INTEL_XEON. server1.allow_reboot = true server1.cpu_family = 'INTEL_XEON' server1.update # Create data volume. data_volume = compute.volumes.create(:datacenter_id => datacenter.id, :name => 'data', :size => 5, :licence_type => 'OTHER', :type => 'SSD') data_volume.wait_for { ready? } # Attach data volume to server1. server1.attach_volume(data_volume.id) # Connect a second network interface to server1. private_nic = compute.nics.create(:datacenter_id => datacenter.id, :server_id => server1.id, :name => 'private', :dhcp => true, :lan => 2) private_nic.wait_for { ready? } # Create a second server. server2 = compute.servers.create(:datacenter_id => datacenter.id, :name => 'server2', :cores => 1, :cpu_family => 'AMD_OPTERON', :ram => 2048, :volumes => [system_volume]) server2.wait_for { ready? } # Connect a private network interface to server2 with SSH access. private_nic = compute.nics.create(:datacenter_id => datacenter.id, :server_id => server2.id, :name => 'private', :dhcp => true, :lan => 2, :firewall_rules => [fw1]) private_nic.wait_for { ready? } fog-profitbricks-4.1.0/fog-profitbricks.gemspec000066400000000000000000000025021320736730600216130ustar00rootroot00000000000000# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'fog/profitbricks/version' Gem::Specification.new do |spec| spec.name = "fog-profitbricks" spec.version = Fog::ProfitBricks::VERSION spec.authors = ["Ethan Devenport"] spec.email = ["ethand@stackpointcloud.com"] spec.summary = "Module for the 'fog' gem to support ProfitBricks." spec.description = "This library can be used as a module for 'fog' or as standalone ProfitBricks provider." spec.homepage = "https://github.com/fog/fog-profitbricks" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0") spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_runtime_dependency "fog-core", "~> 1.42" spec.add_runtime_dependency "fog-json", "~> 1.0" spec.add_development_dependency "rake", "~> 10.4" spec.add_development_dependency "minitest", "~> 4" spec.add_development_dependency "shindo", "~> 0.3" spec.add_development_dependency "turn", "~> 0.9" spec.add_development_dependency "pry", "~> 0.10" spec.add_development_dependency "rubocop" if RUBY_VERSION >= "2.0.0" end fog-profitbricks-4.1.0/gemfiles/000077500000000000000000000000001320736730600165705ustar00rootroot00000000000000fog-profitbricks-4.1.0/gemfiles/Gemfile.1.9.2+000066400000000000000000000002131320736730600206000ustar00rootroot00000000000000source 'https://rubygems.org' gem 'json', '~> 1.8' gem 'activesupport', '>= 3.0', '< 4' gem 'mime-types', '< 2.0' gemspec :path => '../' fog-profitbricks-4.1.0/lib/000077500000000000000000000000001320736730600155435ustar00rootroot00000000000000fog-profitbricks-4.1.0/lib/fog/000077500000000000000000000000001320736730600163165ustar00rootroot00000000000000fog-profitbricks-4.1.0/lib/fog/bin/000077500000000000000000000000001320736730600170665ustar00rootroot00000000000000fog-profitbricks-4.1.0/lib/fog/bin/profitbricks.rb000066400000000000000000000014371320736730600221210ustar00rootroot00000000000000class ProfitBricks < Fog::Bin class << self def class_for(key) case key when :compute Fog::Compute::ProfitBricks else raise ArgumentError, "Unrecognized service: #{key}" end end def [](service) @@connections ||= Hash.new do |hash, key| hash[key] = case key when :compute Fog::Logger.warning("ProfitBricks[:compute] is not recommended, use Fog::Compute[:profitbricks] for portability") Fog::Compute.new(:provider => 'ProfitBricks') else raise ArgumentError, "Unrecognized service: #{key.inspect}" end end @@connections[service] end def services Fog::ProfitBricks.services end end end fog-profitbricks-4.1.0/lib/fog/profitbricks.rb000066400000000000000000000006751320736730600213540ustar00rootroot00000000000000require "fog/core" require "fog/json" require File.expand_path('../profitbricks/version', __FILE__) module Fog module Compute autoload :ProfitBricks, File.expand_path('../profitbricks/compute', __FILE__) end module Models module ProfitBricks autoload :Base, File.expand_path('../profitbricks/models/base', __FILE__) end end module ProfitBricks extend Fog::Provider service(:compute, "Compute") end end fog-profitbricks-4.1.0/lib/fog/profitbricks/000077500000000000000000000000001320736730600210175ustar00rootroot00000000000000fog-profitbricks-4.1.0/lib/fog/profitbricks/compute.rb000066400000000000000000001753501320736730600230330ustar00rootroot00000000000000module Fog module Compute class ProfitBricks < Fog::Service API_VERSION = 'v4'.freeze autoload :Base, File.expand_path('../models/base', __FILE__) requires :profitbricks_username, :profitbricks_password recognizes :profitbricks_url, :profitbricks_user_agent # Models model_path 'fog/profitbricks/models/compute' model :server collection :servers model :datacenter collection :datacenters model :region collection :regions model :image collection :images model :flavor collection :flavors model :volume collection :volumes model :lan collection :lans model :nic collection :nics model :location collection :locations model :snapshot collection :snapshots model :request collection :requests model :ip_block collection :ip_blocks model :firewall_rule collection :firewall_rules model :load_balancer collection :load_balancers model :contract_resource collection :contract_resources model :group collection :groups model :share collection :shares model :user collection :users model :resource collection :resources # Requests request_path 'fog/profitbricks/requests/compute' request :create_server # createServer request :delete_server # deleteServer request :update_server # updateServer request :get_all_servers # getAllServers request :get_server # getServer request :list_attached_volumes # listAttachedVolumes request :attach_volume # attachVolume request :get_attached_volume # getAttachedVolume request :detach_volume # detachVolume request :list_attached_cdroms # listAttachedCdroms request :attach_cdrom # attachCdrom request :get_attached_cdrom # getAttachedCdrom request :detach_cdrom # detachCdrom request :reboot_server # rebootServer request :start_server # startServer request :stop_server # stopServer request :create_datacenter # createDataCenter request :delete_datacenter # deleteDataCenter request :update_datacenter # updateDataCenter request :get_all_datacenters # getAllDataCenters request :get_datacenter # getDataCenter request :get_all_locations # getAllLocations request :get_location # getLocation request :get_all_images # getAllImages request :get_image # getImage request :update_image # updateImage request :delete_image # deleteImage request :get_all_flavors # getAllFlavors request :get_flavor # getFlavor request :create_flavor # createFlavor request :create_volume # createVolume request :delete_volume # deleteVolume request :update_volume # updateVolume request :get_all_volumes # getAllVolumes request :get_volume # getVolume request :create_volume_snapshot # createVolumeSnapshot request :restore_volume_snapshot # restoreVolumeSnapshot request :get_all_lans # getAllLans request :get_lan # getLans request :create_lan # createLan request :update_lan # updateLan request :delete_lan # deleteLan request :create_nic # createNic request :delete_nic # deleteNic request :update_nic # updateNic request :get_all_nic # getAllNic request :get_nic # getNic request :delete_snapshot # deleteSnapshot request :update_snapshot # updateSnapshot request :get_all_snapshots # getAllSnapshots request :get_snapshot # getSnapshot request :get_all_requests # getAllRequests request :get_request # getRequest request :get_request_status # getRequestStatus request :get_all_ip_blocks # getAllIpBlocks request :get_ip_block # getIpBlock request :create_ip_block # createIpBlock request :delete_ip_block # deleteIpBlock request :get_all_firewall_rules # getAllFireWallRules request :get_firewall_rule # getFirewallRule request :create_firewall_rule # createFirewallRule request :update_firewall_rule # updateFirewallRule request :delete_firewall_rule # deleteFirewallRule request :get_all_load_balancers # getAllLoadBalancers request :get_load_balancer # getLoadBalancer request :create_load_balancer # createLoadBalancer request :delete_load_balancer # deleteLoadBalancer request :update_load_balancer # deleteLoadBalancer request :get_all_load_balanced_nics # getAllLoadBalancedNics request :get_load_balanced_nic # getLoadBalancedNic request :associate_nic_to_load_balancer # associateNicToLoadBalancer request :remove_nic_association # removeNicAssociation request :get_all_contract_resources # getAllContractResources request :get_all_groups # getAllGroups request :get_group # getGroup request :create_group # createGroup request :update_group # updateGroup request :delete_group # deleteGroup request :get_all_shares # getAllShares request :get_share # getShare request :add_share # addShare request :update_share # updateShare request :delete_share # deleteShare request :get_all_users # getAllUsers request :get_user # getUser request :create_user # createUser request :update_user # updateUser request :delete_user # deleteUser request :get_group_users # getGroupUsers request :add_user_to_group # addUserToGroup request :remove_user_from_group # removeUserFromGroup request :get_all_resources # getAllResources request :get_resources_by_type # getResourcesByType request :get_resource_by_type # getResourcesByType class Real def initialize(options = {}) @profitbricks_username = options[:profitbricks_username] @profitbricks_password = options[:profitbricks_password] @profitbricks_url = options[:profitbricks_url] || "https://api.profitbricks.com" @user_agent = options[:profitbricks_user_agent] || "" connection_options = options[:connection_options] || {} connection_options[:headers] ||= {} connection_options[:headers]["User-Agent"] = @user_agent != "" ? @user_agent + " " + Fog::Core::Connection.user_agents.to_s : Fog::Core::Connection.user_agents.to_s connection_options[:omit_default_port] = true connection_options[:path_prefix] = "/cloudapi/#{API_VERSION}" @connection = Fog::Core::Connection.new(@profitbricks_url, false, connection_options) end def request(params) params[:headers] ||= {} params[:headers]["Authorization"] = "Basic #{auth_header}" params[:path_style] = false begin response = @connection.request(params) rescue Excon::Errors::Unauthorized => error Logger.warning('Unauthorized error') raise error, Fog::JSON.decode(error.response.body)['messages'] rescue Excon::Errors::HTTPStatusError => error Logger.warning('HTTPStatusError error') raise error, Fog::JSON.decode(error.response.body)['messages'] rescue Excon::Errors::InternalServerError => error Logger.warning('InternalServerError error') raise error, Fog::JSON.decode(error.response.body)['messages'] rescue Fog::Errors::NotFound => error Logger.warning('NotFound error') raise error, Fog::JSON.decode(error.response.body)['messages'] end if response && response.body && !response.body.empty? response.body = Fog::JSON.decode(response.body) response.body['requestId'] = get_request_id(response.headers) end response end private def auth_header Base64.strict_encode64( "#{@profitbricks_username}:#{@profitbricks_password}" ) end def get_request_id(headers) location = headers['Location'] location.match(/requests\/([-a-f0-9]+)/i)[1] unless location.nil? end end class Mock def self.data dc1_id = Fog::UUID.uuid dc2_id = Fog::UUID.uuid serv1_id = Fog::UUID.uuid vol1_id = Fog::UUID.uuid vol2_id = Fog::UUID.uuid req1_id = Fog::UUID.uuid req2_id = Fog::UUID.uuid nic1_id = Fog::UUID.uuid nic2_id = Fog::UUID.uuid ipb1_id = Fog::UUID.uuid ipb2_id = Fog::UUID.uuid fwr1_id = Fog::UUID.uuid fwr2_id = Fog::UUID.uuid lb1_id = Fog::UUID.uuid lb2_id = Fog::UUID.uuid @data ||= Hash.new do |hash, key| hash[key] = { :datacenters => { "id" => "datacenters", "type" => "collection", "href" => "https://api.profitbricks.com/rest/v2/datacenters", "items" => [ { 'id' => dc1_id, 'type' => 'datacenter', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}", 'metadata' => { 'createdDate' => '2016-07-31T15:41:27Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '5b91832ee85a758568d4523a86bd8702', 'lastModifiedDate' => '2016-07-31T15:41:27Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'dc_1', 'description' => 'testing fog rest implementation', 'location' => 'us/las', 'version' => 1, 'features' => %w(SSD MULTIPLE_CPU) } }, { 'id' => dc2_id, 'type' => 'datacenter', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc2_id}", 'metadata' => { 'createdDate' => '2016-07-31T15:41:27Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '5b91832ee85a758568d4523a86bd8702', 'lastModifiedDate' => '2016-07-31T15:41:27Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'dc_2', 'description' => 'testing fog rest implementation', 'location' => 'de/fkb', 'version' => 1, 'features' => %w(SSD MULTIPLE_CPU) } } ] }, :servers => { 'id' => 'servers', 'type' => 'collection', "href" => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers", 'items' => [ { 'id' => serv1_id, 'type' => 'server', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}", 'metadata' => { 'createdDate' => '2014-10-20T21:20:46Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '0018832d7a7ba455db74ac41ae9f11fe', 'lastModifiedDate' => '2015-03-18T21:31:10Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'FogTestServer_1', 'cores' => 1, 'ram' => 1024, 'availabilityZone' => 'AUTO', 'vmState' => 'RUNNING', 'bootVolume' => { 'id' => 'c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1', 'type' => 'volume', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1", 'metadata' => { 'createdDate' => '2014-10-20T21:20:46Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '7a539b539d8ca9e08c5ac5e63c9c4c8f', 'lastModifiedDate' => '2014-10-20T21:20:46Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'Storage', 'type' => 'HDD', 'size' => 50, 'image' => '4f363db0-4955-11e4-b362-52540066fee9', 'bus' => 'VIRTIO', 'licenceType' => 'LINUX', 'cpuHotPlug' => 'true', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'true', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'true', 'nicHotUnplug' => 'true', 'discVirtioHotPlug' => 'true', 'discVirtioHotUnplug' => 'true', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'deviceNumber' => 1 } }, 'cpuFamily' => 'AMD_OPTERON' }, 'entities' => { 'cdroms' => { 'id' => "#{serv1_id}/cdroms", 'type' => 'collection', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/cdroms", 'items' => [] }, 'volumes' => { 'id' => "#{serv1_id}/volumes", 'type' => 'collection', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/volumes", 'items' => [ { 'id' => 'c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1', 'type' => 'volume', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1", 'metadata' => { 'createdDate' => '2014-10-20T21:20:46Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '7a539b539d8ca9e08c5ac5e63c9c4c8f', 'lastModifiedDate' => '2014-10-20T21:20:46Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'Storage', 'type' => 'HDD', 'size' => 50, 'image' => '4f363db0-4955-11e4-b362-52540066fee9', 'bus' => 'VIRTIO', 'licenceType' => 'LINUX', 'cpuHotPlug' => 'true', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'true', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'true', 'nicHotUnplug' => 'true', 'discVirtioHotPlug' => 'true', 'discVirtioHotUnplug' => 'true', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'deviceNumber' => 1 } }, { 'id' => '5c4d37ca-d620-4546-8b24-f92e3c608c2c', 'type' => 'volume', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/5c4d37ca-d620-4546-8b24-f92e3c608c2c", 'metadata' => { 'createdDate' => '2015-03-18T21:31:10Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '0018832d7a7ba455db74ac41ae9f11fe', 'lastModifiedDate' => '2015-03-18T21:31:10Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'Docker Registry Volume', 'type' => 'HDD', 'size' => 50, 'bus' => 'VIRTIO', 'licenceType' => 'OTHER', 'cpuHotPlug' => 'false', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'false', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'false', 'nicHotUnplug' => 'false', 'discVirtioHotPlug' => 'false', 'discVirtioHotUnplug' => 'false', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'deviceNumber' => 2 } } ] }, 'nics' => { 'id' => "#{serv1_id}/nics", 'type' => 'collection', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics", 'items' => [ { 'id' => '01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d', 'type' => 'nic', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d", 'metadata' => { 'createdDate' => '2015-02-09T22:46:38Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'b4854a82738079d2c7f43b5324bd92e3', 'lastModifiedDate' => '2015-02-09T22:46:38Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'mac' => '00:02:94:9e:f4:b0', 'ips' => ['210.94.35.77'], 'dhcp' => 'true', 'lan' => 1, 'firewallActive' => 'false' }, 'entities' => { 'firewallrules' => { 'id' => '01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d/firewallrules', 'type' => 'collection', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/664f0f1c-7384-462b-8f0c-cfc4c3f6e2a3/nics/01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d/firewallrules", 'items' => [] } } } ] } }, 'datacenter_id' => dc1_id } ] }, :locations => { "id" => "locations", "type" => "collection", "href" => "https://api.profitbricks.com/rest/v2/locations", "items" => [ { 'id' => 'de/fkb', 'type' => 'location', 'href' => 'https://api.profitbricks.com/rest/v2/locations/de/fkb', 'properties' => { 'name' => 'karlsruhe', 'features' => %w(SSD MULTIPLE_CPU) } }, { 'id' => 'de/fra', 'type' => 'location', 'href' => 'https://api.profitbricks.com/rest/v2/locations/de/fra', 'properties' => { 'name' => 'frankfurt', 'features' => %w(SSD MULTIPLE_CPU) } }, { 'id' => 'us/las', 'type' => 'location', 'href' => 'https://api.profitbricks.com/rest/v2/locations/us/las', 'properties' => { 'name' => 'lasvegas', 'features' => %w(SSD MULTIPLE_CPU) } } ] }, :images => { "id" => "images", "type" => "collection", "href" => "https://api.profitbricks.com/rest/v2/images", "items" => [ { 'id' => 'dfcb40db-28b5-11e6-9336-52540005ab80', 'type' => 'image', 'href' => 'https=>//api.profitbricks.com/rest/v2/images/dfcb40db-28b5-11e6-9336-52540005ab80', 'metadata' => { 'createdDate' => '2016-06-02T11:33:49Z', 'createdBy' => 'System', 'etag' => '9909709d99655c6f31aca789998d7d89', 'lastModifiedDate' => '2016-06-02T11:33:49Z', 'lastModifiedBy' => 'System', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'CentOS-6.8-x86_64-netinstall.iso', 'description' => '', 'location' => 'us/las', 'size' => 0.23, 'cpuHotPlug' => 'true', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'true', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'true', 'nicHotUnplug' => 'true', 'discVirtioHotPlug' => 'true', 'discVirtioHotUnplug' => 'true', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'licenceType' => 'LINUX', 'imageType' => 'CDROM', 'public' => 'true' } }, { 'id' => 'dfcb40db-28b5-11e6-9336-52540005ab80', 'type' => 'image', 'href' => 'https=>//api.profitbricks.com/rest/v2/images/dfcb40db-28b5-11e6-9336-52540005ab80', 'metadata' => { 'createdDate' => '2016-06-02T11:33:49Z', 'createdBy' => 'System', 'etag' => '9909709d99655c6f31aca789998d7d89', 'lastModifiedDate' => '2016-06-02T11:33:49Z', 'lastModifiedBy' => 'System', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'CentOS-6.8-x86_64-netinstall.iso', 'description' => '', 'location' => 'us/las', 'size' => 0.23, 'cpuHotPlug' => 'true', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'true', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'true', 'nicHotUnplug' => 'true', 'discVirtioHotPlug' => 'true', 'discVirtioHotUnplug' => 'true', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'licenceType' => 'LINUX', 'imageType' => 'HDD', 'public' => 'true' } }, { 'id' => '05cadf29-6c12-11e4-beeb-52540066fee9', 'type' => 'image', 'href' => 'https=>//api.profitbricks.com/rest/v2/images/05cadf29-6c12-11e4-beeb-52540066fee9', 'metadata' => { 'createdDate' => '2014-11-14T15:22:19Z', 'createdBy' => 'System', 'etag' => '957e0eac7456fa7554e73bf0d18860eb', 'lastModifiedDate' => '2014-11-14T15=>22=>19Z', 'lastModifiedBy' => 'System', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'Microsoft-SQL-2012-Full-trial-english.iso', 'description' => '', 'location' => 'us/las', 'size' => 4, 'cpuHotPlug' => 'false', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'false', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'false', 'nicHotUnplug' => 'false', 'discVirtioHotPlug' => 'false', 'discVirtioHotUnplug' => 'false', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'licenceType' => 'OTHER', 'imageType' => 'CDROM', 'public' => 'true' } } ] }, :flavors => [ { 'flavorId' => Fog::UUID.uuid, 'flavorName' => 'Micro', 'ram' => 1024, 'disk' => 50, 'cores' => 1 }, { 'flavorId' => Fog::UUID.uuid, 'flavorName' => 'Small', 'ram' => 2048, 'disk' => 50, 'cores' => 1 } ], :volumes => { "id" => "#{dc1_id}/volumes", "type" => 'collection', "href" => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes", "items" => [ { 'id' => vol1_id, 'type' => 'volume', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/#{vol1_id}", 'metadata' => { 'createdDate' => '2015-03-18T19:00:51Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'c4a2fde6ba91a038ff953b939cc21efe', 'lastModifiedDate' => '2015-03-18T19=>00=>51Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'master 1 Storage', 'type' => 'HDD', 'size' => 50, 'image' => '681673e7-bfc2-11e4-850c-52540066fee9', 'bus' => 'VIRTIO', 'licenceType' => 'OTHER', 'cpuHotPlug' => 'true', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'false', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'true', 'nicHotUnplug' => 'true', 'discVirtioHotPlug' => 'true', 'discVirtioHotUnplug' => 'true', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'deviceNumber' => 1 }, 'datacenter_id' => dc1_id }, { 'id' => vol2_id, 'type' => 'volume', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/#{vol2_id}", 'metadata' => { 'createdDate' => '2015-03-18T21:31:10Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '0018832d7a7ba455db74ac41ae9f11fe', 'lastModifiedDate' => '2015-03-18T21:31:10Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'Docker Registry Volume', 'type' => 'HDD', 'size' => 50, 'bus' => 'VIRTIO', 'licenceType' => 'OTHER', 'cpuHotPlug' => 'false', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'false', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'false', 'nicHotUnplug' => 'false', 'discVirtioHotPlug' => 'false', 'discVirtioHotUnplug' => 'false', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'deviceNumber' => 2 }, 'datacenter_id' => dc1_id } ] }, :lans => { 'id' => "#{dc1_id}/lans", 'type' => 'collection', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/lans", 'items' => [ { 'id' => '9', 'type' => 'nic', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/lans/9", 'metadata' => { 'createdDate' => '2015-03-18T19:00:51Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'faa67fbacb1c0e2e02cf9650657251f1', 'lastModifiedDate' => '2015-03-18T19:00:51Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'FogTestLAN_1', 'public' => 'true' }, 'entities' => { 'nics' => { 'id' => '9/nics', 'type' => 'collection', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/lans/9/nics", 'items' => [] } }, 'datacenter_id' => dc1_id } ] }, :nics => { 'id' => "#{serv1_id}/nics", 'type' => 'collection', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics", 'items' => [ { 'id' => nic1_id, 'type' => 'nic', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}", 'metadata' => { 'createdDate' => '2015-03-18T19:00:51Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'faa67fbacb1c0e2e02cf9650657251f1', 'lastModifiedDate' => '2015-03-18T19:00:51Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'FogTestNIC_1', 'mac' => '02:01:36:5f:09:da', 'ips' => ['10.9.194.12'], 'dhcp' => 'true', 'lan' => 2, 'firewallActive' => 'false' }, 'entities' => { 'firewallrules' => { 'id' => "#{nic1_id}/firewallrules", 'type' => 'collection', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}/firewallrules", 'items' => [] } }, 'datacenter_id' => dc1_id }, { 'id' => nic2_id, 'type' => 'nic', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic2_id}", 'metadata' => { 'createdDate' => '2015-03-18T19:00:51Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'faa67fbacb1c0e2e02cf9650657251f1', 'lastModifiedDate' => '2015-03-18T19:00:51Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'FogTestNIC_2', 'mac' => '03:01:60:bf:d4:8a', 'ips' => ['192.96.159.188'], 'dhcp' => 'true', 'lan' => 1, 'firewallActive' => 'false' }, 'entities' => { 'firewallrules' => { 'id' => 'cf6d01d3-295d-48bd-8d07-568cce63cbbc/firewallrules', 'type' => 'collection', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic2_id}/firewallrules", 'items' => [] } }, 'datacenter_id' => dc1_id } ] }, :snapshots => { 'id' => 'snapshots', 'type' => 'collection', 'href' => 'https =>//api.profitbricks.com/rest/v2/snapshots', 'items' => [ { 'id' => '3d52b13d-bec4-49de-ad05-fd2f8c687be6', 'type' => 'snapshot', 'href' => 'https =>//api.profitbricks.com/rest/v2/snapshots/3d52b13d-bec4-49de-ad05-fd2f8c687be6', 'metadata' => { 'createdDate' => '2016-08-07T22:28:38Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '83ad78a4757ab0d9bdeaebc3a6485dcf', 'lastModifiedDate' => '2016-08-07T22:28:38Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'FogTestSnapshot', 'description' => 'Testing fog create volume snapshot', 'location' => 'de/fkb', 'size' => 5, 'cpuHotPlug' => 'false', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'false', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'false', 'nicHotUnplug' => 'false', 'discVirtioHotPlug' => 'false', 'discVirtioHotUnplug' => 'false', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'licenceType' => 'LINUX' } } ] }, :requests => { 'id' => 'requests', 'type' => 'collection', 'href' => 'https=>//api.profitbricks.com/rest/v2/requests', 'items' => [ { 'id' => req1_id, 'type' => 'request', 'href' => "https=>//api.profitbricks.com/rest/v2/requests/#{req1_id}", 'metadata' => { 'createdDate' => '2016-08-07T23:32:17Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '37a6259cc0c1dae299a7866489dff0bd', 'requestStatus' => { 'id' => "#{req1_id}/status", 'type' => 'request-status', 'href' => "https://api.profitbricks.com/rest/v2/requests/#{req1_id}/status" } }, 'properties' => { 'method' => 'POST', 'headers' => { 'content-type' => 'application/x-www-form-urlencoded', 'connection' => 'Keep-Alive', 'host' => 'api.profitbricks.com', 'x-forwarded-for' => '100.00.00.01', 'content-length' => '47', 'x-forwarded-host' => 'api.profitbricks.com', 'x-reseller' => 'pb.domain', 'user-agent' => 'fog-core/1.42.0', 'x-forwarded-server' => 'my.profitbricks.com' }, 'body' => '{\'snapshotId\': \'3d52b13d-bec4-49de-ad05-fd2f8c687be6\'}', 'url' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/#{vol1_id}/restore-snapshot" } }, { 'id' => req2_id, 'type' => 'request', 'href' => "https=>//api.profitbricks.com/rest/v2/requests/#{req2_id}", 'metadata' => { 'createdDate' => '2016-08-07T23:32:17Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '37a6259cc0c1dae299a7866489dff0bd', 'requestStatus' => { 'id' => "#{req2_id}/status", 'type' => 'request-status', 'href' => "https://api.profitbricks.com/rest/v2/requests/#{req2_id}/status" } }, 'properties' => { 'method' => 'POST', 'headers' => { 'content-type' => 'application/x-www-form-urlencoded', 'connection' => 'Keep-Alive', 'host' => 'api.profitbricks.com', 'x-forwarded-for' => '100.00.00.01', 'content-length' => '47', 'x-forwarded-host' => 'api.profitbricks.com', 'x-reseller' => 'pb.domain', 'user-agent' => 'fog-core/1.42.0', 'x-forwarded-server' => 'my.profitbricks.com' }, 'body' => '{\'snapshotId\': \'3d52b13d-bec4-49de-ad05-fd2f8c687be6\'}', 'url' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/#{vol2_id}/restore-snapshot" } } ] }, :request_status => { 'id' => "#{req1_id}/status", 'type' => 'request-status', 'href' => "https=>//api.profitbricks.com/rest/v2/requests/#{req1_id}/status", 'metadata' => { 'status' => 'DONE', 'message' => 'Request has been successfully executed', 'etag' => '2ba22e58ca17bb728d522bba36cf8350', 'targets' => [ { 'target' => { 'id' => '752df03a-b9a6-48ee-b9f5-58433184aa1a', 'type' => 'volume', 'href' => 'TO_BE_INJECTED' }, 'status' => 'DONE' } ] } }, :ip_blocks => { 'id' => 'ipblocks', 'type' => 'collection', 'href' => 'https://api.profitbricks.com/rest/v2/ipblocks', 'items' => [ { 'id' => ipb1_id, 'type' => 'ipblock', 'href' => "https://api.profitbricks.com/rest/v2/ipblocks/#{ipb1_id}", 'metadata' => { 'createdDate' => '2016-07-31T15:41:27Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '5b91832ee85a758568d4523a86bd8702', 'lastModifiedDate' => '2016-07-31T15:41:27Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'ips' => ["111.111.111.111", "222.222.222.222"], 'location' => 'us/las', 'size' => 2, 'name' => 'Fog test IP Block 1' } }, { 'id' => ipb2_id, 'type' => 'ipblock', 'href' => "https://api.profitbricks.com/rest/v2/ipblocks/#{ipb2_id}", 'metadata' => { 'createdDate' => '2016-07-31T15:41:27Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '5b91832ee85a758568d4523a86bd8702', 'lastModifiedDate' => '2016-07-31T15:41:27Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'ips' => ["333.333.333.333"], 'location' => 'us/las', 'size' => 1, 'name' => 'Fog test IP Block 2' } } ] }, :firewall_rules => { 'id' => "#{nic1_id}/firewallrules", 'type' => 'collection', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}/firewallrules", 'items' => [ { 'id' => fwr1_id, 'type' => 'firewall-rule', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}/firewallrules/#{fwr1_id}", 'metadata' => { 'createdDate' => '2016-07-31T15:41:27Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '5b91832ee85a758568d4523a86bd8703', 'lastModifiedDate' => '2016-07-31T15:41:27Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'Fog test Firewall Rule 1', 'protocol' => 'TCP', 'sourceMac' => 'null', 'sourceIp' => 'null', 'targetIp' => 'null', 'icmpCode' => 'null', 'icmpType' => 'null', 'portRangeStart' => 22, 'portRangeEnd' => 22 }, 'datacenter_id' => dc1_id, 'server_id' => serv1_id, 'nic_id' => nic1_id }, { 'id' => fwr2_id, 'type' => 'firewall-rule', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}/firewallrules/#{fwr2_id}", 'metadata' => { 'createdDate' => '2016-07-31T15:41:27Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '5b91832ee85a758568d4523a86bd8701', 'lastModifiedDate' => '2016-07-31T15:41:27Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'Fog test Firewall Rule 2', 'protocol' => 'TCP', 'sourceMac' => 'null', 'sourceIp' => 'null', 'targetIp' => 'null', 'icmpCode' => 'null', 'icmpType' => 'null', 'portRangeStart' => 24, 'portRangeEnd' => 25 }, 'datacenter_id' => dc1_id, 'server_id' => serv1_id, 'nic_id' => nic1_id } ] }, :load_balancers => { 'id' => "#{dc1_id}/loadbalancers", 'type' => 'collection', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/loadbalancers", 'items' => [ { 'id' => lb1_id, 'type' => 'loadbalancer', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/loadbalancers/#{lb1_id}", 'metadata' => { 'createdDate' => '2016-07-31T15:41:27Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '5b91832ee85a758568d4523a86bd8723', 'lastModifiedDate' => '2016-07-31T15:41:27Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'Fog test Load Balancer 1', 'ip' => 'null', 'dhcp' => 'true' }, 'entities' => { 'balancednics' => { 'id' => "#{lb1_id}/balancednics", 'type' => 'collection', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/loadbalancers/#{lb1_id}/balancednics", 'items' => [ { 'id' => nic1_id, 'type' => 'nic', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}", 'metadata' => { 'createdDate' => '2015-03-18T19:00:51Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'faa67fbacb1c0e2e02cf9650657251f1', 'lastModifiedDate' => '2015-03-18T19:00:51Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'FogTestLoadBalancedNIC_1', 'mac' => '02:01:36:5f:09:da', 'ips' => ['10.9.194.12'], 'dhcp' => 'true', 'lan' => 2, 'firewallActive' => 'false' }, 'entities' => { 'firewallrules' => { 'id' => "#{nic1_id}/firewallrules", 'type' => 'collection', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}/firewallrules", 'items' => [] } }, 'datacenter_id' => dc1_id, 'load_balancer_id' => lb1_id } ] } }, 'datacenter_id' => dc1_id }, { 'id' => lb2_id, 'type' => 'loadbalancer', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/loadbalancers/#{lb2_id}", 'metadata' => { 'createdDate' => '2016-07-31T15:41:27Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '5b91832ee85a758568d4523a86bd8721', 'lastModifiedDate' => '2016-07-31T15:41:27Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'INACTIVE' }, 'properties' => { 'name' => 'Fog test Load Balancer 2', 'ip' => 'null', 'dhcp' => 'false' }, 'entities' => { 'balancednics' => { 'id' => "#{lb2_id}/balancednics", 'type' => 'collection', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/loadbalancers/#{lb2_id}/balancednics", 'items' => [] } }, 'datacenter_id' => dc1_id } ] }, :contracts => { 'type' => 'contract', 'contractNumber' => '12345678', 'owner' => 'test@domain.com', 'status' => 'BILLABLE', 'resourceLimits' => { 'coresPerServer' => '20', 'coresPerContract' => '30', 'coresProvisioned' => '0', 'ramPerServer' => '204800', 'ramPerContract' => '3072000', 'ramProvisioned' => '0', 'hddLimitPerVolume' => '2048000', 'hddLimitPerContract' => '3072000', 'hddVolumeProvisioned' => '0', 'ssdLimitPerVolume' => '2048000', 'ssdLimitPerContract' => '3072000', 'ssdVolumeProvisioned' => '0', 'reservableIps' => '3', 'reservedIpsOnContract' => '0', 'reservedIpsInUse' => '0', } }, :groups => { 'id' => "groups", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups", 'items' => [] }, :shares => { 'id' => "059c4d71-f97a-4bfd-b3a5-XXXXXXXXXXXX/shares", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups/059c4d71-f97a-4bfd-b3a5-XXXXXXXXXXXX/shares", 'items' => [] }, :users => { 'id' => "users", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/users", 'items' => [] }, :resources => { 'id' => "resources", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/resources", 'items' => [ { 'id' => dc1_id, 'type' => 'datacenter', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/resources/datacenter/#{dc1_id}", 'metadata' => { 'createdDate' => '2016-07-31T15:41:27Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '5b91832ee85a758568d4523a86bd8702', 'lastModifiedDate' => '2016-07-31T15:41:27Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'entities' => { 'groups' => { 'id' => "#{dc1_id}/groups", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups", 'items' => [] } } }, { 'id' => 'dfcb40db-28b5-11e6-9336-52540005ab80', 'type' => 'image', 'href' => 'https://api.profitbricks.com/cloudapi/v4/um/resources/image/dfcb40db-28b5-11e6-9336-52540005ab80', 'metadata' => { 'createdDate' => '2016-06-02T11:33:49Z', 'createdBy' => 'System', 'etag' => '9909709d99655c6f31aca789998d7d89', 'lastModifiedDate' => '2016-06-02T11:33:49Z', 'lastModifiedBy' => 'System', 'state' => 'AVAILABLE' }, 'entities' => { 'groups' => { 'id' => "dfcb40db-28b5-11e6-9336-52540005ab80/groups", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups", 'items' => [] } } }, { 'id' => '3d52b13d-bec4-49de-ad05-fd2f8c687be6', 'type' => 'snapshot', 'href' => 'https://api.profitbricks.com/cloudapi/v4/um/resources/snapshot/3d52b13d-bec4-49de-ad05-fd2f8c687be6', 'metadata' => { 'createdDate' => '2016-08-07T22:28:38Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '83ad78a4757ab0d9bdeaebc3a6485dcf', 'lastModifiedDate' => '2016-08-07T22:28:38Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'entities' => { 'groups' => { 'id' => "3d52b13d-bec4-49de-ad05-fd2f8c687be6/groups", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups", 'items' => [] } } }, { 'id' => ipb1_id, 'type' => 'ipblock', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/resources/ipblock/#{ipb1_id}", 'metadata' => { 'createdDate' => '2016-07-31T15:41:27Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '5b91832ee85a758568d4523a86bd8702', 'lastModifiedDate' => '2016-07-31T15:41:27Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'entities' => { 'groups' => { 'id' => "#{ipb1_id}/groups", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups", 'items' => [] } } } ] } } end end def self.reset @data = nil end def initialize(options = {}) @profitbricks_username = options[:profitbricks_username] @profitbricks_password = options[:profitbricks_password] end def data self.class.data[@profitbricks_username] end def reset_data self.class.data.delete(@profitbricks_username) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/helpers/000077500000000000000000000000001320736730600224615ustar00rootroot00000000000000fog-profitbricks-4.1.0/lib/fog/profitbricks/helpers/compute/000077500000000000000000000000001320736730600241355ustar00rootroot00000000000000fog-profitbricks-4.1.0/lib/fog/profitbricks/helpers/compute/data_helper.rb000066400000000000000000000004751320736730600267400ustar00rootroot00000000000000module Fog module Helpers module ProfitBricks module DataHelper def flatten(response_json) %w(properties metadata entities resourceLimits).each { |k| response_json.merge!(response_json.delete(k)) if response_json.key?(k) } response_json end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/000077500000000000000000000000001320736730600223025ustar00rootroot00000000000000fog-profitbricks-4.1.0/lib/fog/profitbricks/models/base.rb000066400000000000000000000020271320736730600235420ustar00rootroot00000000000000module Fog module Models module ProfitBricks class Base < Fog::Model def wait_for(timeout = Fog.timeout, interval = Fog.interval, &block) reload_has_succeeded = false duration = Fog.wait_for(timeout, interval) do # Note that duration = false if it times out if ready? reload_has_succeeded = true instance_eval(&block) else false end end if reload_has_succeeded return duration # false if timeout; otherwise {:duration => elapsed time } else raise Fog::Errors::Error, "Reload failed, #{self.class} #{identity} not present." end end def request_status(request_id) request = service.requests.get_status(request_id) request.status end def ready? request_status(request_id) == 'DONE' end def failed? request_status(request_id) == 'FAILED' end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/000077500000000000000000000000001320736730600237565ustar00rootroot00000000000000fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/contract_resource.rb000066400000000000000000000032251320736730600300310ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class ContractResource < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper # properties attribute :contract_number, :aliases => 'contractNumber' attribute :owner attribute :status attribute :cores_per_server, :aliases => 'coresPerServer' attribute :cores_per_contract, :aliases => 'coresPerContract' attribute :cores_provisioned, :aliases => 'coresProvisioned' attribute :ram_per_server, :aliases => 'ramPerServer' attribute :ram_per_contract, :aliases => 'ramPerContract' attribute :ram_provisioned, :aliases => 'ramProvisioned' attribute :hdd_limit_per_volume, :aliases => 'hddLimitPerVolume' attribute :hdd_limit_per_contract, :aliases => 'hddLimitPerContract' attribute :hdd_volume_provisioned, :aliases => 'hddVolumeProvisioned' attribute :ssd_limit_per_volume, :aliases => 'ssdLimitPerVolume' attribute :ssd_limit_per_contract, :aliases => 'ssdLimitPerContract' attribute :ssd_volume_provisioned, :aliases => 'ssdVolumeProvisioned' attribute :reservable_ips, :aliases => 'reservableIps' attribute :reservable_ips_on_contract, :aliases => 'reservedIpsOnContract' attribute :reservable_ips_in_use, :aliases => 'reservedIpsInUse' def initialize(attributes = {}) super end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/contract_resources.rb000066400000000000000000000007631320736730600302200ustar00rootroot00000000000000require File.expand_path('../contract_resource', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class ContractResources < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::ContractResource def all result = service.get_all_contract_resources load([flatten(result.body)]) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/datacenter.rb000066400000000000000000000066521320736730600264260ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Datacenter < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type # properties attribute :name attribute :description attribute :location attribute :version attribute :features # metadata attribute :created_date, :aliases => 'createdDate', :type => :time attribute :created_by, :aliases => 'createdBy' attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time attribute :last_modified_by, :aliases => 'lastModifiedBy' attribute :request_id, :aliases => 'requestId' attribute :state #entities attribute :servers attribute :volumes attribute :loadbalancers attribute :lans attr_accessor :options def initialize(attributes = {}) super end def save requires :name, :location options = {} options[:name] = name options[:location] = location options[:description] = description if description options[:servers] = servers if servers options[:volumes] = volumes if volumes options[:loadbalancers] = loadbalancers if loadbalancers options[:lans] = lans if lans entities = {} # Retrieve servers collection if present and generate appropriate JSON. if options.key?(:servers) entities[:servers] = collect_entities(options.delete(:servers)) end # Retrieve volumes collection if present and generate appropriate JSON. if options.key?(:volumes) entities[:volumes] = collect_entities(options.delete(:volumes)) end # Retrieve volumes collection if present and generate appropriate JSON. if options.key?(:loadbalancers) entities[:loadbalancers] = collect_entities(options.delete(:loadbalancers)) end # Retrieve volumes collection if present and generate appropriate JSON. if options.key?(:lans) entities[:lans] = collect_entities(options.delete(:lans)) end data = service.create_datacenter(options, entities) merge_attributes(flatten(data.body)) true end def update requires :id options = {} options[:name] = name if name options[:description] = description if description data = service.update_datacenter(id, options) merge_attributes(flatten(data.body)) true end def delete requires :id data = service.delete_datacenter(id) true end private def collect_entities(entities) if entities.is_a?(Array) && entities.length > 0 items = [] entities.each do |entity| if entity.key?(:volumes) subentities = collect_entities(entity.delete(:volumes)) items << { properties: entity, entities: {volumes: subentities} } else items << {properties: entity} end end {items: items} end end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/datacenters.rb000066400000000000000000000012141320736730600265760ustar00rootroot00000000000000require File.expand_path('../datacenter', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Datacenters < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Datacenter def all result = service.get_all_datacenters load(result.body['items'].each { |dc| flatten(dc) }) end def get(id) response = service.get_datacenter(id) datacenter = response.body new(flatten(datacenter)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/firewall_rule.rb000066400000000000000000000070621320736730600271440ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class FirewallRule < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type # properties attribute :name attribute :protocol attribute :source_mac, :aliases => 'sourceMac' attribute :source_ip, :aliases => 'sourceIp' attribute :target_ip, :aliases => 'targetIp' attribute :icmp_code, :aliases => 'icmpCode' attribute :icmp_type, :aliases => 'icmpType' attribute :port_range_start, :aliases => 'portRangeStart' attribute :port_range_end, :aliases => 'portRangeEnd' # metadata attribute :created_date, :aliases => 'createdDate', :type => :time attribute :created_by, :aliases => 'createdBy' attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time attribute :last_modified_by, :aliases => 'lastModifiedBy' attribute :request_id, :aliases => 'requestId' attribute :state attribute :datacenter_id attribute :server_id attribute :nic_id def save requires :datacenter_id, :server_id, :nic_id, :protocol properties = {} properties[:name] = name if name properties[:protocol] = protocol if protocol properties[:sourceMac] = source_mac if source_mac properties[:sourceIp] = source_ip if source_ip properties[:targetIp] = target_ip if target_ip properties[:portRangeStart] = port_range_start if port_range_start properties[:portRangeEnd] = port_range_end if port_range_end properties[:icmpType] = icmp_type if icmp_type properties[:icmpCode] = icmp_code if icmp_code data = service.create_firewall_rule(datacenter_id, server_id, nic_id, properties) merge_attributes(flatten(data.body)) end def update requires :datacenter_id, :server_id, :nic_id, :id properties = {} properties[:name] = name if name properties[:sourceMac] = source_mac if source_mac properties[:sourceIp] = source_ip if source_ip properties[:targetIp] = target_ip if target_ip properties[:portRangeStart] = port_range_start if port_range_start properties[:portRangeEnd] = port_range_end if port_range_end properties[:icmpType] = icmp_type if icmp_type properties[:icmpCode] = icmp_code if icmp_code data = service.update_firewall_rule(datacenter_id, server_id, nic_id, id, properties) merge_attributes(flatten(data.body)) end def delete requires :datacenter_id, :server_id, :nic_id, :id service.delete_firewall_rule(datacenter_id, server_id, nic_id, id) true end def reload requires :datacenter_id, :server_id, :nic_id, :id data = begin collection.get(datacenter_id, server_id, nic_id, id) rescue Excon::Errors::SocketError nil end return unless data new_attributes = data.attributes merge_attributes(new_attributes) self end def ready? state == 'AVAILABLE' end def failed? state == 'ERROR' end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/firewall_rules.rb000066400000000000000000000023211320736730600273200ustar00rootroot00000000000000require File.expand_path('../firewall_rule', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class FirewallRules < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::FirewallRule def all(datacenter_id, server_id, nic_id) result = service.get_all_firewall_rules(datacenter_id, server_id, nic_id) firewall_rules = result.body['items'].each do |fwr| fwr['datacenter_id'] = datacenter_id fwr['server_id'] = server_id fwr['nic_id'] = nic_id end result.body['items'] = firewall_rules load(result.body['items'].each { |fwr| flatten(fwr) }) end def get(datacenter_id, server_id, nic_id, firewall_rule_id) firewall_rule = service.get_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id).body firewall_rule['datacenter_id'] = datacenter_id firewall_rule['server_id'] = server_id firewall_rule['nic_id'] = nic_id new(flatten(firewall_rule)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/flavor.rb000066400000000000000000000010461320736730600255750ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Flavor < Fog::Models::ProfitBricks::Base identity :id, :aliases => "flavorId" attribute :name, :aliases => "flavorName" attribute :cores attribute :ram def save requires :name, :ram, :cores data = service.create_flavor(name, cores, ram) merge_attributes(data.body["createFlavorResponse"]) true end def update Fog::Mock.not_implemented end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/flavors.rb000066400000000000000000000006651320736730600257660ustar00rootroot00000000000000require File.expand_path('../flavor', __FILE__) module Fog module Compute class ProfitBricks class Flavors < Fog::Collection model Fog::Compute::ProfitBricks::Flavor def all load(service.get_all_flavors.body["getAllFlavorsResponse"]) end def get(id) flavor = service.get_flavor(id).body["getFlavorResponse"] new(flavor) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/group.rb000066400000000000000000000041311320736730600254360ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Group < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type attribute :request_id # properties attribute :name attribute :create_datacenter, :aliases => 'createDataCenter' attribute :create_snapshot, :aliases => 'createSnapshot' attribute :reserve_ip, :aliases => 'reserveIp' attribute :access_activity_log, :aliases => 'accessActivityLog' # entities attribute :users attribute :resources attr_accessor :options def initialize(attributes = {}) super end def save requires :name options = {} options[:name] = name options[:createDataCenter] = create_datacenter if create_datacenter options[:createSnapshot] = create_snapshot if create_snapshot options[:reserveIp] = reserve_ip if reserve_ip options[:accessActivityLog] = access_activity_log if access_activity_log data = service.create_group(options) merge_attributes(flatten(data.body)) true end def update requires :id, :name options = {} options[:name] = name options[:createDataCenter] = create_datacenter if [true, false].include?(create_datacenter) options[:createSnapshot] = create_snapshot if [true, false].include?(create_snapshot) options[:reserveIp] = reserve_ip if [true, false].include?(reserve_ip) options[:accessActivityLog] = access_activity_log if [true, false].include?(access_activity_log) data = service.update_group(id, options) merge_attributes(flatten(data.body)) true end def delete requires :id service.delete_group(id) true end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/groups.rb000066400000000000000000000011761320736730600256270ustar00rootroot00000000000000require File.expand_path('../group', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Groups < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Group def all() result = service.get_all_groups() load(result.body['items'].each { |group| flatten(group) }) end def get(group_id) response = service.get_group(group_id) group = response.body new(flatten(group)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/image.rb000066400000000000000000000061071320736730600253710ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Image < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type # properties attribute :name attribute :description attribute :location attribute :size attribute :cpu_hot_plug, :aliases => 'cpuHotPlug' attribute :cpu_hot_unplug, :aliases => 'cpuHotUnplug' attribute :ram_hot_plug, :aliases => 'ramHotPlug' attribute :ram_hot_unplug, :aliases => 'ramHotUnplug' attribute :nic_hot_plug, :aliases => 'nicHotPlug' attribute :nic_hot_unplug, :aliases => 'nicHotUnplug' attribute :disc_virtio_hot_plug, :aliases => 'discVirtioHotPlug' attribute :disc_virtio_hot_unplug, :aliases => 'discVirtioHotUnplug' attribute :disc_scsi_hot_plug, :aliases => 'discScsiHotPlug' attribute :disc_scsi_hot_unplug, :aliases => 'discScsiHotUnplug' attribute :licence_type, :aliases => 'licenceType' attribute :image_type, :aliases => 'imageType' attribute :public attribute :image_aliases, :aliases => 'imageAliases' # metadata attribute :created_date, :aliases => 'createdDate', :type => :time attribute :created_by, :aliases => 'createdBy' attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time attribute :last_modified_by, :aliases => 'lastModifiedBy' attribute :state def update requires :id options = {} options[:name] = name if name options[:description] = description if description options[:licenceType] = licence_type if licence_type options[:cpuHotPlug] = cpu_hot_plug if cpu_hot_plug options[:cpuHotUnplug] = cpu_hot_unplug if cpu_hot_unplug options[:ramHotPlug] = ram_hot_plug if ram_hot_plug options[:ramHotUnplug] = ram_hot_unplug if ram_hot_unplug options[:nicHotPlug] = nic_hot_plug if nic_hot_plug options[:nicHotUnplug] = nic_hot_unplug if nic_hot_unplug options[:discVirtioHotPlug] = disc_virtio_hot_plug if disc_virtio_hot_plug options[:discVirtioHotUnplug] = disc_virtio_hot_unplug if disc_virtio_hot_unplug options[:discScsiHotPlug] = disc_scsi_hot_plug if disc_scsi_hot_plug options[:discScsiHotUnplug] = disc_scsi_hot_unplug if disc_scsi_hot_unplug data = service.update_image(id, options) merge_attributes(flatten(data.body)) true end def delete requires :id service.delete_image(id) true end def ready? state == 'AVAILABLE' end def failed? state == 'ERROR' end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/images.rb000066400000000000000000000011141320736730600255450ustar00rootroot00000000000000require File.expand_path('../image', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Images < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Image def all result = service.get_all_images load(result.body['items'].each { |img| flatten(img) }) end def get(id) image = service.get_image(id).body new(flatten(image)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/ip_block.rb000066400000000000000000000027311320736730600260700ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class IpBlock < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type # properties attribute :ips attribute :location attribute :size attribute :name # metadata attribute :created_date, :aliases => 'createdDate', :type => :time attribute :created_by, :aliases => 'createdBy' attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time attribute :last_modified_by, :aliases => 'lastModifiedBy' attribute :request_id, :aliases => 'requestId' attribute :state def initialize(attributes = {}) super end def save requires :location, :size properties = {} properties[:location] = location if location properties[:size] = size if size properties[:name] = name if name data = service.create_ip_block(properties) merge_attributes(flatten(data.body)) true end def delete requires :id service.delete_ip_block(id) true end def ready? state == 'AVAILABLE' end def failed? state == 'ERROR' end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/ip_blocks.rb000066400000000000000000000011731320736730600262520ustar00rootroot00000000000000require File.expand_path('../ip_block', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class IpBlocks < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::IpBlock def all result = service.get_all_ip_blocks load(result.body['items'].each { |ip_block| flatten(ip_block) }) end def get(ip_block_id) ip_block = service.get_ip_block(ip_block_id).body new(flatten(ip_block)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/lan.rb000066400000000000000000000045601320736730600250620ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Lan < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type # properties attribute :name attribute :public attribute :ip_failover, :aliases => 'ipFailover' # metadata attribute :created_date, :aliases => 'createdDate', :type => :time attribute :created_by, :aliases => 'createdBy' attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time attribute :last_modified_by, :aliases => 'lastModifiedBy' attribute :request_id, :aliases => 'requestId' attribute :state # entities attribute :nics attribute :datacenter_id, :aliases => 'datacenterId' attr_accessor :options def save requires :datacenter_id properties = {} properties[:name] = name if name properties[:public] = public if public properties[:ipFailover] = ip_failover if ip_failover entities = {} entities[:nics] = nics if nics data = service.create_lan(datacenter_id, properties, entities) merge_attributes(flatten(data.body)) true end def update requires :datacenter_id, :id options = {} options[:name] = name if name options[:public] = public if public options[:ipFailover] = ip_failover if ip_failover data = service.update_lan(datacenter_id, id, options) merge_attributes(flatten(data.body)) true end def delete requires :datacenter_id, :id service.delete_lan(datacenter_id, id) true end def reload requires :datacenter_id, :id data = begin collection.get(datacenter_id, id) rescue Excon::Errors::SocketError nil end return unless data new_attributes = data.attributes merge_attributes(new_attributes) self end def ready? state == 'AVAILABLE' end def failed? state == 'ERROR' end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/lans.rb000066400000000000000000000015151320736730600252420ustar00rootroot00000000000000require File.expand_path('../lan', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Lans < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Lan def all(datacenter_id) result = service.get_all_lans(datacenter_id) lans = result.body['items'].each do |lan| lan['datacenter_id'] = datacenter_id end result.body['items'] = lans load(result.body['items'].each { |lan| flatten(lan) }) end def get(datacenter_id, lan_id) lan = service.get_lan(datacenter_id, lan_id).body lan['datacenter_id'] = datacenter_id new(flatten(lan)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/load_balancer.rb000066400000000000000000000061731320736730600270600ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class LoadBalancer < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type # properties attribute :name attribute :ip attribute :dhcp # metadata attribute :created_date, :aliases => 'createdDate', :type => :time attribute :created_by, :aliases => 'createdBy' attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time attribute :last_modified_by, :aliases => 'lastModifiedBy' attribute :state # entities attribute :balancednics attribute :datacenter_id def initialize(attributes = {}) super end def save requires :datacenter_id, :name properties = {} properties[:name] = name if name properties[:ip] = ip if ip properties[:dhcp] = dhcp if dhcp entities = {} entities[:balancednics] = balancednics if balancednics data = service.create_load_balancer(datacenter_id, properties, entities) merge_attributes(flatten(data.body)) true end def update requires :datacenter_id, :id properties = {} properties[:name] = name if name properties[:ip] = ip if ip properties[:dhcp] = dhcp if dhcp data = service.update_load_balancer(datacenter_id, id, properties) merge_attributes(data.body) true end def delete requires :datacenter_id, :id service.delete_load_balancer(datacenter_id, id) true end def reload requires :datacenter_id, :id data = begin collection.get(datacenter_id, id) rescue Excon::Errors::SocketError nil end return unless data new_attributes = data.attributes merge_attributes(new_attributes) self end def list_nics requires :datacenter_id, :id response = service.get_all_load_balanced_nics(datacenter_id, id) response.body['items'].each { |load_balanced_nic| flatten(load_balanced_nic) } end def get_nic(nic_id) requires :datacenter_id, :id response = service.get_load_balanced_nic(datacenter_id, id, nic_id) flatten(response.body) end def associate_nic(nic_id) requires :datacenter_id, :id response = service.associate_nic_to_load_balancer(datacenter_id, id, nic_id) flatten(response.body) end def remove_nic_association(nic_id) requires :datacenter_id, :id service.remove_nic_association(datacenter_id, id, nic_id) true end def ready? state == 'AVAILABLE' end def failed? state == 'ERROR' end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/load_balancers.rb000066400000000000000000000017401320736730600272360ustar00rootroot00000000000000require File.expand_path('../load_balancer', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class LoadBalancers < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::LoadBalancer def all(datacenter_id) result = service.get_all_load_balancers(datacenter_id) load_balancers = result.body['items'].each { |volume| volume['datacenter_id'] = datacenter_id } result.body['items'] = load_balancers load(result.body['items'].each { |load_balancer| flatten(load_balancer) }) end def get(datacenter_id, load_balancer_id) response = service.get_load_balancer(datacenter_id, load_balancer_id) load_balancer = response.body load_balancer['datacenter_id'] = datacenter_id new(flatten(load_balancer)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/location.rb000066400000000000000000000006131320736730600261130ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Location < Fog::Models::ProfitBricks::Base identity :id attribute :name attribute :features attribute :type attribute :image_aliases, :aliases => 'imageAliases' attr_accessor :options def initialize(attributes = {}) super end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/locations.rb000066400000000000000000000011531320736730600262760ustar00rootroot00000000000000require File.expand_path('../location', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Locations < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Location def all result = service.get_all_locations load(result.body['items'].each { |location| flatten(location) }) end def get(id) location = service.get_location(id).body new(flatten(location)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/nic.rb000066400000000000000000000076001320736730600250570ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Nic < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type # properties attribute :name attribute :mac attribute :ips attribute :dhcp attribute :lan attribute :nat attribute :firewall_active, :aliases => 'firewallActive' # metadata attribute :created_date, :aliases => 'createdDate', :type => :time attribute :created_by, :aliases => 'createdBy' attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time attribute :last_modified_by, :aliases => 'lastModifiedBy' attribute :request_id, :aliases => 'requestId' attribute :state # entities attribute :firewallrules attribute :firewall_rules attribute :datacenter_id attribute :server_id attr_accessor :options def save requires :datacenter_id, :server_id, :lan properties = {} properties[:name] = name if name properties[:ips] = ips if ips properties[:dhcp] = dhcp if dhcp properties[:lan] = lan if lan properties[:nat] = nat if nat properties[:firewallActive] = firewall_active if firewall_active entities = {} if firewall_rules properties[:firewallActive] = true entities[:firewallrules] = get_firewall_rules(firewall_rules) end data = service.create_nic(datacenter_id, server_id, properties, entities) merge_attributes(flatten(data.body)) end def update requires :datacenter_id, :server_id, :id properties = {} properties[:name] = name if name properties[:ips] = ips if ips properties[:dhcp] = dhcp if dhcp properties[:lan] = lan if lan properties[:nat] = nat if nat data = service.update_nic(datacenter_id, server_id, id, properties) merge_attributes(data.body) end def delete requires :datacenter_id, :server_id, :id service.delete_nic(datacenter_id, server_id, id) true end def reload requires :datacenter_id, :server_id, :id data = begin collection.get(datacenter_id, server_id, id) rescue Excon::Errors::SocketError nil end return unless data new_attributes = data.attributes merge_attributes(new_attributes) self end def get_firewall_rules(firewall_rules) items = [] firewall_rules.each do |firewall_rule| item = {} item[:name] = firewall_rule[:name] if firewall_rule.key?(:name) item[:protocol] = firewall_rule[:protocol] if firewall_rule.key?(:protocol) item[:sourceMac] = firewall_rule[:source_mac] if firewall_rule.key?(:source_mac) item[:sourceIp] = firewall_rule[:source_ip] if firewall_rule.key?(:source_ip) item[:targetIp] = firewall_rule[:target_ip] if firewall_rule.key?(:target_ip) item[:portRangeStart] = firewall_rule[:port_range_start] if firewall_rule.key?(:port_range_start) item[:portRangeEnd] = firewall_rule[:port_range_end] if firewall_rule.key?(:port_range_end) item[:icmpType] = firewall_rule[:icmp_type] if firewall_rule.key?(:icmp_type) item[:icmpCode] = firewall_rule[:icmp_code] if firewall_rule.key?(:icmp_code) items << { :properties => item } end { :items => items } end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/nics.rb000066400000000000000000000017101320736730600252360ustar00rootroot00000000000000require File.expand_path('../nic', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Nics < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Nic def all(datacenter_id, server_id) result = service.get_all_nic(datacenter_id, server_id) nics = result.body['items'].each do |nic| nic['datacenter_id'] = datacenter_id nic['server_id'] = server_id end result.body['items'] = nics load(result.body['items'].each { |nic| flatten(nic) }) end def get(datacenter_id, server_id, nic_id) nic = service.get_nic(datacenter_id, server_id, nic_id).body nic['datacenter_id'] = datacenter_id nic['server_id'] = server_id new(flatten(nic)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/region.rb000066400000000000000000000004431320736730600255670ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Region < Fog::Models::ProfitBricks::Base identity :id, :aliases => "locationId" attribute :name, :aliases => "locationName" attribute :country, :aliases => "country" end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/regions.rb000066400000000000000000000006751320736730600257610ustar00rootroot00000000000000require File.expand_path('../region', __FILE__) module Fog module Compute class ProfitBricks class Regions < Fog::Collection model Fog::Compute::ProfitBricks::Region def all load(service.get_all_locations.body["getAllLocationsResponse"]) end def get(id) region = service.get_location(id).body["getLocationResponse"] new(region) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/request.rb000066400000000000000000000011301320736730600257660ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Request < Fog::Models::ProfitBricks::Base identity :id # properties attribute :method attribute :headers attribute :body attribute :url attribute :type # metadata attribute :created_date, :aliases => 'createdDate', :type => :time attribute :created_by, :aliases => 'createdBy' attribute :request_status, :aliases => 'requestStatus' attribute :status attribute :message attribute :targets end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/requests.rb000066400000000000000000000015211320736730600261550ustar00rootroot00000000000000require File.expand_path('../request', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Requests < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Request def all result = service.get_all_requests load(result.body['items'].each { |request| flatten(request) }) end def get(request_id) request = service.get_request(request_id).body Excon::Errors new(flatten(request)) rescue Excon::Errors::NotFound nil end def get_status(request_id) request = service.get_request_status(request_id).body new(flatten(request)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/resource.rb000066400000000000000000000014321320736730600261320ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Resource < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type # metadata attribute :created_date, :aliases => 'createdDate' attribute :created_by, :aliases => 'createdBy' attribute :etag attribute :last_modified_date, :aliases => 'lastModifiedDate' attribute :last_modified_by, :aliases => 'lastModifiedBy' attribute :state # entities attribute :groups attr_accessor :options def initialize(attributes = {}) super end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/resources.rb000066400000000000000000000016241320736730600263200ustar00rootroot00000000000000require File.expand_path('../resource', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Resources < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Resource def all response = service.get_all_resources load(response.body['items'].each { |resource| flatten(resource) }) end def get_resource_by_type(resource_type, resource_id) response = service.get_resource_by_type(resource_type, resource_id) share = response.body new(flatten(share)) end def get_by_type(resource_type) response = service.get_resources_by_type(resource_type) load(response.body['items'].each { |resource| flatten(resource) }) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/server.rb000066400000000000000000000204051320736730600256120ustar00rootroot00000000000000# require "fog/compute/models/server" require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Server < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type # properties attribute :name attribute :cores attribute :ram attribute :availability_zone, :aliases => 'availabilityZone' attribute :vm_state, :aliases => 'vmState' attribute :boot_cdrom, :aliases => 'bootCdrom' attribute :boot_volume, :aliases => 'bootVolume' attribute :cpu_family, :aliases => 'cpuFamily' attribute :allow_reboot, :aliases => 'allowReboot' # metadata attribute :created_date, :aliases => 'createdDate', :type => :time attribute :created_by, :aliases => 'createdBy' attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time attribute :last_modified_by, :aliases => 'lastModifiedBy' attribute :request_id, :aliases => 'requestId' attribute :state # entities attribute :cdroms attribute :volumes attribute :nics attribute :datacenter_id attr_accessor :options def initialize(attributes = {}) super end def save requires :datacenter_id, :name, :cores, :ram properties = {} properties[:name] = name if name properties[:cores] = cores if cores properties[:ram] = ram if ram properties[:availabilityZone] = availability_zone if availability_zone properties[:bootVolume] = boot_volume if boot_volume properties[:bootCdrom] = boot_cdrom if boot_cdrom properties[:cpuFamily] = cpu_family if cpu_family entities = {} entities[:volumes] = get_volumes(volumes) if volumes entities[:nics] = get_nics(nics) if nics data = service.create_server(datacenter_id, properties, entities) merge_attributes(flatten(data.body)) true end def update requires :datacenter_id, :id properties = {} properties[:name] = name if name properties[:cores] = cores if cores properties[:ram] = ram if ram properties[:availabilityZone] = availability_zone if availability_zone properties[:cpuFamily] = cpu_family if cpu_family properties[:allowReboot] = allow_reboot if allow_reboot data = service.update_server(datacenter_id, id, properties) merge_attributes(flatten(data.body)) true end def attach_volume(storage_id) requires :datacenter_id, :id data = service.attach_volume(datacenter_id, id, storage_id) flatten(data.body) end def get_attached_volume(volume_id) requires :datacenter_id, :id data = service.get_attached_volume(datacenter_id, id, volume_id) volume = data.body volume['datacenter_id'] = datacenter_id flatten(data.body) end def detach_volume(storage_id) requires :datacenter_id, :id service.detach_volume(datacenter_id, id, storage_id) true end def attach_cdrom(cdrom_image_id) requires :datacenter_id, :id data = service.attach_cdrom(datacenter_id, id, cdrom_image_id) flatten(data.body) end def get_attached_cdrom(cdrom_image_id) requires :datacenter_id, :id data = service.get_attached_cdrom(datacenter_id, id, cdrom_image_id) flatten(data.body) end def detach_cdrom(cdrom_id) requires :datacenter_id, :id service.detach_cdrom(datacenter_id, id, cdrom_id) true end def reboot requires :datacenter_id, :id service.reboot_server(datacenter_id, id) true end def start requires :datacenter_id, :id service.start_server(datacenter_id, id) true end def stop requires :datacenter_id, :id service.stop_server(datacenter_id, id) true end def delete requires :datacenter_id, :id service.delete_server(datacenter_id, id) true end def reload requires :datacenter_id, :id data = begin collection.get(datacenter_id, id) rescue Excon::Errors::SocketError nil end return unless data new_attributes = data.attributes merge_attributes(new_attributes) self end def list_volumes requires :datacenter_id, :id result = service.list_attached_volumes(datacenter_id, id) volumes = result.body['items'].each { |volume| volume['datacenter_id'] = datacenter_id } result.body['items'] = volumes result.body end def list_cdroms requires :datacenter_id, :id result = service.list_attached_cdroms(datacenter_id, id) cdroms = result.body['items'].each { |cdrom| cdrom['datacenter_id'] = datacenter_id } result.body['items'] = cdroms result.body end def list_nics requires :datacenter_id, :id service.nics.all(datacenter_id, id) end def shutoff? vm_state == 'SHUTOFF' end def running? vm_state == 'RUNNING' end private def get_volumes(volumes) items = [] for volume in volumes do item = {} item[:name] = volume[:name] item[:size] = volume[:size] item[:type] = volume[:type] item[:bus] = volume[:bus] || 'VIRTIO' item[:image] = volume[:image] item[:imageAlias] = volume[:image_alias] item[:imagePassword] = volume[:image_password] item[:sshKeys] = volume[:ssh_keys] item[:licenceType] = volume[:licence_type] items << { :properties => item } end { :items => items } end def get_nics(nics) items = [] for nic in nics do firewall_rules = nil item = {} item[:name] = nic[:name] if nic.key?(:name) item[:ips] = nic[:ips] if nic.key?(:ips) item[:dhcp] = nic[:dhcp] if nic.key?(:dhcp) item[:lan] = nic[:lan] if nic.key?(:lan) item[:firewallActive] = nic[:firewall_active] if nic.key?(:firewall_active) if nic[:firewall_rules] firewall_rules = get_firewall_rules(nic[:firewall_rules]) item[:firewallActive] = true end items << { :properties => item, :entities => firewall_rules } end { :items => items } end def get_firewall_rules(firewall_rules) items = [] for firewall_rule in firewall_rules do item = {} item[:name] = firewall_rule[:name] if firewall_rule.key?(:name) item[:protocol] = firewall_rule[:protocol] if firewall_rule.key?(:protocol) item[:sourceMac] = firewall_rule[:source_mac] if firewall_rule.key?(:source_mac) item[:sourceIp] = firewall_rule[:source_ip] if firewall_rule.key?(:source_ip) item[:targetIp] = firewall_rule[:target_ip] if firewall_rule.key?(:target_ip) item[:portRangeStart] = firewall_rule[:port_range_start] if firewall_rule.key?(:port_range_start) item[:portRangeEnd] = firewall_rule[:port_range_end] if firewall_rule.key?(:port_range_end) item[:icmpType] = firewall_rule[:icmp_type] if firewall_rule.key?(:icmp_type) item[:icmpCode] = firewall_rule[:icmp_code] if firewall_rule.key?(:icmp_code) items << { :properties => item } end { :firewallrules => { :items => items } } end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/servers.rb000066400000000000000000000015321320736730600257750ustar00rootroot00000000000000require File.expand_path('../server', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Servers < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Server def all(datacenter_id) result = service.get_all_servers(datacenter_id) servers = result.body['items'].each { |server| server['datacenter_id'] = datacenter_id } result.body['items'] = servers load(result.body['items'].each { |dc| flatten(dc) }) end def get(datacenter_id, server_id) server = service.get_server(datacenter_id, server_id).body server['datacenter_id'] = datacenter_id new(flatten(server)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/share.rb000066400000000000000000000032541320736730600254110ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Share < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type # properties attribute :edit_privilege, :aliases => 'editPrivilege' attribute :share_privilege, :aliases => 'sharePrivilege' attribute :group_id, :aliases => 'groupId' attribute :resource_id, :aliases => 'resourceId' attr_accessor :options def initialize(attributes = {}) super end def save requires :group_id, :resource_id options = {} options[:editPrivilege] = edit_privilege if edit_privilege options[:sharePrivilege] = share_privilege if share_privilege data = service.add_share(group_id, resource_id, options).body data['group_id'] = group_id data['resource_id'] = resource_id merge_attributes(flatten(data)) true end def update requires :group_id, :resource_id options = {} options[:editPrivilege] = edit_privilege if [true, false].include?(edit_privilege) options[:sharePrivilege] = share_privilege if [true, false].include?(share_privilege) data = service.update_share(group_id, resource_id, options) merge_attributes(flatten(data.body)) true end def delete requires :group_id, :resource_id service.delete_share(group_id, resource_id) true end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/shares.rb000066400000000000000000000015561320736730600255770ustar00rootroot00000000000000require File.expand_path('../share', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Shares < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Share def all(group_id) result = service.get_all_shares(group_id) load(result.body['items'].each do |share| share['group_id'] = group_id share['resource_id'] = share['id'] flatten(share) end) end def get(group_id, resource_id) response = service.get_share(group_id, resource_id) share = response.body share['group_id'] = group_id share['resource_id'] = resource_id new(flatten(share)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/snapshot.rb000066400000000000000000000061241320736730600261450ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Snapshot < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type # properties attribute :name attribute :description attribute :location attribute :size attribute :cpu_hot_plug, :aliases => 'cpuHotPlug' attribute :cpu_hot_unplug, :aliases => 'cpuHotUnplug' attribute :ram_hot_plug, :aliases => 'ramHotPlug' attribute :ram_hot_unplug, :aliases => 'ramHotUnplug' attribute :nic_hot_plug, :aliases => 'nicHotPlug' attribute :nic_hot_unplug, :aliases => 'nicHotUnplug' attribute :disc_virtio_hot_plug, :aliases => 'discVirtioHotPlug' attribute :disc_virtio_hot_unplug, :aliases => 'discVirtioHotUnplug' attribute :disc_scsi_hot_plug, :aliases => 'discScsiHotPlug' attribute :disc_scsi_hot_unplug, :aliases => 'discScsiHotUnplug' attribute :licence_type, :aliases => 'licenceType' # metadata attribute :created_date, :aliases => 'createdDate', :type => :time attribute :created_by, :aliases => 'createdBy' attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time attribute :last_modified_by, :aliases => 'lastModifiedBy' attribute :request_id, :aliases => 'requestId' attribute :state attr_accessor :options def initialize(attributes = {}) super end def update requires :id options = {} options[:name] = name if name options[:description] = description if description options[:cpuHotPlug] = cpu_hot_plug if cpu_hot_plug options[:cpuHotUnplug] = cpu_hot_unplug if cpu_hot_unplug options[:ramHotPlug] = ram_hot_plug if ram_hot_plug options[:ramHotUnplug] = ram_hot_unplug if ram_hot_unplug options[:nicHotPlug] = nic_hot_plug if nic_hot_plug options[:nicHotUnplug] = nic_hot_unplug if nic_hot_unplug options[:discVirtioHotPlug] = disc_virtio_hot_plug if disc_virtio_hot_plug options[:discVirtioHotUnplug] = disc_virtio_hot_unplug if disc_virtio_hot_unplug options[:discScsiHotPlug] = disc_scsi_hot_plug if disc_scsi_hot_plug options[:discScsiHotUnplug] = disc_scsi_hot_unplug if disc_scsi_hot_unplug options[:licenceType] = licence_type if licence_type data = service.update_snapshot(id, options) merge_attributes(flatten(data.body)) true end def delete requires :id service.delete_snapshot(id) true end def ready? state == 'AVAILABLE' end def failed? state == 'ERROR' end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/snapshots.rb000066400000000000000000000011531320736730600263250ustar00rootroot00000000000000require File.expand_path('../snapshot', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Snapshots < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Snapshot def all result = service.get_all_snapshots load(result.body['items'].each { |snapshot| flatten(snapshot) }) end def get(id) snapshot = service.get_snapshot(id).body new(flatten(snapshot)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/user.rb000066400000000000000000000040651320736730600252660ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class User < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id attribute :type attribute :request_id # metadata attribute :etag attribute :creation_date, :aliases => 'creationDate' attribute :last_login, :aliases => 'lastLogin' # properties attribute :firstname attribute :lastname attribute :email attribute :password attribute :administrator attribute :force_sec_auth, :aliases => 'forceSecAuth' attribute :sec_auth_active, :aliases => 'secAuthActive' # entities attribute :owns attribute :groups attr_accessor :options def initialize(attributes = {}) super end def save requires :firstname, :lastname, :email, :password options = {} options[:firstname] = firstname options[:lastname] = lastname options[:email] = email options[:password] = password options[:administrator] = administrator if administrator options[:forceSecAuth] = force_sec_auth if force_sec_auth data = service.create_user(options) merge_attributes(flatten(data.body)) true end def update requires :id, :firstname, :lastname, :email, :administrator, :force_sec_auth options = {} options[:firstname] = firstname options[:lastname] = lastname options[:email] = email options[:administrator] = administrator options[:forceSecAuth] = force_sec_auth data = service.update_user(id, options) merge_attributes(flatten(data.body)) true end def delete requires :id service.delete_user(id) true end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/users.rb000066400000000000000000000021521320736730600254440ustar00rootroot00000000000000require File.expand_path('../user', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Users < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::User def all response = service.get_all_users load(response.body['items'].each { |user| flatten(user) }) end def get(user_id) response = service.get_user(user_id) share = response.body new(flatten(share)) end def list_group_users(group_id) response = service.get_group_users(group_id) load(response.body['items'].each { |user| flatten(user) }) end def add_group_user(group_id, user_id) response = service.add_user_to_group(group_id, user_id) user = response.body new(flatten(user)) end def remove_group_user(group_id, user_id) service.remove_user_from_group(group_id, user_id) true end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/volume.rb000066400000000000000000000103601320736730600256120ustar00rootroot00000000000000require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Volume < Fog::Models::ProfitBricks::Base include Fog::Helpers::ProfitBricks::DataHelper identity :id # properties attribute :name attribute :size attribute :image attribute :image_alias, :aliases => 'imageAlias' attribute :bus attribute :type attribute :availability_zone, :aliases => 'availabilityZone' attribute :image_password, :aliases => 'imagePassword' attribute :ssh_keys, :aliases => 'sshKeys' attribute :licence_type, :aliases => 'licenceType' attribute :cpu_hot_plug, :aliases => 'cpuHotPlug' attribute :cpu_hot_unplug, :aliases => 'cpuHotUnplug' attribute :ram_hot_plug, :aliases => 'ramHotPlug' attribute :ram_hot_unplug, :aliases => 'ramHotUnplug' attribute :nic_hot_plug, :aliases => 'nicHotPlug' attribute :nic_hot_unplug, :aliases => 'nicHotUnplug' attribute :disc_virtio_hot_plug, :aliases => 'discVirtioHotPlug' attribute :disc_virtio_hot_unplug, :aliases => 'discVirtioHotUnplug' attribute :disc_scsi_hot_plug, :aliases => 'discScsiHotPlug' attribute :disc_scsi_hot_unplug, :aliases => 'discScsiHotUnplug' attribute :device_number, :aliases => 'deviceNumber' # metadata attribute :created_date, :aliases => 'createdDate', :type => :time attribute :created_by, :aliases => 'createdBy' attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time attribute :last_modified_by, :aliases => 'lastModifiedBy' attribute :request_id, :aliases => 'requestId' attribute :state attribute :datacenter_id attr_accessor :options def initialize(attributes = {}) super end def save requires :datacenter_id, :size, :type options = {} options[:name] = name if name options[:size] = size options[:bus] = bus if bus options[:image] = image if image options[:imageAlias] = image_alias if image_alias options[:type] = type options[:licenceType] = licence_type if licence_type options[:imagePassword] = image_password if image_password options[:sshKeys] = ssh_keys if ssh_keys options[:availabilityZone] = availability_zone if availability_zone data = service.create_volume(datacenter_id, options) merge_attributes(flatten(data.body)) true end def update requires :datacenter_id, :id options = {} options[:name] = name if name options[:size] = size if size data = service.update_volume(datacenter_id, id, options) merge_attributes(flatten(data.body)) true end def delete requires :datacenter_id, :id service.delete_volume(datacenter_id, id) true end def reload requires :datacenter_id, :id data = begin collection.get(datacenter_id, id) rescue Excon::Errors::SocketError nil end return unless data new_attributes = data.attributes merge_attributes(new_attributes) self end def create_snapshot(name, description = '') requires :datacenter_id, :id options = {} options[:name] = name if name options[:description] = description if description && description != '' service.create_volume_snapshot(datacenter_id, id, options) true end def restore_snapshot(snapshot_id) requires :datacenter_id, :id options = {} options[:snapshot_id] = snapshot_id if snapshot_id service.restore_volume_snapshot(datacenter_id, id, options) true end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/models/compute/volumes.rb000066400000000000000000000016001320736730600257720ustar00rootroot00000000000000require File.expand_path('../volume', __FILE__) require File.expand_path('../../../helpers/compute/data_helper', __FILE__) module Fog module Compute class ProfitBricks class Volumes < Fog::Collection include Fog::Helpers::ProfitBricks::DataHelper model Fog::Compute::ProfitBricks::Volume def all(datacenter_id) result = service.get_all_volumes(datacenter_id) volumes = result.body['items'].each { |volume| volume['datacenter_id'] = datacenter_id } result.body['items'] = volumes load(result.body['items'].each { |volume| flatten(volume) }) end def get(datacenter_id, volume_id) response = service.get_volume(datacenter_id, volume_id) volume = response.body volume['datacenter_id'] = datacenter_id new(flatten(volume)) end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/000077500000000000000000000000001320736730600226725ustar00rootroot00000000000000fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/000077500000000000000000000000001320736730600243465ustar00rootroot00000000000000fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/add_share.rb000066400000000000000000000047511320736730600266140ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Adds a specific resource share to a group and optionally allows the setting of permissions # for that resource. As an example, you might use this to grant permissions to use an image # or snapshot to a specific group. # # ==== Parameters # * options<~Hash>: # * group_id<~String> - Required, The ID of the specific group to add a resource to. # * resource_id<~String> - Required, The ID of the specific resource to add. # * editPrivilege<~Boolean> - The group has permission to edit privileges on this resource. # * sharePrivilege<~Boolean> - The group has permission to share this resource. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * properties<~Hash> - A collection of properties. # * editPrivilege<~Boolean> - The group has permission to edit privileges on this resource. # * sharePrivilege<~Boolean> - The group has permission to share this resource. # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#add-a-share] def add_share(group_id, resource_id, options = {}) share = { :properties => options } request( :expects => [202], :method => 'POST', :path => "/um/groups/#{group_id}/shares/#{resource_id}", :body => Fog::JSON.encode(share) ) end end class Mock def add_share(group_id, resource_id, options = {}) response = Excon::Response.new response.status = 202 share = { 'id' => resource_id, 'type' => 'resource', 'href' => "https=>//api.profitbricks.com/rest/v4/um/groups/#{group_id}/shares/#{resource_id}", 'properties' => { 'editPrivilege' => options[:editPrivilege], 'sharePrivilege' => options[:sharePrivilege] } } data[:shares]['items'] << share response.body = share response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/add_user_to_group.rb000066400000000000000000000102701320736730600303770ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Add an existing user to a group. # # ==== Parameters # * group_id<~String> - Required, The ID of the specific group you want to add a user to. # * user_id<~String> - Required, The ID of the specific user to add to the group. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * metadata<~Hash> - Hash containing metadata for the user. # * etag<~String> - ETag of the user. # * creationDate<~String> - A time and date stamp indicating when the user was created. # * lastLogin<~String> - A time and date stamp indicating when the user last logged in. # * properties<~Hash> - Hash containing the user's properties. # * firstname<~String> - The first name of the user. # * lastname<~String> - The last name of the user. # * email<~String> - The e-mail address of the user. # * administrator<~Boolean> - Indicates if the user has administrative rights. # * forceSecAuth<~Boolean> - Indicates if secure (two-factor) authentication was enabled for the user. # * secAuthActive<~Boolean> - Indicates if secure (two-factor) authentication is enabled for the user. # * entities<~Hash> - Hash containing resources the user owns, and groups the user is a member of. # * owns<~Hash> - Hash containing resources the user owns. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * groups<~Hash> - Hash containing groups the user is a member of. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#add-user-to-group] def add_user_to_group(group_id, user_id) usr = { :id => user_id } request( :expects => [202], :method => 'POST', :path => "/um/groups/#{group_id}/users", :body => Fog::JSON.encode(usr) ) end end class Mock def add_user_to_group(group_id, user_id) response = Excon::Response.new response.status = 202 if group = data[:groups]['items'].find do |grp| grp["id"] == group_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end if user = data[:users]['items'].find do |usr| usr["id"] == user_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end group['users']['items'] << user user['groups']['items'] << group response.body = user response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb000066400000000000000000000155761320736730600330450ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Associates a NIC to a Load Balancer, enabling the NIC to participate in load-balancing # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * load_balancer_id<~String> - UUID of the load balancer # * nic_id<~String> - UUID of the NIC # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#associate-nic-to-load-balancer] def associate_nic_to_load_balancer(datacenter_id, load_balancer_id, nic_id) nic = { :id => nic_id } request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}/balancednics", :body => Fog::JSON.encode(nic) ) end end class Mock def associate_nic_to_load_balancer(datacenter_id, load_balancer_id, nic_id) if load_balancer = data[:load_balancers]['items'].find do |lb| lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id end else raise Fog::Errors::NotFound, "The requested resource could not be found" end unless load_balancer['entities'] && load_balancer['entities']['balancednics'] && load_balancer['entities']['balancednics']['items'] nic = data[:nics]['items'].find do |nic| nic["datacenter_id"] == datacenter_id && nic["id"] == nic_id end load_balancer['entities'] = { 'balancednics' => { 'id' => "#{load_balancer_id}/balancednics", 'type' => "collection", 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}/balancednics", 'items' => [nic] } } end response = Excon::Response.new response.status = 202 response.body = nic response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/attach_cdrom.rb000066400000000000000000000113521320736730600273250ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Attach a CD-ROM to an existing server. # # ==== Parameters # * datacenter_id - Required - The unique ID of the data center # * server_id<~String> - Required - The unique ID of the server # * cdrom_image_id<~String> - Required - The unique ID of a CD-ROM image # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the image metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the image # * description<~String> - The description of the image # * location<~String> - The image's location # * size<~Integer> - The size of the image in GB # * cpuHotPlug<~Boolean> - This image is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This image is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This image is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This image is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This image is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This image is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This image is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This image is capable of Scsi drive hot unplug (no reboot required) # * licenceType<~String> - The image's licence type: LINUX, WINDOWS, or UNKNOWN # * imageType<~String> - The type of image: HDD, CDROM # * public<~String> - Indicates if the image is part of the public repository or not # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#attach-a-cd-rom] def attach_cdrom(datacenter_id, server_id, cdrom_image_id) volume = { :id => cdrom_image_id } request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms", :body => Fog::JSON.encode(volume) ) end end class Mock def attach_cdrom(datacenter_id, server_id, cdrom_image_id) if cdrom = data[:images]['items'].find do |cd| cd["id"] == cdrom_image_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end if server = data[:servers]['items'].find do |serv| serv['datacenter_id'] == datacenter_id && serv['id'] == server_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end cdrom['properties'] = {} cdrom['properties']['name'] = cdrom['name'] if server['cdroms'] && server['cdroms']['items'] server['cdroms']['items'] << cdrom else server['cdroms'] = { 'id' => "#{server['id']}/cdroms", 'type' => 'collection', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{server['datacenter_id']}/servers/#{server['id']}/cdroms", 'items' => [cdrom] } end response = Excon::Response.new response.status = 202 response.body = cdrom response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/attach_volume.rb000066400000000000000000000123441320736730600275320ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Attach a pre-existing storage volume to the server. # # ==== Parameters # * datacenter_id - Required - The unique ID of the data center # * server_id<~String> - Required - The unique ID of the server # * storage_id<~String> - Required - The unique ID of a storage volume # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the volume metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the volume. # * type<~String> - The volume type, HDD or SSD. # * size<~Integer> - The size of the volume in GB. # * image<~String> - The image or snapshot ID. # * imagePassword<~Boolean> - Indicates if a password is set on the image. # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN) # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * deviceNumber<~Integer> - The LUN ID of the storage volume # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#attach-a-volume] def attach_volume(datacenter_id, server_id, storage_id) volume = { :id => storage_id } request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/volumes", :body => Fog::JSON.encode(volume) ) end end class Mock def attach_volume(datacenter_id, server_id, storage_id) if volume = data[:volumes]['items'].find do |vlm| vlm["id"] == storage_id && vlm["datacenter_id"] == datacenter_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end if server = data[:servers]['items'].find do |serv| serv['datacenter_id'] == datacenter_id && serv['id'] == server_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end volume['properties'] = {} volume['properties']['name'] = volume['name'] volume['properties']['size'] = volume['size'] volume['properties']['bus'] = volume['bus'] volume['properties']['type'] = volume['type'] volume['properties']['licenceType'] = 'LINUX' if server['entities'] && server['entities']['volumes'] && server['entities']['volumes']['items'] server['entities']['volumes']['items'] << volume else server['entities'] = { 'volumes' => { 'id' => "#{server_id}/volumes", 'type' => 'collection', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/volumes", 'items' => [volume] } } end response = Excon::Response.new response.status = 202 response.body = volume response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_datacenter.rb000066400000000000000000000136651320736730600303430ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Create a new virtual data center # # ==== Parameters # * options<~Hash>: # * name<~String> - The name of the data center # * region<~String> - The physical location where the data center will be created ("de/fkb", "de/fra", or "us/las") # * description<~String> - An optional description for the data center, e.g. staging, production. # * servers<~Hash> - A collection of servers # * volumes<~Hash> - A collection of volumes # * loadbalancers<~Hash> - A collection of loadbalancers # * lans<~Hash> - A collection of LANs in a data center # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the resource's metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Data center state (AVAILABLE, BUSY, INACTIVE) # * properties<~Hash> - A hash containing the resource's properties # * name<~String> - The name of the data center # * description<~String> - The description of the data center # * location<~String> - The location where the data center was provisioned ("de/fkb", "de/fra", or "us/las") # * version<~Integer> - The version of the data center # * features<~Array> - The features of the data center # * entities<~Hash> - A hash containing the datacenter entities # * servers<~Hash> - A collection that represents the servers in a data center # * volumes<~Hash> - A collection that represents volumes in a data center # * loadbalancers<~Hash> - A collection that represents the loadbalancers in a data center # * lans<~Hash> - A collection that represents the LANs in a data center # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-a-data-center] def create_datacenter(options, entities={}) datacenter = { :properties => options, :entities => entities } request( :expects => [202], :method => 'POST', :path => '/datacenters', :body => Fog::JSON.encode(datacenter) ) end end class Mock def create_datacenter(options, entities={}) dc = { :properties => options, :entities => entities } if dc[:properties][:location] == nil raise Excon::Error::HTTPStatus, "Attribute 'location' is required" end dc_3_id = Fog::UUID.uuid dc_4_id = Fog::UUID.uuid datacenter = { 'id' => dc_3_id, 'type' => 'datacenter', 'properties' => { 'name' => dc[:properties][:name], 'description' => dc[:properties][:description], 'location' => dc[:properties][:location], 'version' => 1 } } if entities != nil and entities != {} datacenter = { 'id' => dc_4_id, 'type' => 'datacenter', 'properties' => { 'name' => dc[:properties][:name], 'description' => dc[:properties][:description], 'location' => dc[:properties][:location], 'version' => 1 }, 'entities' => { 'volumes' => { 'items' => [ { 'type' => 'volume', 'properties' => { 'name' => dc[:entities][:volumes][:items][0][:properties][:name], 'type' => dc[:entities][:volumes][:items][0][:properties][:type], 'size' => dc[:entities][:volumes][:items][0][:properties][:size], 'bus' => dc[:entities][:volumes][:items][0][:properties][:bus], 'licenceType' => dc[:entities][:volumes][:items][0][:properties][:licenceType], 'availabilityZone' => dc[:entities][:volumes][:items][0][:properties][:availabilityZone] } } ] }, 'servers' => { 'items' => [ { 'properties' => { 'name' => dc[:entities][:servers][:items][0][:properties][:name], 'cores' => dc[:entities][:servers][:items][0][:properties][:cores], 'ram' => dc[:entities][:servers][:items][0][:properties][:ram] } } ] } } } end data[:datacenters]['items'] << datacenter response = Excon::Response.new response.status = 202 response.body = datacenter response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb000066400000000000000000000147441320736730600310640ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Adds a Firewall Rule to the NIC # # ==== Parameters # * datacenter_id<~String> - Required, UUID of the virtual data center # * server_id<~String> - Required, UUID of the server # * nic_id<~String> - Required, UUID of the NIC # * options<~Hash>: # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~String> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~String> - Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs # * targetIp<~String> - In case the target NIC has multiple IP addresses, only traffic directed to the respective # IP address of the NIC is allowed. Value null allows all target IPs # * portRangeStart<~String> - Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd value null to allow all ports # * portRangeEnd<~String> - Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd null to allow all ports # * icmpType<~String> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types # * icmpCode<~String> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~String> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~String> - Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs # * targetIp<~String> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~String> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes # * icmpType<~String> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types # * portRangeStart<~String> - Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd value null to allow all ports # * portRangeEnd<~String> - Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-firewall-rule] def create_firewall_rule(datacenter_id, server_id, nic_id, options = {}) firewall_rule = { :properties => options } request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules", :body => Fog::JSON.encode(firewall_rule) ) end end class Mock def create_firewall_rule(datacenter_id, server_id, nic_id, options = {}) response = Excon::Response.new response.status = 202 properties = {} properties['name'] = options[:name] properties['protocol'] = options[:protocol] properties['source_mac'] = options[:sourceMac] properties['port_range_start'] = options[:portRangeStart] properties['port_range_end'] = options[:portRangeEnd] firewall_rule_id = Fog::UUID.uuid firewall_rule = { 'id' => firewall_rule_id, 'type' => 'firewall-rule', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}", 'metadata' => { 'createdDate' => '2015-03-18T19:00:51Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'faa67fbacb1c0e2e02cf9650657251f2', 'lastModifiedDate' => '2015-03-18T19:00:51Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => properties, 'datacenter_id' => datacenter_id, 'server_id' => server_id, 'nic_id' => nic_id } data[:firewall_rules]['items'] << firewall_rule response.body = firewall_rule response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_flavor.rb000066400000000000000000000017451320736730600275160ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Not a real API method; will only return flavor object. def create_flavor(flavor_name, cores, ram) response = Excon::Response.new response.status = 200 response.body = { 'createFlavorResponse' => { 'id' => Fog::UUID.uuid, 'name' => flavor_name, 'cores' => cores, 'ram' => ram } } response end end class Mock def create_flavor(flavor_name, ram, cores) response = Excon::Response.new response.status = 200 flavor = { 'id' => Fog::UUID.uuid, 'name' => flavor_name, 'ram' => ram, 'cores' => cores } data[:flavors] << flavor response.body = { 'createFlavorResponse' => flavor } response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_group.rb000066400000000000000000000113341320736730600273540ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Create a new group and set group privileges. # # ==== Parameters # * options<~Hash>: # * name<~String> - Required, The name of the group. # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers. # * createSnapshot<~Boolean> - The group will be allowed to create snapshots. # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses. # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * properties<~Hash> - Hash containing the volume properties. # * name<~String> - The name of the group. # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers. # * createSnapshot<~Boolean> - The group will be allowed to create snapshots. # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses. # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log. # * entities<~Hash> - A hash containing the group entities. # * users<~Hash> - A collection of users that belong to this group. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # * items<~Array> - The array containing individual user resources. # * resources<~Hash> - A collection of resources that are assigned to this group. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # * items<~Array> - An array containing individual resources. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#create-a-group] def create_group(options = {}) group = { :properties => options } request( :expects => [202], :method => 'POST', :path => "/um/groups", :body => Fog::JSON.encode(group) ) end end class Mock def create_group(options = {}) if options[:name] == nil raise Excon::Error::HTTPStatus, "Attribute 'name' is required" end response = Excon::Response.new response.status = 202 group_id = Fog::UUID.uuid group = { 'id' => group_id, 'type' => 'group', 'href' => "https=>//api.profitbricks.com/rest/v4/um/groups/#{group_id}", 'properties' => { 'name' => options[:name], 'createDataCenter' => options[:createDataCenter], 'createSnapshot' => options[:createSnapshot], 'reserveIp' => options[:reserveIp], 'accessActivityLog' => options[:accessActivityLog] }, 'entities' => { 'users' => { 'id' => "#{group_id}/owns", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups/#{group_id}/users", 'items' => [] }, 'resources' => { 'id' => "#{group_id}/resources", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups/#{group_id}/resources", 'items' => [] } } } data[:groups]['items'] << group response.body = group response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_ip_block.rb000066400000000000000000000063421320736730600300050ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Creates a LAN within a data center # # ==== Parameters # * properties<~Hash>: # * location<~String> - Required - This must be one of the locations: us/las, de/fra, de/fkb # * size<~Integer> - Required - The desired size of the IP block # * name<~String> - A descriptive name for the IP block # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the IP Block metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - IP Block state # * properties<~Hash> - Hash containing the IP Block properties # * ips<~Array> - A collection of IPs associated with the IP Block # * location<~String> - Location the IP block resides in # * size<~Integer> - Number of IP addresses in the block # * name<~String> - A descriptive name given to the IP block # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-ip-block] def create_ip_block(options = {}) ip_block = { :properties => options } request( :expects => [202], :method => 'POST', :path => "/ipblocks", :body => Fog::JSON.encode(ip_block) ) end end class Mock def create_ip_block(options = {}) ipb_3_id = Fog::UUID.uuid ip_block = { 'id' => ipb_3_id, 'type' => 'ipblock', 'href' => "https://api.profitbricks.com/rest/v2/ipblocks/#{ipb_3_id}", 'metadata' => { 'createdDate' => '2016-07-31T15:41:27Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '5b91832ee85a758568d4523a86bd8702', 'lastModifiedDate' => '2016-07-31T15:41:27Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'ips' => ["777.777.777.777", "888.888.888.888"], 'location' => options[:location], 'size' => options[:size], 'name' => options[:name] } } data[:ip_blocks]['items'] << ip_block response = Excon::Response.new response.status = 202 response.body = ip_block response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_lan.rb000066400000000000000000000233551320736730600270000ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Creates a LAN within a data center # # ==== Parameters # * datacenter_id<~String> - Required - UUID of virtual data center # * properties<~Hash>: # * name<~String> - The name of the LAN # * public<~Integer> - Boolean indicating if the LAN faces the public Internet or not # * entities<~Hash>: # * nics<~Array> - A collection of NICs associated with the LAN # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual lan objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the LAN metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - LAN state # * properties<~Hash> - Hash containing the LAN properties # * name<~String> - The name of the LAN # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not # * ipFailover<~Array> - Attributes related to IP failover groups # * entities<~Hash> - Hash containing the LAN entities # * nics<~Hash> - Hash containing the NIC properties # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual nic objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-lan] def create_lan(datacenter_id, properties = {}, entities = {}) lan = { :properties => properties, :entities => entities } request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/lans", :body => Fog::JSON.encode(lan) ) end end class Mock def create_lan(datacenter_id, properties = {}, _entities = {}) response = Excon::Response.new response.status = 202 if datacenter = data[:datacenters]['items'].find do |attrib| attrib['id'] == datacenter_id end datacenter['properties']['version'] += 1 if datacenter['properties'] datacenter['version'] += 1 if datacenter['version'] else raise Fog::Errors::NotFound, 'Data center resource could not be found' end lan = { 'id' => '10', 'type' => 'lan', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/lans/10", 'metadata' => { 'createdDate' => '2015-03-18T19:00:51Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'faa67fbacb1c0e2e02cf9650657251f1', 'lastModifiedDate' => '2015-03-18T19:00:51Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => properties[:name], 'public' => properties[:public] }, 'entities' => { 'nics' => { 'id' => '10/nics', 'type' => 'collection', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/lans/10/nics", 'items' => [] } }, 'datacenter_id' => datacenter_id } data[:lans]['items'] << lan response.body = lan response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_load_balancer.rb000066400000000000000000000103571320736730600307720ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Creates a load balancer within the data center. Load balancers can be used for public or private IP traffic # # ==== Parameters # * datacenter_id<~String> - Required, UUID of the virtual data center # * properties<~Hash>: # * name<~String> - Required - The name of the load balancer # * ip<~String> - IPv4 address of the load balancer. All attached NICs will inherit this IP # * dhcp<~Boolean> - Indicates if the load balancer will reserve an IP using DHCP # * entities<~Hash> # * balancednics<~Array> - List of NICs taking part in load-balancing. All balanced nics inherit the IP of the loadbalancer. # See the NIC section for attribute definitions # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Load Balancer metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Load Balancer state # * properties<~Hash> - Hash containing the Load Balancer properties # * name<~String> - The name of the Load Balancer # * ip<~String> - Pv4 address of the Load Balancer. All attached NICs will inherit this IP # * dhcp<~Boolean> - Indicates if the Load Balancer will reserve an IP using DHCP # * entities<~Integer> - Hash containing the Load Balancer entities # * balancednics<~Hash> - List of NICs taking part in load-balancing. All balanced nics inherit the IP of the loadbalancer. # See the NIC section for attribute definitions # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-load-balancer] def create_load_balancer(datacenter_id, properties = {}, entities = {}) load_balancer = { :properties => properties, :entities => entities } request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/loadbalancers", :body => Fog::JSON.encode(load_balancer) ) end end class Mock def create_load_balancer(datacenter_id, properties = {}, entities = {}) response = Excon::Response.new response.status = 202 load_balancer_id = Fog::UUID.uuid nic_1_id = Fog::UUID.uuid serv_1_id = Fog::UUID.uuid properties[:ip] = '123.456.789' load_balancer = { 'id' => load_balancer_id, 'type' => 'loadbalancer', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}", 'metadata' => { 'createdDate' => '2015-03-18T19:00:51Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'faa67fbacb1c0e2e02cf9650657251f2', 'lastModifiedDate' => '2015-03-18T19:00:51Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => properties, 'entities' => entities, 'datacenter_id' => datacenter_id } data[:load_balancers]['items'] << load_balancer response.body = load_balancer response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_nic.rb000066400000000000000000000167131320736730600267770ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Adds a NIC to the target server # # ==== Parameters # * datacenter_id<~String> - Required, UUID of the virtual data center # * server_id<~String> - Required, UUID of the server # * options<~Hash>: # * name<~String> - The name of the NIC. # * ips<~Array> - IPs assigned to the NIC. This can be a collection (string) # * dhcp<~Boolean> - Set to FALSE if you wish to disable DHCP on the NIC. Default: TRUE # * lan<~Integer> - Required, The LAN ID the NIC will sit on. If the LAN ID does not exist it will be created. # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a TRUE value # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-a-nic] def create_nic(datacenter_id, server_id, options = {}, entities = {}) nic = { :properties => options, :entities => entities } request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics", :body => Fog::JSON.encode(nic) ) end end class Mock def create_nic(datacenter_id, server_id, options = {}, entities = {}) if options[:lan] == nil raise Excon::Error::HTTPStatus, "Attribute 'lan' is required" end response = Excon::Response.new response.status = 202 nic_id = Fog::UUID.uuid nic = { 'id' => nic_id, 'type' => 'nic', 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}", 'metadata' => { 'createdDate' => '2015-03-18T19:00:51Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'faa67fbacb1c0e2e02cf9650657251f2', 'lastModifiedDate' => '2015-03-18T19:00:51Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => options, 'entities' => entities, 'datacenter_id' => datacenter_id, 'server_id' => server_id } data[:nics]['items'] << nic response.body = nic response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_server.rb000066400000000000000000000410171320736730600275270ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Creates a server within an existing data center. # Additional properties such as specifying a boot volume and # connecting the server to an existing LAN can be configured. # # ==== Parameters # * datacenter_id<~String> - Required - UUID of virtual data center # * properties<~Hash>: - A hash containing the server properties # * name<~String> - Required - The hostname of the server # * cores<~Integer> - Required - The total number of cores for the server # * ram<~Integer> - Required - The amount of memory for the server in MB, e.g. 2048. # Size must be specified in multiples of 256 MB with a minimum of 256 MB; # however, if ramHotPlug is set to TRUE then a minimum of 1024 MB nust be used # * availabilityZone<~String> - The availability zone for the server (AUTO, ZONE_1, ZONE_2) # * bootCdrom<~Hash> - Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null' # * bootVolume<~Hash> - Reference to a Volume used for booting. If not 'null’ then bootCdrom has to be 'null’ # * cpuFamily<~String> - Type of CPU assigned ("AMD_OPTERON" or "INTEL_XEON") # * entities<~Hash>: - A hash containing the server entities # * cdroms<~Hash> - A collection of cdroms attached to the server # * volumes<~Hash> - A collection of volumes attached to the server # * nics<~Hash> - A collection of NICs attached to the server # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the server metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag # * lastModifiedDate<~String> - The last modified time for the resource # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Status of the virtual Machine # * properties<~Hash> - A hash containing the server properties # * name<~String> - The name of the server # * cores<~Integer> - The number of cores for the server # * ram<~Integer> - The amount of memory on the server (in megabytes) # * availabilityZone<~String> - The availability zone for the server # * vmState<~String> - The current state of the instance # * bootCdrom<~Hash> - Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null'. # * bootVolume<~Hash> - Reference to a Volume used for booting. If not ‘null’ then bootCdrom has to be ‘null’ # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the volume metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the volume. # * type<~String> - The volume type, HDD or SSD. # * size<~Integer> - The size of the volume in GB. # * image<~String> - The image or snapshot ID. # * imagePassword<~String> - Indicates if a password is set on the image. # * sshKeys<~String> - SSH keys # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN) # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * deviceNumber<~Integer> - The LUN ID of the storage volume # * cpuFamily<~String> - Type of CPU assigned # * entities<~Hash> - A hash containing the server entities # * cdroms<~Hash> - A collection of cdroms attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - The array containing individual cd rom resources # * volumes<~Hash> - A collection of volumes attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - The array containing individual volume resources (see bootVolume for detailed structure) # * nics<~Hash> - A collection of NICs attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - An array containing individual NIC resources # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the nic metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - A hash containing the nic properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once you add a firewall rule this will reflect a true value # * entities<~Hash> - A hash containing the nic entities # * firewallrules<~hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - An array of individual firewall rules associated to the NIC # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-a-server] def create_server(datacenter_id, properties = {}, entities = {}) server = { :properties => properties, :entities => entities } request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/servers", :body => Fog::JSON.encode(server) ) end end class Mock def create_server(datacenter_id, properties = {}, entities = {}) if properties[:cores] == nil raise Excon::Error::HTTPStatus, "Attribute 'cores' is required" end server_id = Fog::UUID.uuid volume_id = if entities[:volumes] && entities[:volumes]['items'] && entities[:volumes]['items'][0] && entities[:volumes]['items'][0]['id'] entities[:volumes]['items'][0]['id'] else Fog::UUID.uuid end server = { 'id' => server_id, 'type' => 'server', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}", 'datacenter_id' => datacenter_id, 'metadata' => { 'createdDate' => '2014-10-20T21:20:46Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '0018832d7a7ba455db74ac41ae9f11fe', 'lastModifiedDate' => '2015-03-18T21:31:10Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => properties[:name], 'cores' => properties[:cores], 'ram' => properties[:ram], 'availabilityZone' => properties[:availabilityZone], 'vmState' => 'RUNNING', 'cpuFamily' => properties[:cpuFamily], 'bootVolume' => properties[:bootVolume] } } if entities[:volumes] server['entities'] = { 'volumes' => { 'id' => "#{server_id}/volumes", 'type' => 'collection', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/volumes", 'items' => [ { 'id' => volume_id, 'type' => 'volume', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/volumes/#{volume_id}", 'metadata' => { 'createdDate' => '2015-03-18T19=>00=>51Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'c4a2fde6ba91a038ff953b939cc21efe', 'lastModifiedDate' => '2015-03-18T19=>00=>51Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'FogRestTestVolume', 'type' => 'HDD', 'size' => 5, 'image' => '4f363db0-4955-11e4-b362-52540066fee9', 'bus' => 'VIRTIO', 'licenceType' => 'OTHER', 'cpuHotPlug' => 'true', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'false', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'true', 'nicHotUnplug' => 'true', 'discVirtioHotPlug' => 'true', 'discVirtioHotUnplug' => 'true', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'deviceNumber' => 1 } } ] } } end if entities[:cdroms] server['entities']['cdroms'] = { 'id' => "#{server_id}/cdroms", 'type' => 'collection', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms", 'items' => [ { 'id' => 'dfcb40db-28b5-11e6-9336-52540005ab80', 'type' => 'image', 'href' => 'https=>//api.profitbricks.com/rest/v2/images/dfcb40db-28b5-11e6-9336-52540005ab80', 'metadata' => { 'createdDate' => '2016-06-02T11:33:49Z', 'createdBy' => 'System', 'etag' => '9909709d99655c6f31aca789998d7d89', 'lastModifiedDate' => '2016-06-02T11:33:49Z', 'lastModifiedBy' => 'System', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => 'CentOS-6.8-x86_64-netinstall.iso', 'description' => '', 'location' => 'us/las', 'size' => 0.23, 'cpuHotPlug' => 'true', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'true', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'true', 'nicHotUnplug' => 'true', 'discVirtioHotPlug' => 'true', 'discVirtioHotUnplug' => 'true', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'licenceType' => 'LINUX', 'imageType' => 'CDROM', 'public' => 'true' } } ] } end data[:servers]['items'] << server response = Excon::Response.new response.status = 202 response.body = server response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_user.rb000066400000000000000000000103721320736730600271770ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Create a new user under a particular contract. # # ==== Parameters # * options<~Hash>: # * firstname<~String> - Required, The name of the group. # * lastname<~String> - Required, The group will be allowed to create virtual data centers. # * email<~String> - Required, The group will be allowed to create snapshots. # * password<~String> - Required, The group will be allowed to reserve IP addresses. # * administrator<~Boolean> - The group will be allowed to access the activity log. # * forceSecAuth<~Boolean> - The group will be allowed to access the activity log. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * metadata<~Hash> - Hash containing metadata for the user. # * etag<~String> - ETag of the user. # * creationDate<~String> - A time and date stamp indicating when the user was created. # * lastLogin<~String> - A time and date stamp indicating when the user last logged in. # * properties<~Hash> - Hash containing the user's properties. # * firstname<~String> - The first name of the user. # * lastname<~String> - The last name of the user. # * email<~String> - The e-mail address of the user. # * administrator<~Boolean> - Indicates if the user has administrative rights. # * forceSecAuth<~Boolean> - Indicates if secure (two-factor) authentication was enabled for the user. # * secAuthActive<~Boolean> - Indicates if secure (two-factor) authentication is enabled for the user. # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#create-a-user] def create_user(options = {}) user = { :properties => options } request( :expects => [202], :method => 'POST', :path => "/um/users", :body => Fog::JSON.encode(user) ) end end class Mock def create_user(options = {}) if options[:email] == nil raise Excon::Error::HTTPStatus, "Attribute 'email' is required" end response = Excon::Response.new response.status = 202 user_id = Fog::UUID.uuid user = { 'id' => user_id, 'type' => 'user', 'href' => "https=>//api.profitbricks.com/rest/v4/um/users/#{user_id}", 'metadata' => { 'etag' => '26a6259cc0c1dae299a5687455dff0ce', 'creationDate' => '2017-05-22T08:15:55Z', 'lastLogin' => '', }, 'properties' => { 'firstname' => options[:firstname], 'lastname' => options[:lastname], 'email' => options[:email], 'password' => options[:password], 'administrator' => options[:administrator], 'forceSecAuth' => options[:force_sec_auth] || false, 'secAuthActive' => options[:sec_auth_active] || false }, 'entities' => { 'owns' => { 'id' => "#{user_id}/owns", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/users/#{user_id}/owns", 'items' => [] }, 'groups' => { 'id' => "#{user_id}/groups", 'type' => 'collection', 'href' => "https://api.profitbricks.com/cloudapi/v4/um/users/#{user_id}/groups", 'items' => [] } } } data[:users]['items'] << user response.body = user response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_volume.rb000066400000000000000000000163131320736730600275310ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Creates a volume within the data center. This will NOT attach the volume to a server. # # ==== Parameters # * datacenter_id<~String> - Required, UUID of virtual data center # * options<~Hash>: # * name<~String> - The name of the volume # * size<~Integer> - Required, the size of the volume in GB # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * image<~String> - Required**, the image or snapshot ID # * imageAlias<~String> - Required**, an alias to a ProfitBricks public image. Use instead of "image". # * type<~String> - The volume type, HDD or SSD # * licenceType<~String> - Required**, the licence type of the volume. Options: LINUX, WINDOWS, UNKNOWN, OTHER # * imagePassword<~String> - One-time password is set on the Image for the appropriate account. # This field may only be set in creation requests. When reading, it always returns null. # Password has to contain 8-50 characters. # Only these characters are allowed: [abcdefghjkmnpqrstuvxABCDEFGHJKLMNPQRSTUVX23456789] # * sshKeys<~String> - SSH keys to allow access to the volume via SSH # # ** Either the image or the licenceType parameters need to be provided. # licenceType is required, but if image is supplied, it will already have a licenceType set. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object's representation (absolute path) # * metadata<~Hash> - Hash containing the volume metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the volume. # * type<~String> - The volume type, HDD or SSD. # * size<~Integer> - The size of the volume in GB. # * image<~String> - The image or snapshot ID. # * imagePassword<~String> - Indicates if a password is set on the image. # * sshKeys<~String> - SSH keys # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN) # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * deviceNumber<~Integer> - The LUN ID of the volume volume # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-volume] def create_volume(datacenter_id, options = {}) volume = { :properties => options } request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/volumes", :body => Fog::JSON.encode(volume) ) end end class Mock def create_volume(datacenter_id, options = {}) response = Excon::Response.new response.status = 202 if options[:size] == nil raise Excon::Error::HTTPStatus, "Attribute 'size' is required" end if datacenter = data[:datacenters]['items'].find do |attrib| attrib['id'] == datacenter_id end datacenter['version'] += 1 if datacenter['version'] else raise Excon::Error::HTTPStatus, 'Resource does not exist' end volume_id = Fog::UUID.uuid volume = { 'id' => volume_id, 'type' => 'volume', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter['id']}/volumes/#{volume_id}", 'metadata' => { 'createdDate' => '2015-03-18T19=>00=>51Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => 'c4a2fde6ba91a038ff953b939cc21efe', 'lastModifiedDate' => '2015-03-18T19=>00=>51Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => options[:name], 'type' => options[:type], 'size' => options[:size], 'image' => options[:image], 'availabilityZone' => options[:availabilityZone], 'bus' => 'VIRTIO', 'licenceType' => 'OTHER', 'cpuHotPlug' => 'true', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'false', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'true', 'nicHotUnplug' => 'true', 'discVirtioHotPlug' => 'true', 'discVirtioHotUnplug' => 'true', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'deviceNumber' => 1 }, 'datacenter_id' => datacenter['id'] } data[:volumes]['items'] << volume response.body = volume response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb000066400000000000000000000130351320736730600314460ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Creates a snapshot of a volume within the data center. # A snapshot can be used to create a new storage volume or to restore a storage volume. # # ==== Parameters # * datacenter_id<~String> - Required, UUID of virtual data center # * options<~Hash>: # * name<~String> - The name of the snapshot # * description<~Integer> - The description of the snapshot # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the snapshot metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Snapshot state # * properties<~Hash> - Hash containing the snapshot properties # * name<~String> - The name of the snapshot. # * description<~String> - The description of the snapshot # * location<~String> - The snapshot's location # * size<~Integer> - The size of the snapshot in GB # * cpuHotPlug<~Boolean> - This snapshot is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This snapshot is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This snapshot is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This snapshot is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This snapshot is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This snapshot is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This snapshot is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This snapshot is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This snapshot is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This snapshot is capable of Scsi drive hot unplug (no reboot required) # * licenceType<~String> - The snapshot's licence type: LINUX, WINDOWS, or UNKNOWN # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-volume-snapshot] def create_volume_snapshot(datacenter_id, volume_id, options = {}) body = [["name", options[:name]]] if options[:name] request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/volumes/#{volume_id}/create-snapshot", :headers => { "Content-Type" => "application/x-www-form-urlencoded" }, :body => URI.encode_www_form(body) ) end end class Mock def create_volume_snapshot(datacenter_id, _volume_id, options = {}) response = Excon::Response.new response.status = 202 if datacenter = data[:datacenters]['items'].find do |attrib| attrib['id'] == datacenter_id end else raise Excon::Error::HTTPStatus, 'Data center resource could not be found' end snapshot_id = Fog::UUID.uuid snapshot = { 'id' => snapshot_id, 'type' => 'snapshot', 'href' => "https =>//api.profitbricks.com/rest/v2/snapshots/#{snapshot_id}", 'metadata' => { 'createdDate' => '2016-08-07T22:28:39Z', 'createdBy' => 'test@stackpointcloud.com', 'etag' => '83ad78a4757ab0d9bdeaebc3a6485dcf', 'lastModifiedDate' => '2016-08-07T22:28:39Z', 'lastModifiedBy' => 'test@stackpointcloud.com', 'state' => 'AVAILABLE' }, 'properties' => { 'name' => options[:name], 'description' => options[:description], 'location' => 'us/las', 'size' => 5, 'cpuHotPlug' => 'true', 'cpuHotUnplug' => 'false', 'ramHotPlug' => 'false', 'ramHotUnplug' => 'false', 'nicHotPlug' => 'true', 'nicHotUnplug' => 'true', 'discVirtioHotPlug' => 'true', 'discVirtioHotUnplug' => 'true', 'discScsiHotPlug' => 'false', 'discScsiHotUnplug' => 'false', 'licenceType' => 'OTHER' } } data[:snapshots]['items'] << snapshot response.body = snapshot response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_datacenter.rb000066400000000000000000000021421320736730600303260ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Delete virtual data center # # ==== Parameters # * datacenter_id<~String> - The UUID of the data center # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-a-data-center] def delete_datacenter(datacenter_id) request( :expects => [202], :method => 'DELETE', :path => "/datacenters/#{datacenter_id}" ) end end class Mock def delete_datacenter(datacenter_id) response = Excon::Response.new response.status = 202 if dc = data[:datacenters]["items"].find do |datacenter| datacenter["id"] == datacenter_id end else raise Excon::Error::HTTPStatus, "The requested resource could not be found" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb000066400000000000000000000030711320736730600310520ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Deletes the specified firewall rule # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * server_id<~String> - UUID of the server # * nic_id<~String> - UUID of the NIC # * firewall_rule_id<~String> - UUID of the NIC # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-firewall-rule] def delete_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id) request( :expects => [202], :method => 'DELETE', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}" ) end end class Mock def delete_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id) response = Excon::Response.new response.status = 202 if firewall_rule = data[:firewall_rules]["items"].find do |attribute| attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["nic_id"] == nic_id && attribute["id"] == firewall_rule_id end else raise Fog::Errors::NotFound, "The requested firewall rule resource could not be found" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_group.rb000066400000000000000000000023171320736730600273540ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Delete a single group. # Resources that are assigned to the group are NOT deleted, but are no longer accessible # to the group members unless the member is a Contract Owner, Admin, or Resource Owner. # # ==== Parameters # * group_id<~String> - UUID of the group # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#delete-a-group] def delete_group(group_id) request( :expects => [202], :method => 'DELETE', :path => "/um/groups/#{group_id}" ) end end class Mock def delete_group(group_id) response = Excon::Response.new response.status = 202 if group = data[:groups]['items'].find do |grp| grp['id'] == group_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_image.rb000066400000000000000000000020521320736730600272760ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Delete an existing image # # ==== Parameters # * image_id<~String> - UUID of the image resource # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-image] def delete_image(image_id) request( :expects => [202], :method => 'DELETE', :path => "/images/#{image_id}" ) end end class Mock def delete_image(image_id) response = Excon::Response.new response.status = 202 if img = data[:images]["items"].find do |image| image["id"] == image_id end else raise Fog::Errors::NotFound, "The requested resource could not be found" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_ip_block.rb000066400000000000000000000021061320736730600277760ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Deletes the specified IP Block # # ==== Parameters # * ip_block_id<~String> - UUID of the IP Block # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-ip-block] def delete_ip_block(ip_block_id) request( :expects => [202], :method => 'DELETE', :path => "/ipblocks/#{ip_block_id}" ) end end class Mock def delete_ip_block(ip_block_id) response = Excon::Response.new response.status = 202 if ip_block = data[:ip_blocks]["items"].find do |attribute| attribute["id"] == ip_block_id end else raise Fog::Errors::NotFound, "The requested IP Block could not be found" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_lan.rb000066400000000000000000000022671320736730600267760ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Delete the specified LAN # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * lan_id<~String> - UUID of the data center # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-lan] def delete_lan(datacenter_id, lan_id) request( :expects => [202], :method => 'DELETE', :path => "/datacenters/#{datacenter_id}/lans/#{lan_id}" ) end end class Mock def delete_lan(datacenter_id, lan_id) response = Excon::Response.new response.status = 202 if lan = data[:lans]["items"].find do |attribute| attribute["datacenter_id"] == datacenter_id && attribute["id"] == lan_id end else raise Fog::Errors::NotFound, "The requested lan could not be found" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_load_balancer.rb000066400000000000000000000024451320736730600307700ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Deletes the specified load balancer # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * load_balancer_id<~String> - UUID of the load balancer # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-load-balancer] def delete_load_balancer(datacenter_id, load_balancer_id) request( :expects => [202], :method => 'DELETE', :path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}" ) end end class Mock def delete_load_balancer(datacenter_id, load_balancer_id) response = Excon::Response.new response.status = 202 if lb = data[:load_balancers]["items"].find do |attribute| attribute["datacenter_id"] == datacenter_id && attribute["id"] == load_balancer_id end else raise Fog::Errors::NotFound, "The requested resource could not be found" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_nic.rb000066400000000000000000000025061320736730600267710ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Deletes the specified NIC # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * server_id<~String> - UUID of the server # * nic_id<~String> - UUID of the NIC # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-a-nic] def delete_nic(datacenter_id, server_id, nic_id) request( :expects => [202], :method => 'DELETE', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}" ) end end class Mock def delete_nic(datacenter_id, server_id, nic_id) response = Excon::Response.new response.status = 202 if nic = data[:nics]["items"].find do |attribute| attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["id"] == nic_id end else raise Fog::Errors::NotFound, "The requested nic resource could not be found" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_server.rb000066400000000000000000000027031320736730600275250ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # This will remove a server from a data center. # NOTE: This will not automatically remove the storage volume(s) # attached to a server. A separate API call is required to perform that action. # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * server_id<~String> - UUID of the virtual server # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-a-server] def delete_server(datacenter_id, server_id) request( :expects => [202], :method => 'DELETE', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}" ) end end class Mock def delete_server(datacenter_id, server_id) if server = data[:servers]['items'].find do |attrib| attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id end data[:servers].delete(server) else raise Fog::Errors::NotFound, 'The requested server resource could not be found' end response = Excon::Response.new response.status = 202 response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_share.rb000066400000000000000000000023441320736730600273220ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Remove a resource share from a specified group. # # ==== Parameters # * group_id<~String> - Required, The ID of the specific group containing the resource to delete. # * resource_id<~String> - Required, The ID of the specific resource to delete. # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#delete-a-share] def delete_share(group_id, resource_id) request( :expects => [202], :method => 'DELETE', :path => "/um/groups/#{group_id}/shares/#{resource_id}" ) end end class Mock def delete_share(group_id, resource_id) response = Excon::Response.new response.status = 202 if share = data[:shares]['items'].find do |shr| shr['id'] == resource_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_snapshot.rb000066400000000000000000000020001320736730600300440ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Delete virtual data center # # ==== Parameters # * snapshot_id<~String> - UUID of the snapshot # # ==== Returns # * response<~Excon::Response> # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-snapshot] def delete_snapshot(snapshot_id) request( :expects => [202], :method => 'DELETE', :path => "/snapshots/#{snapshot_id}" ) end end class Mock def delete_snapshot(snapshot_id) response = Excon::Response.new response.status = 202 if snapshot = data[:snapshots]['items'].find do |attrib| attrib['id'] == snapshot_id end else raise Fog::Errors::NotFound, 'The requested resource could not be found' end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_user.rb000066400000000000000000000023211320736730600271710ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Blacklists the user, disabling them. # The user is not completely purged, therefore if you anticipate needing to create # a user with the same name in the future, we suggest renaming the user before you delete it. # # ==== Parameters # * user_id<~String> - UUID of the user # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#delete-a-user] def delete_user(user_id) request( :expects => [202], :method => 'DELETE', :path => "/um/users/#{user_id}" ) end end class Mock def delete_user(user_id) response = Excon::Response.new response.status = 202 if user = data[:users]['items'].find do |usr| usr['id'] == user_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/delete_volume.rb000066400000000000000000000023201320736730600275210ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Deletes the specified volume # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * volume_id<~String> - UUID of the volume # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-volume] def delete_volume(datacenter_id, volume_id) request( :expects => [202], :method => 'DELETE', :path => "/datacenters/#{datacenter_id}/volumes/#{volume_id}" ) end end class Mock def delete_volume(datacenter_id, volume_id) response = Excon::Response.new response.status = 202 if vlm = data[:volumes]["items"].find do |volume| volume["id"] == volume_id && volume["datacenter_id"] == datacenter_id end else raise Excon::Error::HTTPStatus, "The requested resource could not be found" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/detach_cdrom.rb000066400000000000000000000027731320736730600273200ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Detach a CD-ROM from the server # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * server_id<~String> - UUID of the virtual server # * cdrom_id<~String> - UUID of the CD-ROM image # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#detach-a-cd-rom] def detach_cdrom(datacenter_id, server_id, cdrom_id) request( :expects => [202], :method => 'DELETE', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms/#{cdrom_id}" ) end end class Mock def detach_cdrom(datacenter_id, server_id, cdrom_id) response = Excon::Response.new response.status = 202 if server = data[:servers]['items'].find do |serv| serv['datacenter_id'] == datacenter_id && serv['id'] == server_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end if cdrom = server['cdroms']['items'].find do |cd| cd['id'] == cdrom_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/detach_volume.rb000066400000000000000000000035271320736730600275210ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Detach the volume from the server. Depending on the volume "HotUnplug" settings, # this may result in the server being rebooted. # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * server_id<~String> - UUID of the virtual server # * volume_id<~String> - UUID of the virtual storage # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#detach-a-volume] def detach_volume(datacenter_id, server_id, volume_id) request( :expects => [202], :method => 'DELETE', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/volumes/#{volume_id}" ) end end class Mock def detach_volume(datacenter_id, server_id, volume_id) response = Excon::Response.new response.status = 202 if server = data[:servers]['items'].find do |serv| serv['datacenter_id'] == datacenter_id && serv['id'] == server_id end else raise Fog::Errors::NotFound, "The server resource could not be found" end if server['entities'] volume = server['entities']['volumes']['items'].find do |vlm| vlm['id'] == volume_id end elsif server['volumes'] volume = server['volumes']['items'].find do |vlm| vlm['id'] == volume_id end else raise Fog::Errors::NotFound, "The attached volume resource could not be found" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_contract_resources.rb000066400000000000000000000062471320736730600323020ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Get all contract resources # # ==== Parameters # * None # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * type<~String> - The type of the requested resource # * properties<~Hash> # * contractNumber<~Integer> - The contract number that the returned information is from # * owner<~String> - The username of the Contract Owner # * status<~String> - The status of the contract. [ BILLABLE...] # * resourceLimits<~Hash> - An object containing the contract's resource limits # * coresPerServer<~Integer> - Maximum number of CPU cores per server # * coresPerContract<~Integer> - Maximum number of CPU cores per contract # * coresProvisioned<~Integer> - The total number of CPU cores that have been provisioned # * ramPerServer<~Integer> - The maximum amount of RAM (in MB) that may be provisioned for a particular server under this contract # * ramPerContract<~Integer> - The maximum amount of RAM (in MB) that may be provisioned under this contract # * ramProvisioned<~Integer> - The amount of RAM (in MB) that has been provisioned under this contract # * hddLimitPerVolume<~Integer> - The maximum size (in MB) of an individual hard disk volume # * hddLimitPerContract<~Integer> - The maximum amount of hard disk space (in MB) that may be provisioned under this contract # * hddVolumeProvisioned<~Integer> - The amount of hard disk space (in MB) that is currently provisioned # * ssdLimitPerVolume<~Integer> - The maximum size (in MB) of an individual solid state disk volume # * ssdLimitPerContract<~Integer> - The maximum amount of solid state disk space (in MB) that may be provisioned under this contract # * ssdVolumeProvisioned<~Integer> - The amount of solid state disk space (in MB) that is currently provisioned # * reservableIps<~Integer> - The maximum number of static public IP addresses that may be reserved by this customer across all contracts # * reservedIpsOnContract<~Integer> - The maximum number of static public IP addresses that can be reserved under this contract # * reservedIpsInUse<~Integer> - The number of static public IP addresses that have been reserved # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#contract-resources] def get_all_contract_resources request( :expects => [200], :method => 'GET', :path => "/contracts" ) end end class Mock def get_all_contract_resources response = Excon::Response.new response.status = 200 response.body = data[:contracts] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_datacenters.rb000066400000000000000000000057751320736730600306750ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Get all virtual data centers # # ==== Parameters # * None # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the resource's metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Data center state (AVAILABLE, BUSY, INACTIVE) # * properties<~Hash> - A hash containing the resource's properties # * name<~String> - The name of the data center # * description<~String> - The description of the data center # * location<~String> - The location where the data center was provisioned ("de/fkb", "de/fra", or "us/las") # * version<~Integer> - The version of the data center # * features<~Array> - The features of the data center # * entities<~Hash> - A hash containing the datacenter entities # * servers<~Hash> - A collection that represents the servers in a data center # * volumes<~Hash> - A collection that represents volumes in a data center # * loadbalancers<~Hash> - A collection that represents the loadbalancers in a data center # * lans<~Hash> - A collection that represents the LANs in a data center # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-data-centers] def get_all_datacenters request( :expects => [200], :method => 'GET', :path => "/datacenters?depth=5" ) end end class Mock def get_all_datacenters response = Excon::Response.new response.status = 200 response.body = data[:datacenters] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb000066400000000000000000000103711320736730600314030ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves a list of firewall rules associated with a particular NIC # # ==== Parameters # * datacenter_id<~String> - UUID of the datacenter # * server_id<~String> - UUID of the server # * nic_id<~String> - UUID of the NIC # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual Firewall Rule objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~String> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~String> - Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs # * targetIp<~String> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~String> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes # * icmpType<~String> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types # * portRangeStart<~String> - Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd value null to allow all ports # * portRangeEnd<~String> - Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-firewall-rules] def get_all_firewall_rules(datacenter_id, server_id, nic_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules?depth=5" ) end end class Mock def get_all_firewall_rules(datacenter_id, server_id, nic_id) firewall_rules = data[:firewall_rules] if nics = data[:firewall_rules]['items'].select do |attrib| attrib['datacenter_id'] == datacenter_id && attrib['server_id'] == server_id && attrib['nic_id'] == nic_id end else raise Fog::Errors::NotFound, 'The resource could not be found' end firewall_rules['items'] = nics response = Excon::Response.new response.status = 200 response.body = firewall_rules response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_flavors.rb000066400000000000000000000046071320736730600300450ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real def get_all_flavors response = Excon::Response.new response.status = 200 response.body = { 'getAllFlavorsResponse' => [ { 'flavorId' => '00db4c8f-5e83-49b0-a70b-ac4aad786163', 'flavorName' => 'Micro', 'ram' => 1024, 'cores' => 1 }, { 'flavorId' => 'dc64957b-be9d-431e-91cd-9e217f94d3de', 'flavorName' => 'Small', 'ram' => 2048, 'cores' => 1 }, { 'flavorId' => 'b37d000e-b347-4592-b572-df13ef8f68e1', 'flavorName' => 'Medium', 'ram' => 4096, 'cores' => 2 }, { 'flavorId' => 'a5a4389f-54b6-4f47-b6e8-1c5c55976b94', 'flavorName' => 'Large', 'ram' => 7168, 'cores' => 4 }, { 'flavorId' => '0052db40-f1dd-4ecf-a711-5980081b7059', 'flavorName' => 'Extra Large', 'ram' => 14_336, 'cores' => 8 }, { 'flavorId' => '8b2b835d-be09-48cf-aae2-7e35aafe92d6', 'flavorName' => 'Memory Intensive Small', 'ram' => 16_384, 'cores' => 2 }, { 'flavorId' => '45c28f8b-6a67-4f69-8c94-231d371da2b6', 'flavorName' => 'Memory Intensive Medium', 'ram' => 28_672, 'cores' => 4 }, { 'flavorId' => '1d22436d-d958-4151-b144-43a8e180c4c4', 'flavorName' => 'Memory Intensive Large', 'ram' => 57_344, 'cores' => 8 } ] } response end end class Mock def get_all_flavors data = self.data[:flavors] response = Excon::Response.new response.status = 200 response.body = { 'getAllFlavorsResponse' => self.data[:flavors] } response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_groups.rb000066400000000000000000000062161320736730600277060ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieve a full list of all groups. # # ==== Parameters # * None # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - Id of the requested resource # * type<~String> - type of the requested resource # * href<~String> - url to the requested resource # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * properties<~Hash> - Hash containing the volume properties. # * name<~String> - The name of the group. # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers. # * createSnapshot<~Boolean> - The group will be allowed to create snapshots. # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses. # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log. # * entities<~Hash> - A hash containing the group entities. # * users<~Hash> - A collection of users that belong to this group. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # * items<~Array> - The array containing individual user resources. # * resources<~Hash> - A collection of resources that are assigned to this group. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # * items<~Array> - An array containing individual resources. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-groups] def get_all_groups request( :expects => [200], :method => 'GET', :path => "/um/groups?depth=1" ) end end class Mock def get_all_groups response = Excon::Response.new response.status = 200 response.body = data[:groups] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_images.rb000066400000000000000000000072601320736730600276340ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Displays a list of all available images. # # ==== Parameters # * N/A # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the image metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the image # * description<~String> - The description of the image # * location<~String> - The image's location # * size<~Integer> - The size of the image in GB # * cpuHotPlug<~Boolean> - This image is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This image is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This image is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This image is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This image is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This image is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This image is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This image is capable of Scsi drive hot unplug (no reboot required) # * licenceType<~String> - The image's licence type: LINUX, WINDOWS, or UNKNOWN # * imageType<~String> - The type of image: HDD, CDROM # * public<~String> - Indicates if the image is part of the public repository or not # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-images] def get_all_images request( :expects => [200], :method => 'GET', :path => "/images?depth=5" ) end end class Mock def get_all_images response = Excon::Response.new response.status = 200 response.body = data[:images] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb000066400000000000000000000044441320736730600303350ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieve a list of IP Blocks # # ==== Parameters # * None # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual IP Block objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the IP Block metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - IP Block state # * properties<~Hash> - Hash containing the IP Block properties # * ips<~Array> - A collection of IPs associated with the IP Block # * location<~String> - Location the IP block resides in # * size<~Integer> - Number of IP addresses in the block # * name<~String> - A descriptive name given to the IP block # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-ip-blocks] def get_all_ip_blocks request( :expects => [200], :method => 'GET', :path => "/ipblocks?depth=5" ) end end class Mock def get_all_ip_blocks ip_blocks = data[:ip_blocks] response = Excon::Response.new response.status = 200 response.body = ip_blocks response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_lans.rb000066400000000000000000000200251320736730600273160ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves a list of LANs # # ==== Parameters # * datacenter_id<~String> - UUID of the datacenter # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual lan objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the LAN metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - LAN state # * properties<~Hash> - Hash containing the LAN properties # * name<~String> - The name of the LAN # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not # * ipFailover<~Array> - Attributes related to IP failover groups # * entities<~Hash> - Hash containing the LAN entities # * nics<~Hash> - Hash containing the NIC properties # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual nic objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-lans] def get_all_lans(datacenter_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/lans?depth=1" ) end end class Mock def get_all_lans(datacenter_id) lans = data[:lans] if lns = data[:lans]['items'].select do |attrib| attrib['datacenter_id'] == datacenter_id end else raise Fog::Errors::NotFound, 'The resource could not be found' end lans['items'] = lns response = Excon::Response.new response.status = 200 response.body = lans response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb000066400000000000000000000153161320736730600321340ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves a list of NICs associated with the load balancer # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * load_balancer_id<~String> - UUID of the load balancer # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual NIC objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-load-balanced-nics] def get_all_load_balanced_nics(datacenter_id, load_balancer_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}/balancednics?depth=5" ) end end class Mock def get_all_load_balanced_nics(datacenter_id, load_balancer_id) if load_balancer = data[:load_balancers]['items'].find do |lb| lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id end else raise Fog::Errors::NotFound, "The requested resource could not be found" end load_balanced_nics = nil load_balanced_nics = if load_balancer['entities'] load_balancer['entities']['balancednics'] else load_balancer['balancednics'] end response = Excon::Response.new response.status = 200 response.body = load_balanced_nics response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb000066400000000000000000000203041320736730600313120ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieve a list of load balancers within the data center # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual Load Balancer objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Load Balancer metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Load Balancer state # * properties<~Hash> - Hash containing the Load Balancer properties # * name<~String> - The name of the Load Balancer # * ip<~String> - IPv4 address of the Load Balancer. All attached NICs will inherit this IP # * dhcp<~Boolean> - Indicates if the Load Balancer will reserve an IP using DHCP # * entities<~Hash> - Hash containing the Load Balancer entities # * balancednics<~Hash> - Hash containing the NICs associated to the Load Balancer, represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual NIC objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-load-balancers] def get_all_load_balancers(datacenter_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/loadbalancers?depth=5" ) end end class Mock def get_all_load_balancers(datacenter_id) if load_balancers = data[:load_balancers]['items'].select do |attrib| attrib['datacenter_id'] == datacenter_id end else raise Fog::Errors::NotFound, 'The requested Load Balancer resource could not be found' end response = Excon::Response.new response.status = 200 response.body = data[:load_balancers] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_locations.rb000066400000000000000000000031721320736730600303600ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Get all locations # # ==== Parameters # * None # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> # * id<~String> - The resource's unique identifier consisting of country/city # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * properties<~Hash> - A hash containing the location properties # * name<~String> - A descriptive name for the location # * features<~Array> - Features available at this location # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-locations] def get_all_locations request( :expects => [200], :method => 'GET', :path => "/locations?depth=5" ) end end class Mock def get_all_locations(_options = {}) response = Excon::Response.new response.status = 200 response.body = data[:locations] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_nic.rb000066400000000000000000000145641320736730600271450ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves a list of NICs # # ==== Parameters # * datacenter_id<~String> - UUID of the datacenter # * server_id<~String> - UUID of the server # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual nic objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-nics] def get_all_nic(datacenter_id, server_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics?depth=5" ) end end class Mock def get_all_nic(datacenter_id, _server_id) interfaces = data[:nics] if nics = interfaces['items'].select do |attrib| attrib['datacenter_id'] == datacenter_id end else raise Fog::Errors::NotFound, 'The resource could not be found' end interfaces['items'] = nics response = Excon::Response.new response.status = 200 response.body = interfaces response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_requests.rb000066400000000000000000000024601320736730600302370ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves a list of requests # # ==== Parameters # * None # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual request objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-requests] def get_all_requests request( :expects => [200], :method => 'GET', :path => "/requests" ) end end class Mock def get_all_requests requests = data[:requests] response = Excon::Response.new response.status = 200 response.body = requests response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_resources.rb000066400000000000000000000071161320736730600304010ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves a list of all resources and optionally their group associations. # Please note that this API call can take a significant amount of time to return when # there are a large number of provisioned resources. # # ==== Parameters # * None # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - Id of the requested resource # * type<~String> - type of the requested resource # * href<~String> - url to the requested resource # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the metadata for the specific resource. # * createdDate<~String> - A time and date stamp indicating when the resource was created. # * createdBy<~String> - The user who created the resource. # * etag<~String> - Resource's ETag. # * lastModifiedDate<~String> - A time and date stamp indicating when the resource was last modified. # * lastModifiedBy<~String> - The user who last modified the resource. # * state<~String> - The current state of the resource. [ AVAILABLE, BUSY, INACTIVE ] # * entities<~Hash> - A hash containing groups the resource is associated with. # * groups<~Hash> - A collection of groups associated with the resource. # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * properties<~Hash> - Hash containing the volume properties. # * name<~String> - The name of the group. # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers. # * createSnapshot<~Boolean> - The group will be allowed to create snapshots. # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses. # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log. # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-resources] def get_all_resources request( :expects => [200], :method => 'GET', :path => "/um/resources?depth=2" ) end end class Mock def get_all_resources response = Excon::Response.new response.status = 200 response.body = data[:resources] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_servers.rb000066400000000000000000000232651320736730600300630ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Get all servers within a datacenter # # ==== Parameters # * datacenter_id<~String> - UUID of the datacenter which contains the servers # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the server metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag # * lastModifiedDate<~String> - The last modified time for the resource # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Status of the virtual Machine # * properties<~Hash> - A hash containing the server properties # * name<~String> - The name of the server # * cores<~Integer> - The number of cores for the server # * ram<~Integer> - The amount of memory on the server (in megabytes) # * availabilityZone<~String> - The availability zone for the server # * vmState<~String> - The current state of the instance (NOSTATE, RUNNING, BLOCKED, PAUSED, SHUTDOWN, SHUTOFF, CRASHED) # * bootCdrom<~Hash> - Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null'. # * bootVolume<~Hash> - Reference to a Volume used for booting. If not ‘null’ then bootCdrom has to be ‘null’ # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the volume metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the volume. # * type<~String> - The volume type, HDD or SSD. # * size<~Integer> - The size of the volume in GB. # * image<~String> - The image or snapshot ID. # * imagePassword<~String> - Indicates if a password is set on the image. # * sshKeys<~String> - SSH keys # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN) # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * deviceNumber<~Integer> - The LUN ID of the storage volume # * cpuFamily<~String> - Type of CPU assigned # * entities<~Hash> - A hash containing the server entities # * cdroms<~Hash> - A collection of cdroms attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - The array containing individual cd rom resources # * volumes<~Hash> - A collection of volumes attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - The array containing individual volume resources (see bootVolume for detailed structure) # * nics<~Hash> - A collection of NICs attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - An array containing individual NIC resources # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the nic metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - A hash containing the nic properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once you add a firewall rule this will reflect a true value # * entities<~Hash> - A hash containing the nic entities # * firewallrules<~hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - An array of individual firewall rules associated to the NIC # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-servers] def get_all_servers(datacenter_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/servers?depth=5" ) end end class Mock def get_all_servers(datacenter_id) if servs = data[:servers]['items'].select do |attrib| attrib['datacenter_id'] == datacenter_id end else raise Fog::Errors::NotFound, 'Server resource could not be found' end response = Excon::Response.new response.status = 200 response.body = data[:servers] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_shares.rb000066400000000000000000000034601320736730600276520ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieve a full list of all the resources that are shared through this group # and lists the permissions granted to the group members for each shared resource. # # ==== Parameters # * group_id<~String> - Required, The ID of a specific group. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - Id of the requested resource # * type<~String> - type of the requested resource # * href<~String> - url to the requested resource # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * properties<~Hash> - Hash containing the volume properties. # * editPrivilege<~Boolean> - The group has permission to edit privileges on this resource. # * sharePrivilege<~Boolean> - The group has permission to share this resource. # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-shares] def get_all_shares(group_id) request( :expects => [200], :method => 'GET', :path => "/um/groups/#{group_id}/shares?depth=1" ) end end class Mock def get_all_shares(group_id) response = Excon::Response.new response.status = 200 response.body = data[:shares] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_snapshots.rb000066400000000000000000000072601320736730600304110ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieve a list of all snapshots # # ==== Parameters # * None # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the resource's metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Snapshot state (AVAILABLE, BUSY, INACTIVE) # * properties<~Hash> - A hash containing the resource's properties # * name<~String> - The name of the snapshot # * description<~String> - The description of the snapshot # * location<~String> - The snapshot's location ("de/fkb", "de/fra", or "us/las") # * version<~Integer> - The version of the data center # * size<~Integer> - The size of the snapshot in GB # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * licencetype<~String> - The snapshot's licence type: LINUX, WINDOWS, or UNKNOWN. # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-snapshots] def get_all_snapshots request( :expects => [200], :method => 'GET', :path => "/snapshots?depth=5" ) end end class Mock def get_all_snapshots response = Excon::Response.new response.status = 200 response.body = data[:snapshots] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_users.rb000066400000000000000000000073601320736730600275310ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieve a list of all the users that have been created under a contract. # # ==== Parameters # * None # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - Id of the requested resource # * type<~String> - type of the requested resource # * href<~String> - url to the requested resource # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * metadata<~Hash> - Hash containing metadata for the user. # * etag<~String> - ETag of the user. # * creationDate<~String> - A time and date stamp indicating when the user was created. # * lastLogin<~String> - A time and date stamp indicating when the user last logged in. # * properties<~Hash> - Hash containing the user's properties. # * firstname<~String> - The first name of the user. # * lastname<~String> - The last name of the user. # * email<~String> - The e-mail address of the user. # * administrator<~Boolean> - Indicates if the user has administrative rights. # * forceSecAuth<~Boolean> - Indicates if secure (two-factor) authentication was enabled for the user. # * secAuthActive<~Boolean> - Indicates if secure (two-factor) authentication is enabled for the user. # * entities<~Hash> - Hash containing resources the user owns, and groups the user is a member of. # * owns<~Hash> - Hash containing resources the user owns. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * groups<~Hash> - Hash containing groups the user is a member of. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-users] def get_all_users request( :expects => [200], :method => 'GET', :path => "/um/users?depth=1" ) end end class Mock def get_all_users response = Excon::Response.new response.status = 200 response.body = data[:users] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_all_volumes.rb000066400000000000000000000102601320736730600300530ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieve a list of all volumes # # ==== Parameters # * datacenter_id - UUID of the datacenter which contains the volumes # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - Id of the requested resource # * type<~String> - type of the requested resource # * href<~String> - url to the requested resource # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the volume metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the volume. # * type<~String> - The volume type, HDD or SSD. # * size<~Integer> - The size of the volume in GB. # * image<~String> - The image or snapshot ID. # * imagePassword<~Boolean> - Indicates if a password is set on the image. # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN) # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * deviceNumber<~Integer> - The LUN ID of the storage volume # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-volumes] def get_all_volumes(datacenter_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/volumes?depth=5" ) end end class Mock def get_all_volumes(datacenter_id) volumes = data[:volumes] if vlms = data[:volumes]['items'].select do |attrib| attrib['datacenter_id'] == datacenter_id end else raise Fog::Errors::NotFound, 'Volume resource could not be found' end volumes['items'] = vlms response = Excon::Response.new response.status = 200 response.body = data[:volumes] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb000066400000000000000000000102251320736730600304730ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieve the properties of an attached volume # # ==== Parameters # * datacenter_id<~String> - Required - UUID of the datacenter # * server_id<~String> - Required - UUID of the server # * cdrom_image_id<~String> - Required - UUID of the attached volume # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the image metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the image # * description<~String> - The description of the image # * location<~String> - The image's location # * size<~Integer> - The size of the image in GB # * cpuHotPlug<~Boolean> - This image is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This image is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This image is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This image is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This image is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This image is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This image is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This image is capable of Scsi drive hot unplug (no reboot required) # * licenceType<~String> - The image's licence type: LINUX, WINDOWS, or UNKNOWN # * imageType<~String> - The type of image: HDD, CDROM # * public<~String> - Indicates if the image is part of the public repository or not # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#retrieve-attached-cd-rom] def get_attached_cdrom(datacenter_id, server_id, cdrom_image_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms/#{cdrom_image_id}?depth=1" ) end end class Mock def get_attached_cdrom(datacenter_id, server_id, cdrom_image_id) if server = data[:servers]['items'].find do |serv| serv['datacenter_id'] == datacenter_id && serv['id'] == server_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end if cdrom = server['cdroms']['items'].find do |cd| cd['id'] == cdrom_image_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = cdrom response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_attached_volume.rb000066400000000000000000000107451320736730600307050ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieve the properties of an attached volume # # ==== Parameters # * datacenter_id<~String> - Required - UUID of the datacenter # * server_id<~String> - Required - UUID of the server # * volume_id<~String> - Required - UUID of the attached volume # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the volume metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the volume. # * type<~String> - The volume type, HDD or SSD. # * size<~Integer> - The size of the volume in GB. # * image<~String> - The image or snapshot ID. # * imagePassword<~Boolean> - Indicates if a password is set on the image. # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN) # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * deviceNumber<~Integer> - The LUN ID of the storage volume # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#retrieve-an-attached-volume] def get_attached_volume(datacenter_id, server_id, volume_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/volumes/#{volume_id}?depth=1" ) end end class Mock def get_attached_volume(datacenter_id, server_id, volume_id) if server = data[:servers]['items'].find do |serv| serv['datacenter_id'] == datacenter_id && serv['id'] == server_id end else raise Fog::Errors::NotFound, "The server resource could not be found" end if server['entities'] volume = server['entities']['volumes']['items'].find do |vlm| vlm['id'] == volume_id end elsif server['volumes'] volume = server['volumes']['items'].find do |vlm| vlm['id'] == volume_id end else raise Fog::Errors::NotFound, "The attached volume resource could not be found" end response = Excon::Response.new response.status = 200 response.body = volume response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_datacenter.rb000066400000000000000000000057741320736730600276610ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Get a virtual data center by id # # ==== Parameters # * options<~Hash>: # * datacenter_id<~String> - UUID of virtual data center # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the resource's metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Data center state (AVAILABLE, BUSY, INACTIVE) # * properties<~Hash> - A hash containing the resource's properties # * name<~String> - The name of the data center # * description<~String> - The description of the data center # * location<~String> - The location where the data center was provisioned ("de/fkb", "de/fra", or "us/las") # * version<~Integer> - The version of the data center # * features<~Array> - The features of the data center # * entities<~Hash> - A hash containing the datacenter entities # * servers<~Hash> - A collection that represents the servers in a data center # * volumes<~Hash> - A collection that represents volumes in a data center # * loadbalancers<~Hash> - A collection that represents the loadbalancers in a data center # * lans<~Hash> - A collection that represents the LANs in a data center # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#retrieve-a-data-center] def get_datacenter(datacenter_id) request( :expects => [200], :method => "GET", :path => "/datacenters/#{datacenter_id}?depth=5" ) end end class Mock def get_datacenter(datacenter_id) if dc = data[:datacenters]["items"].find do |datacenter| datacenter["id"] == datacenter_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = dc response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb000066400000000000000000000077411320736730600303770ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a given Firewall Rule # # ==== Parameters # * datacenter_id<~String> - UUID of the datacenter # * server_id<~String> - UUID of the server # * nic_id<~String> - UUID of the NIC # * firewall_rule_id<~String> - UUID of the firewall rule # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~String> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~String> - Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs # * targetIp<~String> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~String> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes # * icmpType<~String> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types # * portRangeStart<~String> - Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd value null to allow all ports # * portRangeEnd<~String> - Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-firewall-rule] def get_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id) request( :expects => [200], :method => "GET", :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}?depth=5" ) end end class Mock def get_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id) if firewall_rule = data[:firewall_rules]['items'].find do |fwr| fwr["datacenter_id"] == datacenter_id && fwr["server_id"] == server_id && fwr["nic_id"] == nic_id && fwr["id"] == firewall_rule_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = firewall_rule response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_flavor.rb000066400000000000000000000051751320736730600270330ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real def get_flavor(flavor_id) response = Excon::Response.new response.status = 200 response.body = { "getFlavorResponse" => [ { "flavorId" => "00db4c8f-5e83-49b0-a70b-ac4aad786163", "flavorName" => "Micro", "ram" => 1024, "cores" => 1 }, { "flavorId" => "dc64957b-be9d-431e-91cd-9e217f94d3de", "flavorName" => "Small", "ram" => 2048, "cores" => 1 }, { "flavorId" => "b37d000e-b347-4592-b572-df13ef8f68e1", "flavorName" => "Medium", "ram" => 4096, "cores" => 2 }, { "flavorId" => "a5a4389f-54b6-4f47-b6e8-1c5c55976b94", "flavorName" => "Large", "ram" => 7168, "cores" => 4 }, { "flavorId" => "0052db40-f1dd-4ecf-a711-5980081b7059", "flavorName" => "Extra Large", "ram" => 14_336, "cores" => 8 }, { "flavorId" => "8b2b835d-be09-48cf-aae2-7e35aafe92d6", "flavorName" => "Memory Intensive Small", "ram" => 16_384, "cores" => 2 }, { "flavorId" => "45c28f8b-6a67-4f69-8c94-231d371da2b6", "flavorName" => "Memory Intensive Medium", "ram" => 28_672, "cores" => 4 }, { "flavorId" => "1d22436d-d958-4151-b144-43a8e180c4c4", "flavorName" => "Memory Intensive Large", "ram" => 57_344, "cores" => 8 } ].find { |flavor| flavor["flavorId"] == flavor_id } || raise(Fog::Errors::NotFound) } response end end class Mock def get_flavor(flavor_id) response = Excon::Response.new response.status = 200 if flavor = data[:flavors].find do |attrib| attrib["flavorId"] == flavor_id end else raise Fog::Errors::NotFound, "The requested flavor could not be found" end response.body = { "getFlavorResponse" => flavor } response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_group.rb000066400000000000000000000061471320736730600266760ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a given volume # # ==== Parameters # * group_id<~String> - Required, UUID of the group # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * properties<~Hash> - Hash containing the volume properties. # * name<~String> - The name of the group. # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers. # * createSnapshot<~Boolean> - The group will be allowed to create snapshots. # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses. # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log. # * entities<~Hash> - A hash containing the group entities. # * users<~Hash> - A collection of users that belong to this group. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # * items<~Array> - The array containing individual user resources. # * resources<~Hash> - A collection of resources that are assigned to this group. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # * items<~Array> - An array containing individual resources. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#retrieve-a-group] def get_group(group_id) request( :expects => [200], :method => "GET", :path => "/um/groups/#{group_id}" ) end end class Mock def get_group(group_id) if group = data[:groups]['items'].find do |grp| grp["id"] == group_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = group response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_group_users.rb000066400000000000000000000101121320736730600301020ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves a full list of all the users that are members of a particular group. # # ==== Parameters # * None # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - Id of the requested resource # * type<~String> - type of the requested resource # * href<~String> - url to the requested resource # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * metadata<~Hash> - Hash containing metadata for the user. # * etag<~String> - ETag of the user. # * creationDate<~String> - A time and date stamp indicating when the user was created. # * lastLogin<~String> - A time and date stamp indicating when the user last logged in. # * properties<~Hash> - Hash containing the user's properties. # * firstname<~String> - The first name of the user. # * lastname<~String> - The last name of the user. # * email<~String> - The e-mail address of the user. # * administrator<~Boolean> - Indicates if the user has administrative rights. # * forceSecAuth<~Boolean> - Indicates if secure (two-factor) authentication was enabled for the user. # * secAuthActive<~Boolean> - Indicates if secure (two-factor) authentication is enabled for the user. # * entities<~Hash> - Hash containing resources the user owns, and groups the user is a member of. # * owns<~Hash> - Hash containing resources the user owns. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * groups<~Hash> - Hash containing groups the user is a member of. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-users-in-a-group] def get_group_users(group_id) request( :expects => [200], :method => 'GET', :path => "/um/groups/#{group_id}/users?depth=2" ) end end class Mock def get_group_users(group_id) if users = data[:groups]['items']['users'].find do |usr| usr["groups"]["items"].find do |grp| grp["id"] == group_id end end else raise Fog::Errors::NotFound, "The requested resource could not be found" end response = Excon::Response.new response.status = 200 response.body = users response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_image.rb000066400000000000000000000071331320736730600266200ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a specific image # # ==== Parameters # * image_id<~String> - UUID of virtual data center # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the image metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the image # * description<~String> - The description of the image # * location<~String> - The image's location # * size<~Integer> - The size of the image in GB # * cpuHotPlug<~Boolean> - This image is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This image is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This image is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This image is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This image is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This image is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This image is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This image is capable of Scsi drive hot unplug (no reboot required) # * licenceType<~String> - The image's licence type: LINUX, WINDOWS, or UNKNOWN # * imageType<~String> - The type of image: HDD, CDROM # * public<~String> - Indicates if the image is part of the public repository or not # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-image] def get_image(image_id) request( :expects => [200], :method => "GET", :path => "/images/#{image_id}?depth=5" ) end end class Mock def get_image(image_id) if img = data[:images]["items"].find do |image| image["id"] == image_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = img response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_ip_block.rb000066400000000000000000000043351320736730600273210ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a specific IP Block # # ==== Parameters # * ip_block_id<~String> - UUID of the IP Block # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the IP Block metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - IP Block state # * properties<~Hash> - Hash containing the IP Block properties # * ips<~Array> - A collection of IPs associated with the IP Block # * location<~String> - Location the IP block resides in # * size<~Integer> - Number of IP addresses in the block # * name<~String> - A descriptive name given to the IP block # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-ip-block] def get_ip_block(ip_block_id) request( :expects => [200], :method => "GET", :path => "/ipblocks/#{ip_block_id}?depth=5" ) end end class Mock def get_ip_block(ip_block_id) if ip_block = data[:ip_blocks]['items'].find do |ipb| ipb["id"] == ip_block_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = ip_block response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_lan.rb000066400000000000000000000200571320736730600263100ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a given LAN # # ==== Parameters # * datacenter_id<~String> - UUID of the datacenter # * lan_id<~String> - UUID of the LAN # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual lan objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the LAN metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - LAN state # * properties<~Hash> - Hash containing the LAN properties # * name<~String> - The name of the LAN # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not # * ipFailover<~Array> - Attributes related to IP failover groups # * entities<~Hash> - Hash containing the LAN entities # * nics<~Hash> - Hash containing the NIC properties # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual nic objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-lan] def get_lan(datacenter_id, lan_id) request( :expects => [200], :method => "GET", :path => "/datacenters/#{datacenter_id}/lans/#{lan_id}?depth=5" ) end end class Mock def get_lan(datacenter_id, lan_id) if lan = data[:lans]['items'].find do |ln| ln["datacenter_id"] == datacenter_id && ln["id"] == lan_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = lan response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb000066400000000000000000000152261320736730600311210ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a given loadbalanced NIC # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * load_balancer_id<~String> - UUID of the load balancer # * nic_id<~String> - UUID of the NIC # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-load-balanced-nic] def get_load_balanced_nic(datacenter_id, load_balancer_id, nic_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}/balancednics/#{nic_id}?depth=5" ) end end class Mock def get_load_balanced_nic(datacenter_id, load_balancer_id, _nic_id) if load_balancer = data[:load_balancers]['items'].find do |lb| lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end load_balanced_nic = nil load_balanced_nic = if load_balancer['entities'] load_balancer['entities']['balancednics']['items'][0] else load_balancer['balancednics']['items'][0] end load_balanced_nic['mac'] = '01:23:45:67:89:00' load_balanced_nic['nat'] = false load_balanced_nic['firewall_active'] = true load_balanced_nic['lan'] = load_balanced_nic[:lan] load_balanced_nic['ips'] = load_balanced_nic[:ips] response = Excon::Response.new response.status = 200 response.body = load_balanced_nic response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_load_balancer.rb000066400000000000000000000175321320736730600303100ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a given load balancer # # ==== Parameters # * datacenter_id<~String> - UUID of the datacenter # * load_balancer_id<~String> - UUID of the load balancer # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Load Balancer metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Load Balancer state # * properties<~Hash> - Hash containing the Load Balancer properties # * name<~String> - The name of the Load Balancer # * ip<~String> - IPv4 address of the Load Balancer. All attached NICs will inherit this IP # * dhcp<~Boolean> - Indicates if the Load Balancer will reserve an IP using DHCP # * entities<~Hash> - Hash containing the Load Balancer entities # * balancednics<~Hash> - Hash containing the NICs associated to the Load Balancer, represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual NIC objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-load-balancer] def get_load_balancer(datacenter_id, load_balancer_id) request( :expects => [200], :method => "GET", :path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}?depth=5" ) end end class Mock def get_load_balancer(datacenter_id, load_balancer_id) if load_balancer = data[:load_balancers]['items'].find do |lb| lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = load_balancer response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_location.rb000066400000000000000000000031001320736730600273340ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Get all locations # # ==== Parameters # * location_id<~String> - UUID of the location # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier consisting of country/city # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * properties<~Hash> - A hash containing the location properties # * name<~String> - A descriptive name for the location # * features<~Array> - Features available at this location # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-location] def get_location(location_id) request( :expects => [200], :method => 'GET', :path => "/locations/#{location_id}?depth=5" ) end end class Mock def get_location(location_id) if loc = data[:locations]['items'].find do |lo| lo["id"] == location_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = loc response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_nic.rb000066400000000000000000000137121320736730600263070ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a given NIC # # ==== Parameters # * datacenter_id<~String> - UUID of the datacenter # * server_id<~String> - UUID of the server # * nic_id<~String> - UUID of the NIC # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-a-nic] def get_nic(datacenter_id, server_id, nic_id) request( :expects => [200], :method => "GET", :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}?depth=5" ) end end class Mock def get_nic(datacenter_id, server_id, nic_id) if nic = data[:nics]['items'].find do |nic| nic["id"] == nic_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = nic response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_request.rb000066400000000000000000000050531320736730600272250ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a specific request # # ==== Parameters # * request_id<~String> - The requests's unique identifier # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the resource's metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * requestStatus<~Hash> - A hash containing the request status data # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * properties<~Hash> - A hash containing the resource's properties # * method<~String> - The HTTP method used # * headers<~Hash> - A hash containing the request headers # * connection<~String> # * host<~String> # * x-forwarded-for<~String> # * content-length<~String> # * x-reseller<~String> # * x-forwarded-host<~String> # * user-agent<~String> # * x-forwarded-server<~String> # * body<~String> - The body of the request # * url<~String> - The targeted URL of the request # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-request] def get_request(request_id) request( :expects => [200], :method => 'GET', :path => "/requests/#{request_id}" ) end end class Mock def get_request(request_id) if request = data[:requests]["items"].find do |req| req["id"] == request_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = data[:requests]['items'][0] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_request_status.rb000066400000000000000000000035771320736730600306410ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the status of the request # # ==== Parameters # * request_id<~String> - The requests's unique identifier # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the resource's metadata # * status<~String> - The status of the entire request, e.g. RUNNING # * message<~String> - The request message # * etag<~String> - The etag for the resource # * targets<~Array> - The request status targets represented as a collection # * target<~Hash> - A hash containing individual target attributes # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * status<~String> - Status of individual items within the request, e.g. DONE # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-request-status] def get_request_status(request_id) request( :expects => [200], :method => 'GET', :path => "/requests/#{request_id}/status" ) end end class Mock def get_request_status(_request_id) response = Excon::Response.new response.status = 200 response.body = data[:request_status] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_resource_by_type.rb000066400000000000000000000114751320736730600311240ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # ==== Parameters # * resource_type<~String> - Required, Type of resource. [datacenter, image, snapshot, ipblock] # * resource_id<~String> - Required, The ID of the specific resource to retrieve information about. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - A URI for accessing the resource object. # * metadata<~Hash> - Hash containing metadata for the specific resource. # * createdDate<~String> - A time and date stamp indicating when the resource was created. # * createdBy<~String> - The user who created the resource. # * etag<~String> - Resource's ETag. # * lastModifiedDate<~String> - A time and date stamp indicating when the resource was last modified. # * lastModifiedBy<~String> - The user who last modified the resource. # * state<~String> - The current state of the resource. [ AVAILABLE, BUSY, INACTIVE ] # * entities<~Hash> - Hash containing groups the resource is associated with. # * groups<~Hash> - Hash containing groups associated with the resource. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * properties<~Hash> - Hash containing the volume properties. # * name<~String> - The name of the group. # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers. # * createSnapshot<~Boolean> - The group will be allowed to create snapshots. # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses. # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log. # * entities<~Hash> - A hash containing the group entities. # * users<~Hash> - A collection of users that belong to this group. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # * items<~Array> - The array containing individual user resources. # * resources<~Hash> - A collection of resources that are assigned to this group. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # * items<~Array> - An array containing individual resources. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-a-specific-resource-type] def get_resource_by_type(resource_type, resource_id) request( :expects => [200], :method => 'GET', :path => "/um/resources/#{resource_type}/#{resource_id}?depth=2" ) end end class Mock def get_resource_by_type(resource_type, resource_id) if resource = data[:resources]['items'].find do |r| r["type"] == resource_type && r["id"] == resource_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = resource response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_resources_by_type.rb000066400000000000000000000037251320736730600313060ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # List all shareable resources of a specific type. # Optionally include their association with groups, permissions that a group has # for the resource, and users that are members of the group. # # ==== Parameters # * resource_type<~String> - Required, Type of resource. [datacenter, image, snapshot, ipblock] # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - "resources" # * type<~String> - The type of response, in this case it will be "collection". # * href<~String> - A URI for accessing the object. "baseurl/um/resources" # * items<~Array> - A collection containing the available resources. # * id<~String> - The resource's unique identifier # * type<~String> - The type of object. # * href<~String> - A URI for accessing the object. # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#list-all-resources-of-a-type] def get_resources_by_type(resource_type) request( :expects => [200], :method => 'GET', :path => "/um/resources/#{resource_type}?depth=2" ) end end class Mock def get_resources_by_type(resource_type) if resources = data[:resources]['items'].select {|resource| resource['type'] == resource_type} result = data[:resources].dup result['items'] = resources else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = result response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_server.rb000066400000000000000000000227161320736730600270500ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Create new virtual server # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * server_id<~String> - UUID of the virtual server # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the server metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag # * lastModifiedDate<~String> - The last modified time for the resource # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Status of the virtual Machine # * properties<~Hash> - A hash containing the server properties # * name<~String> - The name of the server # * cores<~Integer> - The number of cores for the server # * ram<~Integer> - The amount of memory on the server (in megabytes) # * availabilityZone<~String> - The availability zone for the server # * vmState<~String> - The current state of the instance (NOSTATE, RUNNING, BLOCKED, PAUSED, SHUTDOWN, SHUTOFF, CRASHED) # * bootCdrom<~Hash> - Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null'. # * bootVolume<~Hash> - Reference to a Volume used for booting. If not ‘null’ then bootCdrom has to be ‘null’ # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the volume metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the volume. # * type<~String> - The volume type, HDD or SSD. # * size<~Integer> - The size of the volume in GB. # * image<~String> - The image or snapshot ID. # * imagePassword<~String> - Indicates if a password is set on the image. # * sshKeys<~String> - SSH keys # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN) # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * deviceNumber<~Integer> - The LUN ID of the storage volume # * cpuFamily<~String> - Type of CPU assigned # * entities<~Hash> - A hash containing the server entities # * cdroms<~Hash> - A collection of cdroms attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - The array containing individual cd rom resources # * volumes<~Hash> - A collection of volumes attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - The array containing individual volume resources (see bootVolume for detailed structure) # * nics<~Hash> - A collection of NICs attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - An array containing individual NIC resources # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the nic metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - A hash containing the nic properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once you add a firewall rule this will reflect a true value # * entities<~Hash> - A hash containing the nic entities # * firewallrules<~hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - An array of individual firewall rules associated to the NIC # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#retrieve-a-server] def get_server(datacenter_id, server_id) request( :expects => [200], :method => "GET", :path => "/datacenters/#{datacenter_id}/servers/#{server_id}?depth=5" ) end end class Mock def get_server(datacenter_id, server_id) if server = data[:servers]['items'].find do |serv| serv['datacenter_id'] == datacenter_id && serv['id'] == server_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = server response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_share.rb000066400000000000000000000040011320736730600266270ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a given volume # # ==== Parameters # * group_id<~String> - Required, The ID of the specific group to retrieve. # * resource_id<~String> - Required, The ID of the specific resource to retrieve. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - Id of the requested resource # * type<~String> - type of the requested resource # * href<~String> - url to the requested resource # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * properties<~Hash> - Hash containing the share properties. # * editPrivilege<~Boolean> - The group has permission to edit privileges on this resource. # * sharePrivilege<~Boolean> - The group has permission to share this resource. # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#retrieve-a-share] def get_share(group_id, resource_id) request( :expects => [200], :method => "GET", :path => "/um/groups/#{group_id}/shares/#{resource_id}" ) end end class Mock def get_share(group_id, resource_id) if share = data[:shares]['items'].find do |shr| shr["id"] == resource_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = share response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_snapshot.rb000066400000000000000000000071751320736730600274030ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a specific snapshot # # ==== Parameters # * snapshot_id<~String> - Required, UUID of the snapshot # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the resource's metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Snapshot state (AVAILABLE, BUSY, INACTIVE) # * properties<~Hash> - A hash containing the resource's properties # * name<~String> - The name of the snapshot # * description<~String> - The description of the snapshot # * location<~String> - The snapshot's location ("de/fkb", "de/fra", or "us/las") # * version<~Integer> - The version of the data center # * size<~Integer> - The size of the snapshot in GB # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * licencetype<~String> - The snapshot's licence type: LINUX, WINDOWS, or UNKNOWN. # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-snapshot] def get_snapshot(snapshot_id) request( :expects => [200], :method => "GET", :path => "/snapshots/#{snapshot_id}" ) end end class Mock def get_snapshot(snapshot_id) if snapshot = data[:snapshots]['items'].find do |attrib| attrib["id"] == snapshot_id end else raise Excon::Error::HTTPStatus, 'Resource does not exist' end response = Excon::Response.new response.status = 200 response.body = snapshot response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_user.rb000066400000000000000000000073101320736730600265110ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieve details about a specific user including what groups and resources the user is associated with. # # ==== Parameters # * user_id<~String> - Required, UUID of the user # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the resource. # * href<~String> - URL to the object's representation (absolute path). # * metadata<~Hash> - Hash containing metadata for the user. # * etag<~String> - ETag of the user. # * creationDate<~String> - A time and date stamp indicating when the user was created. # * lastLogin<~String> - A time and date stamp indicating when the user last logged in. # * properties<~Hash> - Hash containing the user's properties. # * firstname<~String> - The first name of the user. # * lastname<~String> - The last name of the user. # * email<~String> - The e-mail address of the user. # * administrator<~Boolean> - Indicates if the user has administrative rights. # * forceSecAuth<~Boolean> - Indicates if secure (two-factor) authentication was enabled for the user. # * secAuthActive<~Boolean> - Indicates if secure (two-factor) authentication is enabled for the user. # * entities<~Hash> - Hash containing resources the user owns, and groups the user is a member of. # * owns<~Hash> - Hash containing resources the user owns. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * groups<~Hash> - Hash containing groups the user is a member of. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#retrieve-a-user] def get_user(user_id) request( :expects => [200], :method => "GET", :path => "/um/users/#{user_id}?depth=1" ) end end class Mock def get_user(user_id) if user = data[:users]['items'].find do |usr| usr["id"] == user_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = user response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/get_volume.rb000066400000000000000000000076501320736730600270510ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Retrieves the attributes of a given volume # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * volume_id<~String> - UUID of the volume # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the volume metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the volume. # * type<~String> - The volume type, HDD or SSD. # * size<~Integer> - The size of the volume in GB. # * image<~String> - The image or snapshot ID. # * imagePassword<~Boolean> - Indicates if a password is set on the image. # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN) # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * deviceNumber<~Integer> - The LUN ID of the storage volume # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-volume] def get_volume(datacenter_id, volume_id) request( :expects => [200], :method => "GET", :path => "/datacenters/#{datacenter_id}/volumes/#{volume_id}" ) end end class Mock def get_volume(datacenter_id, volume_id) if volume = data[:volumes]['items'].find do |vlm| vlm["id"] == volume_id && vlm["datacenter_id"] == datacenter_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = volume response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb000066400000000000000000000104151320736730600310530ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Get a list of CD-ROMs attached to the server # # ==== Parameters # * datacenter_id<~String> - Required - UUID of the datacenter # * server_id<~String> - Required - UUID of the server # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the image metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the image # * description<~String> - The description of the image # * location<~String> - The image's location # * size<~Integer> - The size of the image in GB # * cpuHotPlug<~Boolean> - This image is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This image is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This image is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This image is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This image is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This image is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This image is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This image is capable of Scsi drive hot unplug (no reboot required) # * licenceType<~String> - The image's licence type: LINUX, WINDOWS, or UNKNOWN # * imageType<~String> - The type of image: HDD, CDROM # * public<~String> - Indicates if the image is part of the public repository or not # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-attached-cd-roms] def list_attached_cdroms(datacenter_id, server_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms?depth=1" ) end end class Mock def list_attached_cdroms(datacenter_id, server_id) if server = data[:servers]['items'].find do |serv| serv['datacenter_id'] == datacenter_id && serv['id'] == server_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end data[:images]['items'] = data[:images]['items'].select {|img| img['imageType'] == 'CDROM'} response = Excon::Response.new response.status = 200 response.body = data[:images] response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb000066400000000000000000000113341320736730600312570ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Get a list of volumes attached to the server # # ==== Parameters # * datacenter_id<~String> - Required - UUID of the datacenter # * server_id<~String> - Required - UUID of the server # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - Id of the requested resource # * type<~String> - type of the requested resource # * href<~String> - url to the requested resource # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the volume metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the volume. # * type<~String> - The volume type, HDD or SSD. # * size<~Integer> - The size of the volume in GB. # * image<~String> - The image or snapshot ID. # * imagePassword<~Boolean> - Indicates if a password is set on the image. # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN) # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * deviceNumber<~Integer> - The LUN ID of the storage volume # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-attached-volumes] def list_attached_volumes(datacenter_id, server_id) request( :expects => [200], :method => 'GET', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/volumes?depth=1" ) end end class Mock def list_attached_volumes(datacenter_id, server_id) if server = data[:servers]['items'].find do |serv| serv['datacenter_id'] == datacenter_id && serv['id'] == server_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 200 response.body = if server['volumes'] server['volumes'] else { 'id' => "#{server_id}/volumes", 'type' => 'collection', 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/volumes", 'items' => [] } end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/reboot_server.rb000066400000000000000000000026371320736730600275630ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # This will force a hard reboot of the server. # Do not use this method if you want to gracefully reboot the machine. # This is the equivalent of powering off the machine and turning it back on # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * server_id<~String> - UUID of the virtual server # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#reboot-a-server] def reboot_server(datacenter_id, server_id) request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/reboot" ) end end class Mock def reboot_server(datacenter_id, server_id) if server = data[:servers]['items'].find do |attrib| attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id end else raise Fog::Errors::NotFound, 'The requested server resource could not be found' end response = Excon::Response.new response.status = 202 response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/remove_nic_association.rb000066400000000000000000000026741320736730600314260ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Associates a NIC to a Load Balancer, enabling the NIC to participate in load-balancing # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * load_balancer_id<~String> - UUID of the load balancer # * nic_id<~String> - UUID of the NIC # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#remove-a-nic-association] def remove_nic_association(datacenter_id, load_balancer_id, nic_id) request( :expects => [202], :method => 'DELETE', :path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}/balancednics/#{nic_id}" ) end end class Mock def remove_nic_association(datacenter_id, load_balancer_id, _nic_id) if load_balancer = data[:load_balancers]['items'].find do |lb| lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id end else raise Fog::Errors::NotFound, "The requested resource could not be found" end response = Excon::Response.new response.status = 202 response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/remove_user_from_group.rb000066400000000000000000000026551320736730600314750ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Remove a user from a group. # # ==== Parameters # * group_id<~String> - Required, The ID of the specific group you want to remove a user from. # * user_id<~String> - Required, The ID of the specific user to remove from the group. # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#remove-user-from-a-group] def remove_user_from_group(group_id, user_id) request( :expects => [202], :method => 'DELETE', :path => "/um/groups/#{group_id}/users/#{user_id}" ) end end class Mock def remove_user_from_group(group_id, user_id) response = Excon::Response.new response.status = 202 if group = data[:groups]['items'].find do |grp| grp["id"] == group_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end if user = data[:users]['items'].find do |usr| usr["id"] == user_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb000066400000000000000000000043471320736730600316740ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Restores a snapshot onto a volume. # A snapshot is created as just another image that can be used to create new volumes or to restore an existing volume. # # ==== Parameters # * datacenter_id<~String> - Required, UUID of virtual data center # * volume_id<~String> - Required, UUID of the snapshot # * options<~Hash>: # * snapshotId<~String> - Required, The ID of the snapshot # # ==== Returns # * response<~Excon::Response> - No response parameters # * status<~Integer> - HTTP status for the request # * headers<~Array> - The response headers # * Location<~String> - URL of a request resource which should be used for operation's status polling # * Date<~String> # * Content-Length<~Integer> # * Connection<~String> # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-volume-snapshot] def restore_volume_snapshot(datacenter_id, volume_id, options = {}) request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/volumes/#{volume_id}/restore-snapshot", :headers => { "Content-Type" => "application/x-www-form-urlencoded" }, :body => URI.encode_www_form("snapshotId" => options[:snapshot_id]) ) end end class Mock def restore_volume_snapshot(datacenter_id, volume_id, _options = {}) response = Excon::Response.new response.status = 202 if datacenter = data[:datacenters]['items'].find do |attrib| attrib['id'] == datacenter_id end else raise Excon::Error::HTTPStatus, 'Data center resource could not be found' end if volume = data[:volumes]['items'].find do |attrib| attrib['id'] == volume_id && attrib['datacenter_id'] == datacenter_id end else raise Excon::Error::HTTPStatus, 'Volume resource could not be found' end response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/start_server.rb000066400000000000000000000026131320736730600274200ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # This will start a server. # If the server's public IP was deallocated, then a new IP will be assigned # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * server_id<~String> - UUID of the virtual server # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#start-a-server] def start_server(datacenter_id, server_id) request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/start" ) end end class Mock def start_server(datacenter_id, server_id) if server = data[:servers]['items'].find do |attrib| attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id end else raise Fog::Errors::NotFound, 'The requested server resource could not be found' end server['vm_state'] = 'RUNNING' server['state'] = 'AVAILABLE' response = Excon::Response.new response.status = 202 response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/stop_server.rb000066400000000000000000000027011320736730600272460ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # This will stop a server. # The machine will be forcefully powered off, billing will cease, # and the public IP, if one is allocated, will be deallocated # # ==== Parameters # * datacenter_id<~String> - UUID of the data center # * server_id<~String> - UUID of the virtual server # # ==== Returns # * response<~Excon::Response> - No response parameters # (HTTP/1.1 202 Accepted) # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#stop-a-server] def stop_server(datacenter_id, server_id) request( :expects => [202], :method => 'POST', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/stop" ) end end class Mock def stop_server(datacenter_id, server_id) if server = data[:servers]['items'].find do |attrib| attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id end else raise Fog::Errors::NotFound, 'The requested server resource could not be found' end server['vm_state'] = 'SHUTOFF' server['state'] = 'INACTIVE' response = Excon::Response.new response.status = 202 response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_datacenter.rb000066400000000000000000000066511320736730600303570ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update an existing virtual data center # # ==== Parameters # * options<~Hash>: # * name<~String> - The new name of the data center # * description<~String> - The optional description of the data center # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the resource's metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Data center state (AVAILABLE, BUSY, INACTIVE) # * properties<~Hash> - A hash containing the resource's properties # * name<~String> - The name of the data center # * description<~String> - The description of the data center # * location<~String> - The location where the data center was provisioned ("de/fkb", "de/fra", or "us/las") # * version<~Integer> - The version of the data center # * features<~Array> - The features of the data center # * entities<~Hash> - A hash containing the datacenter entities # * servers<~Hash> - A collection that represents the servers in a data center # * volumes<~Hash> - A collection that represents volumes in a data center # * loadbalancers<~Hash> - A collection that represents the loadbalancers in a data center # * lans<~Hash> - A collection that represents the LANs in a data center # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-a-data-center] def update_datacenter(datacenter_id, options = {}) request( :expects => [202], :method => 'PATCH', :path => "/datacenters/#{datacenter_id}", :body => Fog::JSON.encode(options) ) end end class Mock def update_datacenter(datacenter_id, options = {}) if dc = data[:datacenters]["items"].find do |datacenter| datacenter["id"] == datacenter_id end dc['properties']['version'] += 1 if dc['properties'] dc['version'] += 1 if dc['version'] dc['properties']['name'] = options[:properties][:name] if dc['properties'] dc['name'] = options[:name] if dc['name'] else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 202 response.body = dc response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb000066400000000000000000000130441320736730600310730ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update a Firewall Rule # # ==== Parameters # * datacenter_id<~String> - Required - UUID of the NIC # * server_id<~String> - Required - UUID of the server # * nic_id<~String> - Required - UUID of the NIC # * firewall_rule_id<~String> - Required - UUID of the NIC # * options<~Hash>: # * name<~String> - The name of the Firewall Rule # * sourceMac<~String> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~String> - Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs # * targetIp<~String> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~String> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes # * icmpType<~String> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types # * portRangeStart<~String> - Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd value null to allow all ports # * portRangeEnd<~String> - Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd null to allow all ports # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * sourceMac<~String> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~String> - Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs # * targetIp<~String> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~String> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes # * icmpType<~String> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types # * portRangeStart<~String> - Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd value null to allow all ports # * portRangeEnd<~String> - Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen. # Leave portRangeStart and portRangeEnd null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-firewall-rule] def update_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id, options = {}) request( :expects => [202], :method => 'PATCH', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}", :body => Fog::JSON.encode(options) ) end end class Mock def update_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id, options = {}) if firewall_rule = data[:firewall_rules]['items'].find do |attribute| attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["nic_id"] == nic_id && attribute["id"] == firewall_rule_id end options.each do |key, value| firewall_rule[key] = value end else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 202 response.body = firewall_rule response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_group.rb000066400000000000000000000111221320736730600273660ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update a group. # Normally a PUT request would require that you pass all the attributes and values. # In this implementation, you must supply the name, even if it isn't being changed. # As a convenience, the other four attributes will default to false. # You should explicitly set them to true if you want to have them enabled. # # ==== Parameters # * group_id<~String> - Required, The ID of the specific group to update. # * options<~Hash>: # * name<~String> - Required, The name of the group. # * createDataCenter<~Integer> - The group will be allowed to create virtual data centers. # * createSnapshot<~Integer> - The group will be allowed to create snapshots. # * reserveIp<~Integer> - The group will be allowed to reserve IP addresses. # * accessActivityLog<~Integer> - The group will be allowed to access the activity log. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * properties<~Hash> - Hash containing the volume properties. # * name<~String> - The name of the group. # * createDataCenter<~Boolean> - The group will be allowed to create virtual data centers. # * createSnapshot<~Boolean> - The group will be allowed to create snapshots. # * reserveIp<~Boolean> - The group will be allowed to reserve IP addresses. # * accessActivityLog<~Boolean> - The group will be allowed to access the activity log. # * entities<~Hash> - A hash containing the group entities. # * users<~Hash> - A collection of users that belong to this group. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # * items<~Array> - The array containing individual user resources. # * resources<~Hash> - A collection of resources that are assigned to this group. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # * items<~Array> - An array containing individual resources. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the requested resource. # * href<~String> - URL to the object’s representation (absolute path). # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#update-a-group] def update_group(group_id, options = {}) group = { :properties => options } request( :expects => [202], :method => 'PUT', :path => "/um/groups/#{group_id}", :body => Fog::JSON.encode(group) ) end end class Mock def update_group(group_id, options = {}) if group = data[:groups]['items'].find do |grp| grp["id"] == group_id end group['name'] = options[:name] group['createDataCenter'] = options[:createDataCenter] if [true, false].include?(options[:createDataCenter]) group['createSnapshot'] = options[:createSnapshot] if [true, false].include?(options[:createSnapshot]) group['reserveIp'] = options[:reserveIp] if [true, false].include?(options[:reserveIp]) group['accessActivityLog'] = options[:accessActivityLog] if [true, false].include?(options[:accessActivityLog]) else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 202 response.body = group response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_image.rb000066400000000000000000000123361320736730600273240ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update an existing image # # ==== Parameters # * image_id<~String> - UUID of the image resource # * options<~Hash>: # * name<~String> - The name of the image # * description<~String> - The description of the image # * licenceType<~String> - The image's licence type: LINUX, WINDOWS, or UNKNOWN # * cpuHotPlug<~String> - This image is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~String> - This image is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~String> - This image is capable of memory hot plug (no reboot required) # * ramHotUnplug<~String> - This image is capable of memory hot unplug (no reboot required) # * nicHotPlug<~String> - This image is capable of nic hot plug (no reboot required) # * nicHotUnplug<~String> - This image is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~String> - This image is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotUnplug<~String> - This image is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~String> - This image is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~String> - This image is capable of Scsi drive hot unplug (no reboot required) # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the image metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the image # * description<~String> - The description of the image # * location<~String> - The image's location # * size<~Integer> - The size of the image in GB # * cpuHotPlug<~Boolean> - This image is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This image is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This image is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This image is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This image is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This image is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This image is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This image is capable of Scsi drive hot unplug (no reboot required) # * licenceType<~String> - The image's licence type: LINUX, WINDOWS, or UNKNOWN # * imageType<~String> - The type of image: HDD, CDROM # * public<~String> - Indicates if the image is part of the public repository or not # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-image] def update_image(image_id, options = {}) request( :expects => [202], :method => 'PATCH', :path => "/images/#{image_id}", :body => Fog::JSON.encode(options) ) end end class Mock def update_image(image_id, options = {}) if img = data[:images]["items"].find do |image| image["id"] == image_id end img['licenceType'] = options[:licenceType] options.each do |key, value| img[key.to_s] = value end else raise Excon::Error::HTTPStatus, "The requested resource could not be found" end response = Excon::Response.new response.status = 202 response.body = img response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_lan.rb000066400000000000000000000207131320736730600270120ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update LAN properties # # ==== Parameters # * datacenter_id<~String> - Required - UUID of the virtual data center # * lan_id<~String> - Required - UUID of the LAN # * properties<~Hash>: # * name<~String> - The name of the LAN # * public<~Integer> - Boolean indicating if the LAN faces the public Internet or not # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual lan objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the LAN metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - LAN state # * properties<~Hash> - Hash containing the LAN properties # * name<~String> - The name of the LAN # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not # * ipFailover<~Array> - Attributes related to IP failover groups # * entities<~Hash> - Hash containing the LAN entities # * nics<~Hash> - Hash containing the NIC properties # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Hash> - Collection of individual nic objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-lan] def update_lan(datacenter_id, lan_id, options = {}) request( :expects => [202], :method => 'PATCH', :path => "/datacenters/#{datacenter_id}/lans/#{lan_id}", :body => Fog::JSON.encode(options) ) end end class Mock def update_lan(datacenter_id, lan_id, options = {}) if lan = data[:lans]['items'].find do |attrib| attrib['datacenter_id'] == datacenter_id && attrib['id'] == lan_id end options.each do |key, value| lan[key] = value end else raise Fog::Errors::NotFound, 'The requested LAN resource could not be found' end response = Excon::Response.new response.status = 202 response.body = lan response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_load_balancer.rb000066400000000000000000000062431320736730600310100ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update a load balancer # # ==== Parameters # * datacenter_id<~String> - Required - UUID of the NIC # * load_balancer_id<~String> - Required - UUID of the load balancer # * options<~Hash>: # * name<~String> - The name of the Load Balancer # * ip<~String> - The IP of the Load Balancer # * dhcp<~Boolean> - Indicates if the loadbalancer will reserve an IP using DHCP # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Load Balancer metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Load Balancer state # * properties<~Hash> - Hash containing the Load Balancer properties # * name<~String> - The name of the Load Balancer # * ip<~String> - Pv4 address of the Load Balancer. All attached NICs will inherit this IP # * dhcp<~Boolean> - Indicates if the Load Balancer will reserve an IP using DHCP # * entities<~Integer> - Hash containing the Load Balancer entities # * balancednics<~Hash> - List of NICs taking part in load-balancing. All balanced nics inherit the IP of the loadbalancer. # See the NIC section for attribute definitions # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-load-balancer] def update_load_balancer(datacenter_id, load_balancer_id, options = {}) request( :expects => [202], :method => 'PATCH', :path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}", :body => Fog::JSON.encode(options) ) end end class Mock def update_load_balancer(datacenter_id, load_balancer_id, options = {}) if load_balancer = data[:load_balancers]['items'].find do |attribute| attribute["datacenter_id"] == datacenter_id && attribute["id"] == load_balancer_id end options.each do |key, value| load_balancer[key] = value end else raise Fog::Errors::NotFound, 'The requested resource could not be found' end response = Excon::Response.new response.status = 202 response.body = load_balancer response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_nic.rb000066400000000000000000000146451320736730600270200ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update a virtual NIC # # ==== Parameters # * datacenter_id<~String> - Required - UUID of the NIC # * server_id<~String> - Required - UUID of the server # * nic_id<~String> - Required - UUID of the NIC # * options<~Hash>: # * name<~String> - The name of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the created resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the NIC metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - Hash containing the NIC properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~Integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value # * entities<~Hash> - Hash containing the NIC entities # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - Collection of individual firewall rules objects # * id<~String> - The resource's unique identifier # * type<~String> - The type of the resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the Firewall Rule metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Firewall Rule state # * properties<~Hash> - Hash containing the Firewall Rule properties # * name<~String> - The name of the Firewall Rule # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed. # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed. # Value null allows all source IPs # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed # to the respective IP address of the NIC is allowed. Value null allows all target IPs # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. # Value null allows all codes. # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. # Value null allows all types # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534) # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd # value null to allow all ports # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534) # if the protocol TCP or UDP is chosen. Leave portRangeStart and # portRangeEnd value null to allow all ports # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-a-nic] def update_nic(datacenter_id, server_id, nic_id, options = {}) request( :expects => [202], :method => 'PATCH', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}", :body => Fog::JSON.encode(options) ) end end class Mock def update_nic(datacenter_id, server_id, nic_id, options = {}) if nic = data[:nics]['items'].find do |attribute| attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["id"] == nic_id end nic['name'] = options[:name] else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 202 response.body = nic response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_server.rb000066400000000000000000000250461320736730600275520ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update the attributes of an existing virtual server # # ==== Parameters # * datacenter_id<~String> - Required - UUID of the virtual data center # * server_id<~String> - Required - UUID of the virtual server # * properties<~Hash>: - A hash containing the server properties # * name<~String> - Required - The hostname of the server # * cores<~Integer> - Required - The total number of cores for the server # * ram<~Integer> - Required - The amount of memory for the server in MB, e.g. 2048. # Size must be specified in multiples of 256 MB with a minimum of 256 MB; # however, if ramHotPlug is set to TRUE then a minimum of 1024 MB nust be used # * availabilityZone<~String> - The availability zone for the server (AUTO, ZONE_1, ZONE_2) # * bootCdrom<~Hash> - Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null' # * bootVolume<~Hash> - Reference to a Volume used for booting. If not 'null’ then bootCdrom has to be 'null’ # * cpuFamily<~String> - Type of CPU assigned ("AMD_OPTERON" or "INTEL_XEON") # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the server metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag # * lastModifiedDate<~String> - The last modified time for the resource # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Status of the virtual Machine # * properties<~Hash> - A hash containing the server properties # * name<~String> - The name of the server # * cores<~Integer> - The number of cores for the server # * ram<~Integer> - The amount of memory on the server (in megabytes) # * availabilityZone<~String> - The availability zone for the server # * vmState<~String> - The current state of the instance # * bootCdrom<~Hash> - Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null'. # * bootVolume<~Hash> - Reference to a Volume used for booting. If not ‘null’ then bootCdrom has to be ‘null’ # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the volume metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the volume. # * type<~String> - The volume type, HDD or SSD. # * size<~Integer> - The size of the volume in GB. # * image<~String> - The image or snapshot ID. # * imagePassword<~String> - Indicates if a password is set on the image. # * sshKeys<~String> - SSH keys # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN) # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * deviceNumber<~Integer> - The LUN ID of the storage volume # * cpuFamily<~String> - Type of CPU assigned # * entities<~Hash> - A hash containing the server entities # * cdroms<~Hash> - A collection of cdroms attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - The array containing individual cd rom resources # * volumes<~Hash> - A collection of volumes attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - The array containing individual volume resources (see bootVolume for detailed structure) # * nics<~Hash> - A collection of NICs attached to the server # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - An array containing individual NIC resources # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the nic metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - NIC state # * properties<~Hash> - A hash containing the nic properties # * name<~String> - The name of the NIC # * mac<~String> - The MAC address of the NIC # * ips<~Array> - IPs assigned to the NIC represented as a collection # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not # * lan<~integer> - The LAN ID the NIC sits on # * firewallActive<~Boolean> - Once you add a firewall rule this will reflect a true value # * entities<~Hash> - A hash containing the nic entities # * firewallrules<~hash> - A list of firewall rules associated to the NIC represented as a collection # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * items<~Array> - An array of individual firewall rules associated to the NIC # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-a-server] def update_server(datacenter_id, server_id, properties = {}) request( :expects => [202], :method => 'PATCH', :path => "/datacenters/#{datacenter_id}/servers/#{server_id}", :body => Fog::JSON.encode(properties) ) end end class Mock def update_server(_datacenter_id, server_id, properties = {}) if server = data[:servers]['items'].find do |attrib| attrib['id'] == server_id end else raise Excon::Error::HTTPStatus, "Resource does not exist" end server['name'] = properties[:name] response = Excon::Response.new response.status = 202 response.body = server response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_share.rb000066400000000000000000000056701320736730600273470ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update a group. # Normally a PUT request would require that you pass all the attributes and values. # In this implementation, you must supply the name, even if it isn't being changed. # As a convenience, the other four attributes will default to false. # You should explicitly set them to true if you want to have them enabled. # # ==== Parameters # * group_id<~String> - Required, The ID of the specific group to update. # * resource_id<~String> - Required, The ID of the specific resource to update. # * properties<~Hash>: - A collection of properties. # * editPrivilege<~Boolean> - The group has permission to edit privileges on this resource. # * sharePrivilege<~Boolean> - The group has permission to share this resource. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - Id of the requested resource # * type<~String> - type of the requested resource # * href<~String> - url to the requested resource # * items<~Array> # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * properties<~Hash> - Hash containing the share properties. # * editPrivilege<~Boolean> - The group has permission to edit privileges on this resource. # * sharePrivilege<~Boolean> - The group has permission to share this resource. # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#update-a-share] def update_share(group_id, resource_id, options = {}) share = { :properties => options } request( :expects => [202], :method => 'PUT', :path => "/um/groups/#{group_id}/shares/#{resource_id}", :body => Fog::JSON.encode(share) ) end end class Mock def update_share(group_id, resource_id, options = {}) if share = data[:shares]['items'].find do |shr| shr["id"] == resource_id end share['editPrivilege'] = options[:editPrivilege] if [true, false].include?(options[:editPrivilege]) share['sharePrivilege'] = options[:sharePrivilege] if [true, false].include?(options[:sharePrivilege]) else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 202 response.body = share response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_snapshot.rb000066400000000000000000000122701320736730600300760ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update an existing snapshot # # ==== Parameters # * snapshot_id<~String> - Required, UUID of the snapshot # * options<~Hash>: # * name<~String> - The name of the snapshot # * description<~String> - The description of the snapshot # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of NIC hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of NIC hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotUnplug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of SCSI drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of SCSI drive hot unplug (no reboot required) # * licencetype<~String> - The snapshot's licence type: LINUX, WINDOWS, or UNKNOWN. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - A hash containing the resource's metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Snapshot state (AVAILABLE, BUSY, INACTIVE) # * properties<~Hash> - A hash containing the resource's properties # * name<~String> - The name of the snapshot # * description<~String> - The description of the snapshot # * location<~String> - The snapshot's location ("de/fkb", "de/fra", or "us/las") # * version<~Integer> - The version of the data center # * size<~Integer> - The size of the snapshot in GB # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * licencetype<~String> - The snapshot's licence type: LINUX, WINDOWS, or UNKNOWN. # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-snapshot] def update_snapshot(snapshot_id, options = {}) request( :expects => [202], :method => 'PATCH', :path => "/snapshots/#{snapshot_id}", :body => Fog::JSON.encode(options) ) end end class Mock def update_snapshot(snapshot_id, options = {}) if snapshot = data[:snapshots]['items'].find do |snpsht| snpsht["id"] == snapshot_id end options.each do |key, value| snapshot[key] = value end else raise Fog::Errors::NotFound, 'The requested resource could not be found' end response = Excon::Response.new response.status = 202 response.body = snapshot response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_user.rb000066400000000000000000000116661320736730600272250ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update details about a specific user including their privileges. # With this PUT operation, you need to supply values for all the attributes, # even if you are only updating some of them. # # The password attribute is immutable. It is not allowed in update requests. # It is recommended that a new user log into the DCD and change their password. # # ==== Parameters # * user_id<~String> - Required, The ID of the specific user to update. # * options<~Hash>: # * firstname<~String> - Required, The name of the group. # * lastname<~String> - Required, The group will be allowed to create virtual data centers. # * email<~String> - Required, The group will be allowed to create snapshots. # * administrator<~Boolean> - Required, The group will be allowed to access the activity log. # * forceSecAuth<~Boolean> - Required, The group will be allowed to access the activity log. # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * metadata<~Hash> - Hash containing metadata for the user. # * etag<~String> - ETag of the user. # * creationDate<~String> - A time and date stamp indicating when the user was created. # * lastLogin<~String> - A time and date stamp indicating when the user last logged in. # * properties<~Hash> - Hash containing the user's properties. # * firstname<~String> - The first name of the user. # * lastname<~String> - The last name of the user. # * email<~String> - The e-mail address of the user. # * administrator<~Boolean> - Indicates if the user has administrative rights. # * forceSecAuth<~Boolean> - Indicates if secure (two-factor) authentication was enabled for the user. # * secAuthActive<~Boolean> - Indicates if secure (two-factor) authentication is enabled for the user. # * entities<~Hash> - Hash containing resources the user owns, and groups the user is a member of. # * owns<~Hash> - Hash containing resources the user owns. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * groups<~Hash> - Hash containing groups the user is a member of. # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # * items<~Array> # * id<~String> - The resource's unique identifier. # * type<~String> - The type of the created resource. # * href<~String> - URL to the object's representation (absolute path). # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v4/#update-a-user] def update_user(user_id, options = {}) user = { :properties => options } request( :expects => [202], :method => 'PUT', :path => "/um/users/#{user_id}", :body => Fog::JSON.encode(user) ) end end class Mock def update_user(user_id, options = {}) if user = data[:users]['items'].find do |usr| usr["id"] == user_id end user['firstname'] = options[:firstname] user['lastname'] = options[:lastname] user['email'] = options[:email] user['administrator'] = options[:administrator] user['forceSecAuth'] = options[:force_sec_auth] || false else raise Excon::Error::HTTPStatus, "Resource does not exist" end response = Excon::Response.new response.status = 202 response.body = user response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/requests/compute/update_volume.rb000066400000000000000000000104261320736730600275470ustar00rootroot00000000000000module Fog module Compute class ProfitBricks class Real # Update a virtual storage # # ==== Parameters # * datacenter_id<~String> - Required, UUID of virtual data center # * volume_id<~String> - Required, UUID of volume # * options<~Hash>: # * name<~String> - The name of the volume # * size<~Integer> - Required, the size of the volume in GB # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: # * id<~String> - The resource's unique identifier # * type<~String> - The type of the requested resource # * href<~String> - URL to the object’s representation (absolute path) # * metadata<~Hash> - Hash containing the volume metadata # * createdDate<~String> - The date the resource was created # * createdBy<~String> - The user who created the resource # * etag<~String> - The etag for the resource # * lastModifiedDate<~String> - The last time the resource has been modified # * lastModifiedBy<~String> - The user who last modified the resource # * state<~String> - Volume state # * properties<~Hash> - Hash containing the volume properties # * name<~String> - The name of the volume. # * type<~String> - The volume type, HDD or SSD. # * size<~Integer> - The size of the volume in GB. # * image<~String> - The image or snapshot ID. # * imagePassword<~String> - Indicates if a password is set on the image. # * sshKeys<~String> - SSH keys # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO. # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN) # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required) # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required) # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required) # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required) # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required) # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required) # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required) # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required) # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required) # * deviceNumber<~Integer> - The LUN ID of the volume volume # # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-volume] def update_volume(datacenter_id, volume_id, options = {}) request( :expects => [202], :method => 'PATCH', :path => "/datacenters/#{datacenter_id}/volumes/#{volume_id}", :body => Fog::JSON.encode(options) ) end end class Mock def update_volume(datacenter_id, volume_id, options = {}) if volume = data[:volumes]['items'].find do |vlm| vlm["id"] == volume_id && vlm["datacenter_id"] == datacenter_id end volume['name'] = options[:name] volume['size'] = options[:size] else raise Excon::Error::HTTPStatus, 'The requested resource could not be found' end response = Excon::Response.new response.status = 202 response.body = volume response end end end end end fog-profitbricks-4.1.0/lib/fog/profitbricks/version.rb000066400000000000000000000001101320736730600230210ustar00rootroot00000000000000module Fog module ProfitBricks VERSION = "4.1.0".freeze end end fog-profitbricks-4.1.0/spec/000077500000000000000000000000001320736730600157275ustar00rootroot00000000000000fog-profitbricks-4.1.0/spec/minitest_helper.rb000066400000000000000000000015041320736730600214470ustar00rootroot00000000000000require 'minitest/spec' require 'minitest/autorun' require 'turn' Turn.config do |c| # use one of output formats: # :outline - turn's original case/test outline mode [default] # :progress - indicates progress with progress bar # :dotted - test/unit's traditional dot-progress mode # :pretty - new pretty reporter # :marshal - dump output as YAML (normal run mode only) # :cue - interactive testing # c.format = :outline # turn on invoke/execute tracing, enable full backtrace c.trace = 20 # use humanized test names (works only with :outline format) c.natural = true end if ENV['COVERAGE'] require 'coveralls' require 'simplecov' SimpleCov.start do add_filter '/spec/' end end require File.join(File.dirname(__FILE__), '../lib/fog/profitbricks') Coveralls.wear! if ENV['COVERAGE'] fog-profitbricks-4.1.0/tests/000077500000000000000000000000001320736730600161375ustar00rootroot00000000000000fog-profitbricks-4.1.0/tests/helper.rb000066400000000000000000000011641320736730600177450ustar00rootroot00000000000000ENV['FOG_RC'] = ENV['FOG_RC'] || File.expand_path('~/.fog', __FILE__) ENV['FOG_CREDENTIAL'] = ENV['FOG_CREDENTIAL'] || 'default' ## From fog-core require 'fog/test_helpers/formats_helper' require 'fog/test_helpers/succeeds_helper' require 'fog/profitbricks' Excon.defaults.merge!(:debug_request => true, :debug_response => true) # This overrides the default 600 seconds timeout during live test runs if Fog.mocking? FOG_TESTING_TIMEOUT = ENV['FOG_TEST_TIMEOUT'] || 2000 Fog.timeout = 2000 Fog::Logger.warning "Setting default fog timeout to #{Fog.timeout} seconds" else FOG_TESTING_TIMEOUT = Fog.timeout end fog-profitbricks-4.1.0/tests/helpers/000077500000000000000000000000001320736730600176015ustar00rootroot00000000000000fog-profitbricks-4.1.0/tests/helpers/formats_helper.rb000066400000000000000000000020331320736730600231360ustar00rootroot00000000000000# format related hackery # allows both true.is_a?(Fog::Boolean) and false.is_a?(Fog::Boolean) # allows both nil.is_a?(Fog::Nullable::String) and ''.is_a?(Fog::Nullable::String) module Fog module Boolean; end module Nullable module Boolean; end module Integer; end module String; end module Time; end module Float; end module Hash; end module Array; end end end [FalseClass, TrueClass].each { |klass| klass.send(:include, Fog::Boolean) } [FalseClass, TrueClass, NilClass, Fog::Boolean].each { |klass| klass.send(:include, Fog::Nullable::Boolean) } [NilClass, String].each { |klass| klass.send(:include, Fog::Nullable::String) } [NilClass, Time].each { |klass| klass.send(:include, Fog::Nullable::Time) } [Integer, NilClass].each { |klass| klass.send(:include, Fog::Nullable::Integer) } [Float, NilClass].each { |klass| klass.send(:include, Fog::Nullable::Float) } [Hash, NilClass].each { |klass| klass.send(:include, Fog::Nullable::Hash) } [Array, NilClass].each { |klass| klass.send(:include, Fog::Nullable::Array) } fog-profitbricks-4.1.0/tests/helpers/mock_helper.rb000066400000000000000000000002761320736730600224230ustar00rootroot00000000000000Fog.mock! if ENV["FOG_MOCK"] == "true" if Fog.mock? Fog.credentials = { :profitbricks_username => "username", :profitbricks_password => "abc123xyz" }.merge(Fog.credentials) end fog-profitbricks-4.1.0/tests/profitbricks/000077500000000000000000000000001320736730600206405ustar00rootroot00000000000000fog-profitbricks-4.1.0/tests/profitbricks/models/000077500000000000000000000000001320736730600221235ustar00rootroot00000000000000fog-profitbricks-4.1.0/tests/profitbricks/models/compute/000077500000000000000000000000001320736730600235775ustar00rootroot00000000000000fog-profitbricks-4.1.0/tests/profitbricks/models/compute/compute_tests.rb000066400000000000000000001201121320736730600270170ustar00rootroot00000000000000Shindo.tests('Fog::Compute[:profitbricks] | compute models', %w(profitbricks compute)) do compute = Fog::Compute.new(:provider => 'ProfitBricks', :profitbricks_username => ENV['PROFITBRICKS_USERNAME'], :profitbricks_password => ENV['PROFITBRICKS_PASSWORD']) tests('success') do Excon.defaults[:connection_timeout] = 500 tests('List Contract Resources').succeeds do contract_resources = compute.contract_resources.all contract_resources.count > 0 && contract_resources[0].contract_number !~ /\D/ end tests('List Requests').succeeds do requests = compute.requests.all @request_id = requests[0].id requests.count > 0 && requests[0].type == 'request' end tests('Get Request').succeeds do request = compute.requests.get(@request_id) request.id == @request_id && request.type == 'request' end tests('Get Request Status').succeeds do request_status = compute.requests.get_status(@request_id) request_status.id == "#{@request_id}/status" && request_status.type == 'request-status' end tests('List Locations').succeeds do locations = compute.locations.all locations.count > 0 && locations[0].type == 'location' && locations.find {|item| item.id == 'us/las'} != nil end tests('Get Location').succeeds do location = compute.locations.get('us/las') location.id == 'us/las' && location.type == 'location' end tests('Create Datacenter Simple').succeeds do datacenter = compute.datacenters.create(:name => 'Fog Test', :location => 'us/las', :description => 'Fog test datacenter') datacenter.wait_for {ready?} @datacenter_id = datacenter.id datacenter.type == 'datacenter' && datacenter.name == 'Fog Test' && datacenter.location == 'us/las' && datacenter.description == 'Fog test datacenter' end tests('Create Datacenter Composite').succeeds do servers = [ { name: 'Fog Test', ram: 1024, cores: 1 } ] volumes = [ { name: 'Fog Test', size: 2, bus: 'VIRTIO', type: 'HDD', licenceType: 'UNKNOWN', availabilityZone: 'ZONE_3' } ] datacenter = compute.datacenters.create(:name => 'Fog Test Composite', :location => 'us/las', :description => 'Fog test composite datacenter', :servers => servers, :volumes => volumes) datacenter.wait_for {ready?} @composite_dc_id = datacenter.id datacenter.type == 'datacenter' && datacenter.name == 'Fog Test Composite' && datacenter.location == 'us/las' && datacenter.description == 'Fog test composite datacenter' && datacenter.servers.count > 0 && datacenter.volumes.count > 0 end tests('List Datacenters').succeeds do datacenters = compute.datacenters.all datacenters.count > 0 && datacenters[0].type == 'datacenter' end tests('Get Datacenter').succeeds do datacenter = compute.datacenters.get(@datacenter_id) datacenter.id == @datacenter_id && datacenter.type == 'datacenter' && datacenter.name == 'Fog Test' && datacenter.location == 'us/las' && datacenter.description == 'Fog test datacenter' end tests('Update Datacenter').succeeds do datacenter = compute.datacenters.get(@datacenter_id) datacenter.name = datacenter.name + ' - RENAMED' datacenter.update datacenter.wait_for {ready?} datacenter.reload datacenter.name == 'Fog Test - RENAMED' && datacenter.version > 1 end tests('Create LAN').succeeds do lan = compute.lans.create(:datacenter_id => @datacenter_id, :name => 'Fog Test', :public => true) @lan_id = lan.id sleep(120) if ENV["FOG_MOCK"] != "true" lan.name == 'Fog Test' && lan.public end tests('List LANs').succeeds do lans = compute.lans.all(@datacenter_id) lans.count > 0 && lans[0].type == 'lan' end tests('Get LAN').succeeds do lan = compute.lans.get(@datacenter_id, @lan_id) lan.id == @lan_id && lan.type == 'lan' && lan.name == 'Fog Test' && lan.public end tests('Update LAN').succeeds do lan = compute.lans.get(@datacenter_id, @lan_id) lan.name = lan.name + ' - RENAME' lan.public = false lan.update lan.id == @lan_id && lan.type == 'lan' && lan.name == 'Fog Test - RENAME' end tests('List Images').succeeds do images = compute.images.all images.count > 0 images[0].type == 'image' image = images.find do |img| img.image_type == 'HDD' && img.licence_type == 'LINUX' && img.location == 'us/las' end @image_id = image.id end tests('Get Image').succeeds do image = compute.images.get(@image_id) image.id == @image_id && image.type == 'image' && !image.name.empty? && image.description.to_s.empty? && !image.location.to_s.empty? && image.size > 0 && ['true', 'false', true, false].include?(image.cpu_hot_plug) && ['true', 'false', true, false].include?(image.cpu_hot_unplug) && ['true', 'false', true, false].include?(image.ram_hot_plug) && ['true', 'false', true, false].include?(image.ram_hot_unplug) && ['true', 'false', true, false].include?(image.nic_hot_plug) && ['true', 'false', true, false].include?(image.nic_hot_unplug) && ['true', 'false', true, false].include?(image.disc_virtio_hot_plug) && ['true', 'false', true, false].include?(image.disc_virtio_hot_unplug) && ['true', 'false', true, false].include?(image.disc_scsi_hot_plug) && ['true', 'false', true, false].include?(image.disc_scsi_hot_unplug) && ['true', 'false', true, false].include?(image.public) && !image.licence_type.to_s.empty? && !image.image_type.to_s.empty? end tests('Create Volume').succeeds do volume = compute.volumes.create(:datacenter_id => @datacenter_id, :name => 'Fog Test', :size => 2, :bus => 'VIRTIO', :type => 'HDD', :availability_zone => 'ZONE_3', :image => @image_id, :ssh_keys => ['ssh-rsa AAAAB3NzaC1']) volume.wait_for {ready?} @volume_id = volume.id volume.name == 'Fog Test' && volume.size == 2 && volume.bus == 'VIRTIO' && volume.type == 'HDD' && volume.availability_zone == 'ZONE_3' && volume.image == @image_id && volume.ssh_keys.kind_of?(Array) end tests('List Volumes').succeeds do volumes = compute.volumes.all(@datacenter_id) volumes.count > 0 && volumes[0].type == 'HDD' end tests('Get Volume').succeeds do volume = compute.volumes.get(@datacenter_id, @volume_id) volume.id == @volume_id && volume.name == 'Fog Test' && volume.size == 2 && volume.type == 'HDD' && volume.availability_zone == 'ZONE_3' && volume.image == @image_id end tests('Update Volume').succeeds do volume = compute.volumes.get(@datacenter_id, @volume_id) volume.size = 5 volume.name = volume.name + ' - RENAME' volume.update volume.wait_for {ready?} volume.reload volume.id == @volume_id && volume.name == 'Fog Test - RENAME' && volume.size == 5 end tests('Create Snapshot').succeeds do volume = compute.volumes.get(@datacenter_id, @volume_id) volume.create_snapshot('Fog Test', 'Fog test snapshot') == true volume.reload end tests('List Snapshots').succeeds do sleep(30) if ENV["FOG_MOCK"] != "true" snapshots = compute.snapshots.all snapshot = snapshots.find do |snp| snp.name == 'Fog Test' end @snapshot_id = snapshot.id snapshots.count > 0 && snapshots[0].type == 'snapshot' end tests('Get Snapshot').succeeds do volume = compute.volumes.get(@datacenter_id, @volume_id) snapshot = compute.snapshots.get(@snapshot_id) snapshot.id == @snapshot_id && snapshot.name == 'Fog Test' && snapshot.description.include?('Fog') && snapshot.type == 'snapshot' && snapshot.location == 'us/las' && snapshot.size == volume.size && snapshot.cpu_hot_plug == volume.cpu_hot_plug && snapshot.cpu_hot_unplug == volume.cpu_hot_unplug && snapshot.ram_hot_plug == volume.ram_hot_plug && snapshot.ram_hot_unplug == volume.ram_hot_unplug && snapshot.nic_hot_plug == volume.nic_hot_plug && snapshot.nic_hot_unplug == volume.nic_hot_unplug && snapshot.disc_virtio_hot_plug == volume.disc_virtio_hot_plug && snapshot.disc_virtio_hot_unplug == volume.disc_virtio_hot_unplug && snapshot.disc_scsi_hot_plug == volume.disc_scsi_hot_plug && snapshot.disc_scsi_hot_unplug == volume.disc_scsi_hot_unplug && snapshot.licence_type == volume.licence_type end tests('Restore Snapshot').succeeds do volume = compute.volumes.get(@datacenter_id, @volume_id) volume.restore_snapshot(@snapshot_id) end tests('Update Snapshot').succeeds do snapshot = compute.snapshots.get(@snapshot_id) snapshot.name = snapshot.name + ' - RENAME' snapshot.description = snapshot.description + ' - RENAME' snapshot.update sleep(30) if ENV["FOG_MOCK"] != "true" snapshot = compute.snapshots.get(@snapshot_id) snapshot.name == 'Fog Test - RENAME' && snapshot.description.include?('Fog') && snapshot.description.include?('- RENAME') end tests('Create Server').succeeds do server = compute.servers.create(:datacenter_id => @datacenter_id, :name => 'Fog Test', :ram => 1024, :cores => 1, :availability_zone => 'ZONE_1', :cpu_family => 'INTEL_XEON') server.wait_for {ready?} @server_id = server.id server.type == 'server' && server.name == 'Fog Test' && server.ram == 1024 && server.cores == 1 && server.availability_zone == 'ZONE_1' && server.cpu_family == 'INTEL_XEON' end tests('Create Server Composite').succeeds do volumes = [ { name: 'Fog Test', size: 2, bus: 'VIRTIO', type: 'HDD', licence_type: 'UNKNOWN', availability_zone: 'ZONE_3' } ] nics = [ { name: 'Fog Test', dhcp: 'true', lan: 1, firewallActive: true, nat: false, firewallrules: [ { name: 'SSH', protocol: 'TCP', sourceMac: '01:23:45:67:89:00', portRangeStart: 22, portRangeEnd: 22 } ] } ] server = compute.servers.create(:datacenter_id => @datacenter_id, :name => 'Fog Test Composite', :ram => 1024, :cores => 1, :volumes => volumes, :nics => nics) server.wait_for {ready?} @composite_server_id = server.id server.type == 'server' && server.name == 'Fog Test Composite' && server.ram == 1024 && server.cores == 1 && server.nics.count > 0 && server.volumes.count > 0 end tests('List Servers').succeeds do servers = compute.servers.all(@datacenter_id) servers.count > 0 && servers[0].type == 'server' end tests('Get Server').succeeds do server = compute.servers.get(@datacenter_id, @server_id) server.id == @server_id && server.type == 'server' && server.name == 'Fog Test' && server.cores == 1 && server.ram == 1024 && server.availability_zone == 'ZONE_1' && server.cpu_family == 'INTEL_XEON' end tests('Update Server').succeeds do server = compute.servers.get(@datacenter_id, @server_id) server.name = server.name + ' RENAME' server.update server.wait_for {ready?} server.id == @server_id && server.name == 'Fog Test RENAME' end tests('Attach Volume').succeeds do volume = compute.attach_volume(@datacenter_id, @server_id, @volume_id) sleep(60) if ENV["FOG_MOCK"] != "true" volume.body['id'] == @volume_id && volume.body['properties']['name'] == 'Fog Test - RENAME' && volume.body['properties']['size'] == 5 && volume.body['properties']['type'] == 'HDD' && volume.body['properties']['licenceType'] == 'LINUX' end tests('List Attached Volumes').succeeds do server = compute.servers.get(@datacenter_id, @server_id) volumes = server.list_volumes volumes['items'].count > 0 end tests('Get Attached Volume').succeeds do server = compute.servers.get(@datacenter_id, @server_id) volume = server.get_attached_volume(@volume_id) volume['name'] == 'Fog Test - RENAME' && volume['size'] == 5 && volume['bus'] == 'VIRTIO' && volume['type'] == 'HDD' end tests('Detach Volume').succeeds do server = compute.servers.get(@datacenter_id, @server_id) server.detach_volume(@volume_id) end tests('Attach CDROM').succeeds do images = compute.images.all cd_image = images.find do |img| img.image_type == 'CDROM' && img.licence_type == 'LINUX' end @cd_image_id = cd_image.id server = compute.servers.get(@datacenter_id, @server_id) sleep(30) if ENV["FOG_MOCK"] != "true" cdrom = server.attach_cdrom(@cd_image_id) sleep(120) if ENV["FOG_MOCK"] != "true" @cdrom_id = cdrom['id'] cdrom['id'] == @cd_image_id && !cdrom['name'].to_s.empty? end tests('List Attached CDROMs').succeeds do server = compute.servers.get(@datacenter_id, @server_id) server.list_cdroms.count > 0 end if ENV["FOG_MOCK"] == "true" tests('Get Attached CDROM').succeeds do server = compute.servers.get(@datacenter_id, @server_id) cdrom = server.get_attached_cdrom(@cdrom_id) cdrom['id'] == @cdrom_id && !cdrom['name'].empty? end end tests('Detach CDROM').succeeds do server = compute.servers.get(@datacenter_id, @server_id) if !server.list_cdroms['items'].empty? server.detach_cdrom(@image_id) else server.list_cdroms end end tests('Stop Server').succeeds do server = compute.servers.get(@datacenter_id, @server_id) server.stop end tests('Start Server').succeeds do server = compute.servers.get(@datacenter_id, @server_id) server.stop end tests('Reset Server').succeeds do server = compute.servers.get(@datacenter_id, @server_id) server.reboot end tests('Reserve IP Block').succeeds do ip_block = compute.ip_blocks.create(:location => 'us/las', :size => 2, :name => 'Fog Test') sleep(60) if ENV["FOG_MOCK"] != "true" @ip_block_id = ip_block.id ip_block.name == 'Fog Test' && ip_block.size == 2 && ip_block.location == 'us/las' end tests('List IP Blocks').succeeds do ip_blocks = compute.ip_blocks.all ip_blocks.count > 0 && ip_blocks[0].type == 'ipblock' end tests('Get IP Block').succeeds do ip_block = compute.ip_blocks.get(@ip_block_id) ip_block.id == @ip_block_id && ip_block.type == 'ipblock' && ip_block.name == 'Fog Test' && ip_block.size == 2 && ip_block.location == 'us/las' && ip_block.ips.count == 2 end tests('Create NIC').succeeds do sleep(60) if ENV["FOG_MOCK"] != "true" nic = compute.nics.create(:datacenter_id => @datacenter_id, :server_id => @composite_server_id, :lan => @lan_id, :name => 'Fog Test', :dhcp => true, :firewall_active => true, :ips => ['10.0.0.1'], :nat => false) nic.type == 'nic' && nic.name == 'Fog Test' && nic.lan.to_s == @lan_id.to_s && nic.firewall_active && nic.ips.is_a?(Array) end tests('List NICs').succeeds do nics = compute.nics.all(@datacenter_id, @composite_server_id) @nic_id = nics[0].id nics.count > 0 && nics[0].type == 'nic' end tests('Get NIC').succeeds do nic = compute.nics.get(@datacenter_id, @composite_server_id, @nic_id) nic.id == @nic_id && nic.type == 'nic' && nic.name == 'Fog Test' && nic.dhcp && nic.lan.to_s == @lan_id.to_s && nic.ips.is_a?(Array) end tests('Update NIC').succeeds do nic = compute.nics.get(@datacenter_id, @composite_server_id, @nic_id) nic.name = nic.name + ' - RENAME' nic.update nic.name == 'Fog Test - RENAME' end tests('Create Firewall Rule').succeeds do firewall_rule = compute.firewall_rules.create(:datacenter_id => @datacenter_id, :server_id => @composite_server_id, :nic_id => @nic_id, :name => 'SSH', :protocol => 'TCP', :source_mac => '01:23:45:67:89:00', :port_range_start => '22', :port_range_end => '22') sleep(60) if ENV["FOG_MOCK"] != "true" @firewall_rule_id = firewall_rule.id firewall_rule.type == 'firewall-rule' && firewall_rule.name == 'SSH' && firewall_rule.protocol == 'TCP' && firewall_rule.source_mac == '01:23:45:67:89:00' && firewall_rule.source_ip.nil? && firewall_rule.target_ip.nil? && firewall_rule.port_range_start.to_s == '22' && firewall_rule.port_range_end.to_s == '22' && firewall_rule.icmp_type.nil? && firewall_rule.icmp_code.nil? end tests('List Firewall Rules').succeeds do firewall_rules = compute.firewall_rules.all(@datacenter_id, @composite_server_id, @nic_id) firewall_rules.count > 0 && firewall_rules[0].type == 'firewall-rule' end tests('Get Firewall Rule').succeeds do firewall_rule = compute.firewall_rules.get(@datacenter_id, @composite_server_id, @nic_id, @firewall_rule_id) firewall_rule.id == @firewall_rule_id && firewall_rule.type == 'firewall-rule' && firewall_rule.name == 'SSH' && firewall_rule.protocol == 'TCP' && firewall_rule.source_mac == '01:23:45:67:89:00' && firewall_rule.source_ip.nil? && firewall_rule.target_ip.nil? && firewall_rule.port_range_start.to_s == '22' && firewall_rule.port_range_end.to_s == '22' && firewall_rule.icmp_type.nil? && firewall_rule.icmp_code.nil? end tests('Create Load Balancer').succeeds do load_balancer = compute.load_balancers.create(:datacenter_id => @datacenter_id, :name => 'Fog Test', :dhcp => true) sleep(60) if ENV["FOG_MOCK"] != "true" @load_balancer_id = load_balancer.id load_balancer.type == 'loadbalancer' && load_balancer.name == 'Fog Test' && load_balancer.dhcp end tests('List Load Balancers').succeeds do load_balancers = compute.load_balancers.all(@datacenter_id) load_balancers.count > 0 && load_balancers[0].type == 'loadbalancer' end tests('Get Load Balancer').succeeds do load_balancer = compute.load_balancers.get(@datacenter_id, @load_balancer_id) load_balancer.id == @load_balancer_id && load_balancer.type == 'loadbalancer' && load_balancer.name == 'Fog Test' && load_balancer.dhcp == true end tests('Update Load Balancer').succeeds do load_balancer = compute.load_balancers.get(@datacenter_id, @load_balancer_id) load_balancer.name = load_balancer.name + ' - RENAME' load_balancer.update sleep(60) if ENV["FOG_MOCK"] != "true" load_balancer.id == @load_balancer_id && load_balancer.type == 'loadbalancer' && load_balancer.name == 'Fog Test - RENAME' end tests('Associate Balanced NIC').succeeds do load_balancer = compute.load_balancers.get(@datacenter_id, @load_balancer_id) nic = load_balancer.associate_nic(@nic_id) sleep(60) if ENV["FOG_MOCK"] != "true" nic['id'] == @nic_id && nic['name'] == 'Fog Test - RENAME' end tests('List Balanced NICs').succeeds do load_balancer = compute.load_balancers.get(@datacenter_id, @load_balancer_id) balanced_nics = load_balancer.list_nics balanced_nics.count > 0 && balanced_nics[0]['type'] == 'nic' end tests('Get Balanced NIC').succeeds do load_balancer = compute.load_balancers.get(@datacenter_id, @load_balancer_id) balanced_nic = load_balancer.get_nic(@nic_id) balanced_nic['id'].to_s == @nic_id.to_s && balanced_nic['type'] == 'nic' && balanced_nic['name'] == 'Fog Test - RENAME' && ((balanced_nic['mac'] =~ /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/) == 0) && balanced_nic['ips'].count > 0 && ['true', 'false', true, false].include?(balanced_nic['nat']) end tests('List Resources').succeeds do resources = compute.resources.all datacenter = resources.find do |r| r.type == 'datacenter' end image = resources.find do |r| r.type == 'image' end snapshot = resources.find do |r| r.type == 'snapshot' end ipblock = resources.find do |r| r.type == 'ipblock' end @dc_id = datacenter.id @img_id = image.id @snp_id = snapshot.id @ipb_id = ipblock.id resources.count > 0 end tests('List Datacenter Resources').succeeds do resources = compute.resources.get_by_type('datacenter') resources.count > 0 && resources[0].type == 'datacenter' end tests('List Image Resources').succeeds do resources = compute.resources.get_by_type('image') resources.count > 0 && resources[0].type == 'image' end tests('List Snapshot Resources').succeeds do resources = compute.resources.get_by_type('snapshot') resources.count > 0 && resources[0].type == 'snapshot' end tests('List IP Block Resources').succeeds do resources = compute.resources.get_by_type('ipblock') resources.count > 0 && resources[0].type == 'ipblock' end tests('Get Datacenter Resource').succeeds do resource = compute.resources.get_resource_by_type('datacenter', @dc_id) resource.id == @dc_id && resource.type == 'datacenter' end tests('Get Image Resource').succeeds do resource = compute.resources.get_resource_by_type('image', @img_id) resource.id == @img_id && resource.type == 'image' end tests('Get Snapshot Resource').succeeds do resource = compute.resources.get_resource_by_type('snapshot', @snp_id) resource.id == @snp_id && resource.type == 'snapshot' end tests('Get IP Block Resource').succeeds do resource = compute.resources.get_resource_by_type('ipblock', @ipb_id) resource.id == @ipb_id && resource.type == 'ipblock' end end tests('user management success') do Excon.defaults[:connection_timeout] = 500 tests('Create Group').succeeds do group = compute.groups.create(:name => 'Fog Test', :create_datacenter => true, :create_snapshot => true, :reserve_ip => true, :access_activity_log => true) group.wait_for {ready?} @group_id = group.id group.type == 'group' && group.name == 'Fog Test' && group.create_datacenter == true && group.create_snapshot == true && group.reserve_ip == true && group.access_activity_log == true end tests('List Groups').succeeds do groups = compute.groups.all groups.count > 0 && groups[0].type = 'group' end tests('Get Group').succeeds do group = compute.groups.get(@group_id) group.id == @group_id && group.type == 'group' && group.name == 'Fog Test' && group.create_datacenter == true && group.create_snapshot == true && group.reserve_ip == true && group.access_activity_log == true end tests('Update Group').succeeds do group = compute.groups.get(@group_id) group.name = group.name + ' - RENAME' group.create_datacenter = false group.update group.wait_for {ready?} group.reload group.id == @group_id && group.type == 'group' && group.name == 'Fog Test - RENAME' && group.create_datacenter == false end tests('Create Share').succeeds do share = compute.shares.create(:group_id => @group_id, :resource_id => @image_id, :edit_privilege => true, :share_privilege => true) @share_id = share.id share.type == 'resource' && share.edit_privilege == true && share.share_privilege == true end tests('List Shares').succeeds do shares = compute.shares.all(@group_id) shares.count > 0 && shares[0].type = 'resource' end tests('Get Share').succeeds do share = compute.shares.get(@group_id, @image_id) share.id == @image_id && share.type == 'resource' && share.edit_privilege == true && share.share_privilege == true end tests('Update Share').succeeds do share = compute.shares.get(@group_id, @image_id) share.edit_privilege = false share.update share.id == @image_id && share.type == 'resource' && share.edit_privilege == false end tests('Create User').succeeds do user = compute.users.create(:firstname => 'John', :lastname => 'Doe', :email => 'no-reply@example.com', :password => 'secretpassword123', :administrator => true, :force_sec_auth => false) user.wait_for {ready?} @user_id = user.id user.type == 'user' && user.firstname == 'John' && user.lastname == 'Doe' && user.email == 'no-reply@example.com' && user.administrator == true && user.force_sec_auth == false end tests('List Users').succeeds do users = compute.users.all users.count > 0 && users[0].type = 'user' end tests('Get User').succeeds do user = compute.users.get(@user_id) user.id == @user_id && user.type == 'user' && user.firstname == 'John' && user.lastname == 'Doe' && user.email == 'no-reply@example.com' && user.administrator == true && user.force_sec_auth == false && user.sec_auth_active == false end tests('Update User').succeeds do user = compute.users.get(@user_id) user.administrator = false user.update user.id == @user_id && user.type == 'user' && user.administrator == false && user.firstname == 'John' && user.lastname == 'Doe' && user.email == 'no-reply@example.com' && user.force_sec_auth == false end tests('Add User to Group').succeeds do user = compute.users.add_group_user(@group_id, @user_id) user.id == @user_id && user.type == 'user' end tests('Remove User from Group').succeeds do compute.users.remove_group_user(@group_id, @user_id) end end tests('user management failure') do tests('Create Group Failure (Missing Required Parameter)') do begin options = { create_datacenter: true } compute.create_group(options) rescue Exception => e returns(true, "exception contains 'Attribute 'name' is required'") { e.message.include? "Attribute 'name' is required" } end end tests('Get Group Failure (Nonexistent)') do begin compute.get_group('00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, 'exception contains \'Resource does not exist\'') { e.message.include? 'Resource does not exist' } end end tests('Get share Failure (Nonexistent)') do begin compute.get_share(@group_id, '00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, 'exception contains \'Resource does not exist\'') { e.message.include? 'Resource does not exist' } end end tests('Create User Failure (Missing Required Parameter)') do begin options = { firstname: 'John', lastname: 'Doe' } compute.create_user(options) rescue Exception => e returns(true, "exception contains 'Attribute 'email' is required'") { e.message.include? "Attribute 'email' is required" } end end tests('Get User Failure (Nonexistent)') do begin compute.get_user('00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, 'exception contains \'Resource does not exist\'') { e.message.include? 'Resource does not exist' } end end end tests('failure') do tests('Get Location Failure (Nonexistent)') do begin compute.get_location('00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, 'exception contains \'Resource does not exist\'') { e.message.include? 'Resource does not exist' } end end tests('Create Datacenter Failure (Missing Required Parameter)') do options = { name: 'Fog Datacenter' } begin compute.create_datacenter(options) rescue Exception => e returns(true, "exception contains 'Attribute 'location' is required'") { e.message.include? "Attribute 'location' is required" } end end tests('Get Datacenter Failure (Nonexistent)') do begin compute.get_datacenter('00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, "exception contains 'Resource does not exist'") { e.message.include? 'Resource does not exist' } end end tests('Get LAN Failure (Nonexistent)') do begin compute.get_lan('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, "exception contains 'Resource does not exist'") { e.message.include? 'Resource does not exist' } end end tests('Get Image Failure (Nonexistent)') do begin compute.get_image('00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, "exception contains 'Resource does not exist'") { e.message.include? 'Resource does not exist' } end end tests('Create Volume Failure (Missing Required Parameter)') do options = { name: 'Fog Test' } begin compute.create_volume(@datacenter_id, options) rescue Exception => e returns(true, "exception contains 'Attribute 'size' is required'") { e.message.include? "Attribute 'size' is required" } end end tests('Create Server Failure (Missing Required Parameter)') do options = { name: 'Fog Test', ram: 1024 } begin compute.create_server(@datacenter_id, options) rescue Exception => e returns(true, "exception contains 'Attribute 'cores' is required'") { e.message.include? "Attribute 'cores' is required" } end end tests('Get Server Failure (Nonexistent)') do begin compute.get_server('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, "exception contains 'Resource does not exist'") { e.message.include? 'Resource does not exist' } end end tests('Get Volume Failure (Nonexistent)') do begin compute.get_volume('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, "exception contains 'Resource does not exist'") { e.message.include? 'Resource does not exist' } end end tests('Get Snapshot Failure (Nonexistent)') do begin compute.get_snapshot('00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, "exception contains 'Resource does not exist'") { e.message.include? 'Resource does not exist' } end end tests('Get Request Failure (Nonexistent)') do begin compute.get_request('00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, "exception contains 'Resource does not exist'") { e.message.include? 'Resource does not exist' } end end tests('Get IP Block Failure (Nonexistent)') do begin compute.get_ip_block('00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, 'exception contains \'Resource does not exist\'') { e.message.include? 'Resource does not exist' } end end tests('Create NIC Failure (Missing Required Parameter)') do begin compute.nics.create(:datacenter_id => @datacenter_id, :server_id => @server_id, :name => 'Fog Test') rescue Exception => e returns(true, "exception contains 'lan is required for this operation'") { e.message.include? "lan is required for this operation" } end end tests('Get NIC Failure (Nonexistent)') do begin compute.get_nic('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, 'exception contains \'Resource does not exist\'') { e.message.include? 'Resource does not exist' } end end tests('Create Firewall Rule Failure (Missing Required Parameter)') do begin compute.firewall_rules.create(:datacenter_id => @datacenter_id, :server_id => @server_id, :nic_id => @nic_id, :name => 'Fog Test') rescue Exception => e returns(true, "exception contains 'protocol is required for this operation'") { e.message.include? "protocol is required for this operation" } end end tests('Get Firewall Rule Failure (Nonexistent)') do begin compute.get_firewall_rule('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, 'exception contains \'Resource does not exist\'') { e.message.include? 'Resource does not exist' } end end tests('Create Load Balancer Failure (Missing Required Parameter)') do begin compute.create_load_balancer(@datacenter_id) rescue Exception => e returns(true, "exception contains 'Attribute 'name' is required'") { e.message.include? "Attribute 'name' is required" } end end tests('Get Load Balancer Failure (Nonexistent)') do begin compute.get_load_balancer(@datacenter_id, '00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, 'exception contains \'Resource does not exist\'') { e.message.include? 'Resource does not exist' } end end tests('List Resources Failure (Nonexistent)') do begin compute.resources.get_by_type('unknown') rescue Exception => e returns(true, 'exception contains \'Resource does not exist\'') { e.message.include? 'Resource does not exist' } end end tests('List Resources Type Failure (Nonexistent)') do begin compute.resources.get_resource_by_type('datacenter', '00000000-0000-0000-0000-000000000000') rescue Exception => e returns(true, 'exception contains \'Resource does not exist\'') { e.message.include? 'Resource does not exist' } end end end tests('user management cleanup') do Excon.defaults[:connection_timeout] = 500 tests('Remove User').succeeds do user = compute.users.get(@user_id) user.delete end tests('Remove Share').succeeds do share = compute.shares.get(@group_id, @image_id) share.delete end tests('Remove Group').succeeds do group = compute.groups.get(@group_id) group.delete end end tests('cleanup') do Excon.defaults[:connection_timeout] = 500 tests('Remove Balanced NIC').succeeds do load_balancer = compute.load_balancers.get(@datacenter_id, @load_balancer_id) result = load_balancer.remove_nic_association(@nic_id) sleep(60) if ENV["FOG_MOCK"] != "true" result end tests('Remove Load Balancer').succeeds do load_balancer = compute.load_balancers.get(@datacenter_id, @load_balancer_id) load_balancer.delete end tests('Remove Firewall Rule').succeeds do firewall_rule = compute.firewall_rules.get(@datacenter_id, @composite_server_id, @nic_id, @firewall_rule_id) firewall_rule.delete end tests('Release IP Block').succeeds do ip_block = compute.ip_blocks.get(@ip_block_id) ip_block.delete end tests('Remove NIC').succeeds do sleep(60) if ENV["FOG_MOCK"] != "true" nic = compute.nics.get(@datacenter_id, @composite_server_id, @nic_id) nic.delete end tests('Remove LAN').succeeds do sleep(60) if ENV["FOG_MOCK"] != "true" lan = compute.lans.get(@datacenter_id, @lan_id) lan.delete end tests('Remove Snapshot').succeeds do snapshot = compute.snapshots.get(@snapshot_id) snapshot.delete end tests('Remove Volume').succeeds do volume = compute.volumes.get(@datacenter_id, @volume_id) volume.delete end tests('Remove Server').succeeds do server = compute.servers.get(@datacenter_id, @server_id) composite_server = compute.servers.get(@datacenter_id, @composite_server_id) server.delete and composite_server.delete end tests('Remove Datacenter').succeeds do datacenter = compute.datacenters.get(@datacenter_id) composite_dc = compute.datacenters.get(@composite_dc_id) datacenter.delete and composite_dc.delete end end end