Class: Fog::Compute::Openvz::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/openvz/compute.rb,
lib/fog/openvz/requests/compute/set_server.rb,
lib/fog/openvz/requests/compute/exec_server.rb,
lib/fog/openvz/requests/compute/stop_server.rb,
lib/fog/openvz/requests/compute/exec2_server.rb,
lib/fog/openvz/requests/compute/list_servers.rb,
lib/fog/openvz/requests/compute/mount_server.rb,
lib/fog/openvz/requests/compute/start_server.rb,
lib/fog/openvz/requests/compute/create_server.rb,
lib/fog/openvz/requests/compute/resume_server.rb,
lib/fog/openvz/requests/compute/status_server.rb,
lib/fog/openvz/requests/compute/umount_server.rb,
lib/fog/openvz/requests/compute/compact_server.rb,
lib/fog/openvz/requests/compute/convert_server.rb,
lib/fog/openvz/requests/compute/destroy_server.rb,
lib/fog/openvz/requests/compute/quotaon_server.rb,
lib/fog/openvz/requests/compute/restart_server.rb,
lib/fog/openvz/requests/compute/suspend_server.rb,
lib/fog/openvz/requests/compute/quotaoff_server.rb,
lib/fog/openvz/requests/compute/snapshot_server.rb,
lib/fog/openvz/requests/compute/quotainit_server.rb,
lib/fog/openvz/requests/compute/runscript_server.rb,
lib/fog/openvz/requests/compute/get_server_details.rb,
lib/fog/openvz/requests/compute/snapshot_list_server.rb,
lib/fog/openvz/requests/compute/snapshot_mount_server.rb,
lib/fog/openvz/requests/compute/snapshot_delete_server.rb,
lib/fog/openvz/requests/compute/snapshot_switch_server.rb,
lib/fog/openvz/requests/compute/snapshot_umount_server.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



58
59
60
# File 'lib/fog/openvz/compute.rb', line 58

def initialize(options={})
  @openvz_connect_command = options[:openvz_connect_command]
end

Class Method Details

.dataObject



46
47
48
49
50
51
52
# File 'lib/fog/openvz/compute.rb', line 46

def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {
      :servers => [],
    }
  end
end

.resetObject



54
55
56
# File 'lib/fog/openvz/compute.rb', line 54

def self.reset
  @data = nil
end

Instance Method Details

#compact_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/compact_server.rb', line 14

def compact_server(id, options = {})
  Fog::Mock.not_implemented
end

#convert_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/convert_server.rb', line 14

def convert_server(id, options = {})
  Fog::Mock.not_implemented
end

#create_server(options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/fog/openvz/requests/compute/create_server.rb', line 14

def create_server(options = {})
  # When a new fake server is created we set the status to stopped
  options['status'] = 'stopped'
  self.data[:servers] << options
end

#dataObject



62
63
64
# File 'lib/fog/openvz/compute.rb', line 62

def data
  self.class.data[@openvz_connect_command]
end

#destroy_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/destroy_server.rb', line 14

def destroy_server(id , options = {})
  self.data[:servers].reject! { |s| s['ctid'].to_s == id.to_s }
end

#exec2_server(id, args) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/exec2_server.rb', line 14

def exec2_server(id, args)
  Fog::Mock.not_implemented
end

#exec_server(id, args = []) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/exec_server.rb', line 14

def exec_server(id, args = [])
  Fog::Mock.not_implemented
end

#get_server_details(id) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/get_server_details.rb', line 14

def get_server_details(id)
  return self.data[:servers].find { |s| s['ctid'].to_s == id.to_s }
end

#list_serversObject



14
15
16
# File 'lib/fog/openvz/requests/compute/list_servers.rb', line 14

def list_servers
  self.data[:servers]
end

#mount_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/mount_server.rb', line 14

def mount_server(id, options = {})
  Fog::Mock.not_implemented
end

#quotainit_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/quotainit_server.rb', line 14

def quotainit_server(id, options = {})
  Fog::Mock.not_implemented
end

#quotaon_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/quotaon_server.rb', line 14

def quotaon_server(id, options = {})
  Fog::Mock.not_implemented
end

#quotaooff_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/quotaoff_server.rb', line 14

def quotaooff_server(id, options = {})
  Fog::Mock.not_implemented
end

#reset_dataObject



66
67
68
# File 'lib/fog/openvz/compute.rb', line 66

def reset_data
  self.class.data.delete(@openvz_connect_command)
end

#restart_server(id, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/fog/openvz/requests/compute/restart_server.rb', line 14

def restart_server(id, options = {})
  server = self.data[:servers].find { |s| s['ctid'] == id.to_s }
  unless server.nil?
    server['status'] = 'running'
  end
end

#resume_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/resume_server.rb', line 14

def resume_server(id, options = {})
  Fog::Mock.not_implemented
end

#runscript_server(id, args = []) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/runscript_server.rb', line 14

def runscript_server(id,args = [])
  Fog::Mock.not_implemented
end

#set_server(id, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/fog/openvz/requests/compute/set_server.rb', line 14

def set_server(id, options = {})
  server = self.data[:servers].find { |s| s['ctid'].to_s == id.to_s }
  unless server.nil?
    options.each do |k,v|
      server[k] = v
    end
  end

end

#snapshot_delete_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/snapshot_delete_server.rb', line 14

def snapshot_delete_server(id,options = {})
  Fog::Mock.not_implemented
end

#snapshot_list_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/snapshot_list_server.rb', line 14

def snapshot_list_server(id, options = {})
  Fog::Mock.not_implemented
end

#snapshot_mount_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/snapshot_mount_server.rb', line 14

def snapshot_mount_server(id,options = {})
  Fog::Mock.not_implemented
end

#snapshot_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/snapshot_server.rb', line 14

def snapshot_server(id,options = {})
  Fog::Mock.not_implemented
end

#snapshot_switch_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/snapshot_switch_server.rb', line 14

def snapshot_switch_server(id,options = {})
  Fog::Mock.not_implemented
end

#snapshot_umount_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/snapshot_umount_server.rb', line 14

def snapshot_umount_server(id,options = {})
  Fog::Mock.not_implemented
end

#start_server(id, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/fog/openvz/requests/compute/start_server.rb', line 14

def start_server(id,options={})
  server = self.data[:servers].find { |s| s['ctid'].to_s == id.to_s }
  unless server.nil?
    server['status'] = 'running'
  end
end

#status_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/status_server.rb', line 14

def status_server(id, options = {})
  Fog::Mock.not_implemented
end

#stop_server(id, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/fog/openvz/requests/compute/stop_server.rb', line 14

def stop_server(id, options = {})
   server = self.data[:servers].find { |s| s['ctid'].to_s == id.to_s }
    unless server.nil?
         server['status'] = 'stopped'
    end
end

#suspend_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/suspend_server.rb', line 14

def suspend_server(id, options = {})
  Fog::Mock.not_implemented
end

#umount_server(id, options = {}) ⇒ Object



14
15
16
# File 'lib/fog/openvz/requests/compute/umount_server.rb', line 14

def umount_server(id, options = {})
  Fog::Mock.not_implemented
end