mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
M #-: add more methods to Vultr API (#1729)
(cherry picked from commit f1da69b04a6f3a438db08ef882f26d89fd05d3ba)
This commit is contained in:
parent
e3aa492a8d
commit
ee58967e96
@ -47,6 +47,9 @@ class Vultr
|
||||
# API instances URL
|
||||
INSTANCE_URL = "#{BASE_URL}/instances"
|
||||
|
||||
# API bare-metal instances
|
||||
BAREMETAL_URL = "#{BASE_URL}/bare-metals"
|
||||
|
||||
# API networks URL
|
||||
NETWORK_URL = "#{BASE_URL}/reserved-ips"
|
||||
|
||||
@ -60,10 +63,33 @@ class Vultr
|
||||
@key = key
|
||||
end
|
||||
|
||||
############################################################################
|
||||
# Baremetal Methods
|
||||
############################################################################
|
||||
def list_metals
|
||||
get(BAREMETAL_URL)
|
||||
end
|
||||
|
||||
# Delete baremetal
|
||||
#
|
||||
# @param id [String] Baremetal ID
|
||||
#
|
||||
# @return [Nil, Error] nil if no error, error othwerise
|
||||
def delete_metal(id)
|
||||
delete("#{BAREMETAL_URL}/#{id}")
|
||||
end
|
||||
|
||||
############################################################################
|
||||
# Instances Methods
|
||||
############################################################################
|
||||
|
||||
# List instances
|
||||
#
|
||||
# @return [Hash, Error] hash with instances, error otherwise
|
||||
def list_instances
|
||||
get(INSTANCE_URL)
|
||||
end
|
||||
|
||||
# Get instances information
|
||||
#
|
||||
# @param id [String] Instances ID
|
||||
@ -77,6 +103,15 @@ class Vultr
|
||||
JSON.parse(rc)['instance']
|
||||
end
|
||||
|
||||
# Delete instance
|
||||
#
|
||||
# @param id [String] Instances ID
|
||||
#
|
||||
# @return [Nil, Error] nil if no error, error othwerise
|
||||
def delete_instance(id)
|
||||
delete("#{INSTANCE_URL}/#{id}")
|
||||
end
|
||||
|
||||
# Attach Reserved IP to an Instance
|
||||
#
|
||||
# @param id [String] Instance ID
|
||||
@ -107,6 +142,13 @@ class Vultr
|
||||
# Network methods
|
||||
############################################################################
|
||||
|
||||
# List IPs
|
||||
#
|
||||
# @return [Hash, Error] hash with IPs, error otherwise
|
||||
def list_ips
|
||||
get(NETWORK_URL)
|
||||
end
|
||||
|
||||
# Create a new Reserved IP in a region
|
||||
#
|
||||
# @param region [String] Create the Reserved IP in this Region id
|
||||
|
Loading…
x
Reference in New Issue
Block a user