mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-02 13:16:48 +09:00
M #-: add more methods to Vultr API (#1729)
This commit is contained in:
1 parent
a1634e76e0
commit
f1da69b04a
1 file changed
+42
@@ -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
|
||||
|
||||
Reference in new issue
Block a user