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.



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

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

Class Method Details

.dataObject



43
44
45
46
47
48
49
# File 'lib/fog/openvz/compute.rb', line 43

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

.resetObject



51
52
53
# File 'lib/fog/openvz/compute.rb', line 51

def self.reset
  @data = nil
end

Instance Method Details

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



11
12
13
# File 'lib/fog/openvz/requests/compute/compact_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/convert_server.rb', line 11

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

#create_server(options = {}) ⇒ Object



11
12
13
14
15
# File 'lib/fog/openvz/requests/compute/create_server.rb', line 11

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



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

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/destroy_server.rb', line 11

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

#exec2_server(id, args) ⇒ Object



11
12
13
# File 'lib/fog/openvz/requests/compute/exec2_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/exec_server.rb', line 11

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

#get_server_details(id) ⇒ Object



11
12
13
# File 'lib/fog/openvz/requests/compute/get_server_details.rb', line 11

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

#list_serversObject



11
12
13
# File 'lib/fog/openvz/requests/compute/list_servers.rb', line 11

def list_servers
  self.data[:servers]
end

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



11
12
13
# File 'lib/fog/openvz/requests/compute/mount_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/quotainit_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/quotaon_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/quotaoff_server.rb', line 11

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

#reset_dataObject



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

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

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



11
12
13
14
15
16
# File 'lib/fog/openvz/requests/compute/restart_server.rb', line 11

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



11
12
13
# File 'lib/fog/openvz/requests/compute/resume_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/runscript_server.rb', line 11

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

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



11
12
13
14
15
16
17
18
# File 'lib/fog/openvz/requests/compute/set_server.rb', line 11

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



11
12
13
# File 'lib/fog/openvz/requests/compute/snapshot_delete_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/snapshot_list_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/snapshot_mount_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/snapshot_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/snapshot_switch_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/snapshot_umount_server.rb', line 11

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

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



11
12
13
14
15
16
# File 'lib/fog/openvz/requests/compute/start_server.rb', line 11

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



11
12
13
# File 'lib/fog/openvz/requests/compute/status_server.rb', line 11

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

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



11
12
13
14
15
16
# File 'lib/fog/openvz/requests/compute/stop_server.rb', line 11

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



11
12
13
# File 'lib/fog/openvz/requests/compute/suspend_server.rb', line 11

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

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



11
12
13
# File 'lib/fog/openvz/requests/compute/umount_server.rb', line 11

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