26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/vcli/cli.rb', line 26
def login()
target=options[:target].to_s
user=options[:user].to_s
password=options[:password].to_s
if target.length >0
Vcli.set_config("target",target)
end
if user.length >0
Vcli.set_config("user",user)
end
if password.length >0
Vcli.set_config("password",password)
end
begin
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
:abiquo_username => Vcli::user,
:abiquo_password => Vcli::password)
abq.user
enterprise=abq.user.link(:enterprise).get
puts "Logged into Abiquo Portal as User - #{abq.user.id} - #{abq.user.name} #{abq.user.surname}"
puts " in Enterprise - #{enterprise.id} - #{abq.enterprise.title}"
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 "Note Found - HTTP 400 Received"
rescue AbiquoAPIClient::UnsupportedMediaType
puts "Unsupported Media Type Specified - HTTP 415 Received"
end
end
|