Skip to content

Commit

Permalink
Change module namespace to Fog::Vsphere::Compute
Browse files Browse the repository at this point in the history
* Transfer to preferred namespace Fog::Vsphere::Compute

* Add Upgrade notice

* bump version
  • Loading branch information
ezr-ondrej authored and timogoebel committed Mar 20, 2019
1 parent 495c6a9 commit e137fa7
Show file tree
Hide file tree
Showing 137 changed files with 352 additions and 343 deletions.
4 changes: 4 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ Metrics/ParameterLists:
Metrics/PerceivedComplexity:
Max: 159

Naming/FileName:
Exclude:
- 'lib/fog-vsphere.rb'

# Offense count: 10
Style/CaseEquality:
Exclude:
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ Or install it yourself as:
gem install fog-vsphere
```

## Upgrading

In version 3.0.0 we have changed the namespacing of `Compute` service.
`Fog::Compute::Vsphere` became `Fog::Vsphere::Compute` as recommended by fog-core.
We hope we are not causing any issues as `Fog::Compute[:vsphere]` is only public API.

## Usage

To connect to your vSphere instance with Fog vSphere:
Expand Down Expand Up @@ -67,7 +73,7 @@ compute.list_virtual_machines

# List a VM's SCSI controllers
compute.list_vm_scsi_controllers('ab589f9a-af35-428e-9690-9b96587d86f3')
#=> [<Fog::Compute::Vsphere::SCSIController
#=> [<Fog::Vsphere::Compute::SCSIController
#=> shared_bus='noSharing',
#=> type='VirtualLsiLogicController',
#=> unit_number=7,
Expand Down
1 change: 1 addition & 0 deletions lib/fog-vsphere.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'fog/vsphere'
2 changes: 1 addition & 1 deletion lib/fog/bin/vsphere.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class << self
def class_for(key)
case key
when :compute
Fog::Compute::Vsphere
Fog::Vsphere::Compute
else
raise ArgumentError, "Unrecognized service: #{key}"
end
Expand Down
6 changes: 2 additions & 4 deletions lib/fog/vsphere.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
require 'fog/core'

module Fog
module Compute
autoload :Vsphere, File.expand_path('../vsphere/compute.rb', __FILE__)
end

module Vsphere
extend Fog::Provider

Expand All @@ -14,6 +10,8 @@ class SecurityError < ServiceError; end
class NotFound < ServiceError; end
end

autoload :Compute, File.expand_path('../vsphere/compute', __FILE__)

service(:compute, 'Compute')

# This helper was originally added as Fog.class_as_string and moved to core but only used here
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# rubocop:disable Lint/RescueWithoutErrorClass
# rubocop:disable Metrics/ModuleLength
module Fog
module Compute
class Vsphere < Fog::Service
module Vsphere
class Compute < Fog::Service
requires :vsphere_username, :vsphere_password, :vsphere_server
recognizes :vsphere_port, :vsphere_path, :vsphere_ns
recognizes :vsphere_rev, :vsphere_ssl, :vsphere_expected_pubkey_hash
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/models/compute/cdrom.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Cdrom < Fog::Model
identity :key

Expand Down
6 changes: 3 additions & 3 deletions lib/fog/vsphere/models/compute/cdroms.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Cdroms < Fog::Collection
attribute :instance_uuid, alias: :server_id
model Fog::Compute::Vsphere::Cdrom
model Fog::Vsphere::Compute::Cdrom

def all(_filters = {})
load service.list_vm_cdroms(instance_uuid)
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/models/compute/cluster.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Cluster < Fog::Model
identity :id

Expand Down
6 changes: 3 additions & 3 deletions lib/fog/vsphere/models/compute/clusters.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Clusters < Fog::Collection
autoload :Cluster, File.expand_path('../cluster', __FILE__)

model Fog::Compute::Vsphere::Cluster
model Fog::Vsphere::Compute::Cluster
attr_accessor :datacenter

def all(filters = {})
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/models/compute/customfield.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Customfield < Fog::Model
identity :key

Expand Down
6 changes: 3 additions & 3 deletions lib/fog/vsphere/models/compute/customfields.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Customfields < Fog::Collection
autoload :Customfield, File.expand_path('../customfield', __FILE__)

model Fog::Compute::Vsphere::Customfield
model Fog::Vsphere::Compute::Customfield

attr_accessor :vm

Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/models/compute/customvalue.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Customvalue < Fog::Model
attribute :value
attribute :key
Expand Down
10 changes: 5 additions & 5 deletions lib/fog/vsphere/models/compute/customvalues.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Customvalues < Fog::Collection
autoload :Customvalue, File.expand_path('../customvalue', __FILE__)

model Fog::Compute::Vsphere::Customvalue
model Fog::Vsphere::Compute::Customvalue

attr_accessor :vm

def all(_filters = {})
requires :vm
case vm
when Fog::Compute::Vsphere::Server
when Fog::Vsphere::Compute::Server
load service.list_vm_customvalues(vm.id)
else
raise 'customvalues should have vm'
Expand All @@ -21,7 +21,7 @@ def all(_filters = {})
def get(key)
requires :vm
case vm
when Fog::Compute::Vsphere::Server
when Fog::Vsphere::Compute::Server
load service.list_vm_customvalues(vm.id)
else
raise 'customvalues should have vm'
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/models/compute/datacenter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Datacenter < Fog::Model
identity :id
attribute :name
Expand Down
6 changes: 3 additions & 3 deletions lib/fog/vsphere/models/compute/datacenters.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Datacenters < Fog::Collection
autoload :Datacenter, File.expand_path('../datacenter', __FILE__)

model Fog::Compute::Vsphere::Datacenter
model Fog::Vsphere::Compute::Datacenter

def all(filters = {})
load service.list_datacenters(filters)
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/models/compute/datastore.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Datastore < Fog::Model
identity :id

Expand Down
6 changes: 3 additions & 3 deletions lib/fog/vsphere/models/compute/datastores.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Datastores < Fog::Collection
autoload :Datastore, File.expand_path('../datastore', __FILE__)

model Fog::Compute::Vsphere::Datastore
model Fog::Vsphere::Compute::Datastore
attr_accessor :datacenter, :cluster

def all(filters = {})
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/models/compute/folder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Folder < Fog::Model
identity :id

Expand Down
6 changes: 3 additions & 3 deletions lib/fog/vsphere/models/compute/folders.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Folders < Fog::Collection
autoload :Folder, File.expand_path('../folder', __FILE__)

model Fog::Compute::Vsphere::Folder
model Fog::Vsphere::Compute::Folder
attr_accessor :datacenter, :type, :path

def all(filters = {})
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/models/compute/host.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Host < Fog::Model
identity :name

Expand Down
8 changes: 4 additions & 4 deletions lib/fog/vsphere/models/compute/hosts.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Hosts < Fog::Collection
attribute :datacenter
attribute :cluster

model Fog::Compute::Vsphere::Host
model Fog::Vsphere::Compute::Host

def all(_filters = {})
requires :datacenter, :cluster
Expand All @@ -14,7 +14,7 @@ def all(_filters = {})

def get(name)
all.find { |host| host.name == name } ||
raise(Fog::Compute::Vsphere::NotFound, "no such host #{name}")
raise(Fog::Vsphere::Compute::NotFound, "no such host #{name}")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/models/compute/interface.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Interface < Fog::Model
SAVE_MUTEX = Mutex.new

Expand Down
16 changes: 8 additions & 8 deletions lib/fog/vsphere/models/compute/interfaces.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Interfaces < Fog::Collection
autoload :Interface, File.expand_path('../interface', __FILE__)

model Fog::Compute::Vsphere::Interface
model Fog::Vsphere::Compute::Interface

attribute :server_id

def all(_filters = {})
requires :server_id

case server
when Fog::Compute::Vsphere::Server
when Fog::Vsphere::Compute::Server
load service.list_vm_interfaces(server.id)
when Fog::Compute::Vsphere::Template
when Fog::Vsphere::Compute::Template
load service.list_template_interfaces(server.id)
else
raise 'interfaces should have vm or template'
Expand All @@ -28,17 +28,17 @@ def get(id)
requires :server_id

case server
when Fog::Compute::Vsphere::Server
when Fog::Vsphere::Compute::Server
interface = service.get_vm_interface(server.id, key: id, mac: id, name: id, datacenter: server.datacenter)
when Fog::Compute::Vsphere::Template
when Fog::Vsphere::Compute::Template
interface = service.get_template_interfaces(server.id, key: id, mac: id, name: id)
else

raise 'interfaces should have vm or template'
end

if interface
Fog::Compute::Vsphere::Interface.new(interface.merge(server_id: server.id, service: service))
Fog::Vsphere::Compute::Interface.new(interface.merge(server_id: server.id, service: service))
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/models/compute/interfacetype.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Interfacetype < Fog::Model
identity :id

Expand Down
10 changes: 5 additions & 5 deletions lib/fog/vsphere/models/compute/interfacetypes.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Interfacetypes < Fog::Collection
autoload :Interfacetype, File.expand_path('../interfacetype', __FILE__)

model Fog::Compute::Vsphere::Interfacetype
model Fog::Vsphere::Compute::Interfacetype
attr_accessor :datacenter
attr_accessor :servertype

def all(filters = {})
requires :servertype
case servertype
when Fog::Compute::Vsphere::Servertype
when Fog::Vsphere::Compute::Servertype
load service.list_interface_types(filters.merge(datacenter: datacenter,
servertype: servertype.id))
else
Expand All @@ -23,7 +23,7 @@ def get(id)
requires :servertype
requires :datacenter
new service.get_interface_type id, servertype, datacenter
rescue Fog::Compute::Vsphere::NotFound
rescue Fog::Vsphere::Compute::NotFound
nil
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/models/compute/network.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fog
module Compute
class Vsphere
module Vsphere
class Compute
class Network < Fog::Model
identity :id

Expand Down
Loading

0 comments on commit e137fa7

Please sign in to comment.