Class: Vcli::CLI::Delete

Inherits:
Thor
  • Object
show all
Defined in:
lib/vcli/cli/delete.rb

Instance Method Summary collapse

Instance Method Details

#virtualappliance(id, vdc) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vcli/cli/delete.rb', line 19

def virtualappliance(id,vdc)
  begin
    abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
    link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + id ,
                             :type => 'application/vnd.abiquo.virtualappliance+json')
    abq.delete(link)
  rescue AbiquoAPIClient::Forbidden
    puts "Forbidden HTTP 403 Received"
  rescue AbiquoAPIClient::InvalidCredentials
    puts "Invalid Credentials - HTTP 401 Received" 
  rescue AbiquoAPIClient::BadRequest
    puts "Bad Request - HTTP 400 or 406 Received"
  rescue AbiquoAPIClient::NotFound
    puts "Not Found - HTTP 400 Received"
  rescue AbiquoAPIClient::UnsupportedMediaType
    puts "Unsupported Media Type Specified - HTTP 415 Received"
  end
end

#virtualmachine(vm, va, vdc) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/vcli/cli/delete.rb', line 62

def virtualmachine(vm, va, vdc)
  begin
    abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
    link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines/' + vm,
                             :type => 'application/vnd.abiquo.virtualmachine+json')
    abq.delete(link)
    puts "VM Deleted"
  rescue AbiquoAPIClient::Forbidden
    puts "Forbidden HTTP 403 Received"
  rescue AbiquoAPIClient::InvalidCredentials
    puts "Invalid Credentials - HTTP 401 Received"
  rescue AbiquoAPIClient::BadRequest
    puts "Bad Request - HTTP 400 or 406 Received"
  rescue AbiquoAPIClient::NotFound
    puts "Not Found - HTTP 400 Received"
  rescue AbiquoAPIClient::UnsupportedMediaType
    puts "Unsupported Media Type Specified - HTTP 415 Received"
  end
end

#vlan(id, vdc) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/vcli/cli/delete.rb', line 39

def vlan(id,vdc)
  begin
    abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
    link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/privatenetworks/' + id ,
                             :type => 'application/vnd.abiquo.vlan+json')
    abq.delete(link)
    puts "VLAN Deleted"
  rescue AbiquoAPIClient::Forbidden
    puts "Forbidden HTTP 403 Received"
  rescue AbiquoAPIClient::InvalidCredentials
    puts "Invalid Credentials - HTTP 401 Received" 
  rescue AbiquoAPIClient::BadRequest
    puts "Bad Request - HTTP 400 or 406 Received"
  rescue AbiquoAPIClient::NotFound
    puts "Not Found - HTTP 400 Received"
  rescue AbiquoAPIClient::UnsupportedMediaType
    puts "Unsupported Media Type Specified - HTTP 415 Received"
  rescue AbiquoAPIClient::Error => e
    puts "Error - "+ e.message
  end
end