vcli 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vcli/cli.rb +8 -1
- data/lib/vcli/cli/create.rb +73 -0
- data/lib/vcli/cli/delete.rb +66 -0
- data/lib/vcli/cli/show.rb +0 -7
- data/lib/vcli/version.rb +3 -1
- metadata +4 -3
- data/lib/vcli/cli/abiquo.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b90b147af12414d980bebb4ed0d6ccb07e51c93a
|
4
|
+
data.tar.gz: 8d193f0a852e877fa6300a60a8883d11fdf5d948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fe3bacfc94b449cadee6196e4c4754dddcf5f9f086b42dd3009fc37f81b36bffc8352855b82bef5a9e21dd2dd549b868a6ddac6fdfde7ccf9658561ad52270a
|
7
|
+
data.tar.gz: ad13b1cb806d042091505713c30caae9f12c53301126a329d2a39ff8e3af19f5e2713da0e2d1fc1564d33bc9bf2389855be97e934fdcce25784659091587b1ac
|
data/lib/vcli/cli.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'vcli/cli/show'
|
3
3
|
require 'vcli/cli/resource'
|
4
|
+
require 'vcli/cli/create'
|
5
|
+
require 'vcli/cli/delete'
|
4
6
|
require 'abiquo-api'
|
5
7
|
include Vcli
|
6
8
|
|
@@ -40,7 +42,6 @@ module Vcli
|
|
40
42
|
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
41
43
|
:abiquo_username => Vcli::user,
|
42
44
|
:abiquo_password => Vcli::password)
|
43
|
-
abq.user
|
44
45
|
enterprise=abq.user.link(:enterprise).get
|
45
46
|
puts "Logged into Abiquo Portal as User - #{abq.user.id} - #{abq.user.name} #{abq.user.surname}"
|
46
47
|
puts " in Enterprise - #{enterprise.id} - #{abq.enterprise.title}"
|
@@ -66,5 +67,11 @@ module Vcli
|
|
66
67
|
|
67
68
|
desc "show COMMANDS", "Show items within the Abiquo VDC"
|
68
69
|
subcommand "show", Vcli::CLI::Show
|
70
|
+
|
71
|
+
desc "create COMMANDS", "Create items within the Abiquo VDC"
|
72
|
+
subcommand "create", Vcli::CLI::Create
|
73
|
+
|
74
|
+
desc "delete COMMANDS", "Delete items within the Abiquo VDC"
|
75
|
+
subcommand "delete", Vcli::CLI::Delete
|
69
76
|
end
|
70
77
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
############################################################################
|
2
|
+
#
|
3
|
+
# VCLI::CLI::Create
|
4
|
+
#
|
5
|
+
############################################################################
|
6
|
+
# Jay Fearn
|
7
|
+
############################################################################
|
8
|
+
# Initial Create
|
9
|
+
############################################################################
|
10
|
+
# DATE # Ver # Description
|
11
|
+
############################################################################
|
12
|
+
# 28072015 # 0.1 # Initial Creation
|
13
|
+
############################################################################
|
14
|
+
|
15
|
+
module Vcli
|
16
|
+
module CLI
|
17
|
+
class Create < Thor
|
18
|
+
desc "virtualappliance", "Create Virtual Appliance"
|
19
|
+
def virtualappliance(name,vdc)
|
20
|
+
begin
|
21
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
22
|
+
:abiquo_username => Vcli::user,
|
23
|
+
:abiquo_password => Vcli::password)
|
24
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances' ,
|
25
|
+
:type => 'application/vnd.abiquo.virtualappliance+json')
|
26
|
+
newvirtualappliance={name: name}
|
27
|
+
response=abq.post(link,newvirtualappliance)
|
28
|
+
puts "ID for Virtual Appliance - #{response.id}"
|
29
|
+
rescue AbiquoAPIClient::Forbidden
|
30
|
+
puts "Forbidden HTTP 403 Received"
|
31
|
+
rescue AbiquoAPIClient::InvalidCredentials
|
32
|
+
puts "Invalid Credentials - HTTP 401 Received"
|
33
|
+
rescue AbiquoAPIClient::BadRequest
|
34
|
+
puts "Bad Request - HTTP 400 or 406 Received"
|
35
|
+
rescue AbiquoAPIClient::NotFound
|
36
|
+
puts "Note Found - HTTP 400 Received"
|
37
|
+
rescue AbiquoAPIClient::UnsupportedMediaType
|
38
|
+
puts "Unsupported Media Type Specified - HTTP 415 Received"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "vlan", "Create VLAN Appliance"
|
43
|
+
def vlan(name, address, mask, gateway, vdc)
|
44
|
+
begin
|
45
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
46
|
+
:abiquo_username => Vcli::user,
|
47
|
+
:abiquo_password => Vcli::password)
|
48
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/privatenetworks' ,
|
49
|
+
:type => 'application/vnd.abiquo.vlan+json')
|
50
|
+
# TODO Check the limits before creating new VLAN
|
51
|
+
# If exceeds limit then throw an error
|
52
|
+
# If within limits the create VLAN
|
53
|
+
|
54
|
+
newvlan={name: name, address: address, gateway: gateway, mask: mask}
|
55
|
+
response=abq.post(link,newvlan)
|
56
|
+
puts "ID for VLAN - #{response.id}"
|
57
|
+
rescue AbiquoAPIClient::Forbidden
|
58
|
+
puts "Forbidden HTTP 403 Received"
|
59
|
+
rescue AbiquoAPIClient::InvalidCredentials
|
60
|
+
puts "Invalid Credentials - HTTP 401 Received"
|
61
|
+
rescue AbiquoAPIClient::BadRequest
|
62
|
+
puts "Bad Request - HTTP 400 or 406 Received"
|
63
|
+
rescue AbiquoAPIClient::NotFound
|
64
|
+
puts "Not Found - HTTP 400 Received"
|
65
|
+
rescue AbiquoAPIClient::UnsupportedMediaType
|
66
|
+
puts "Unsupported Media Type Specified - HTTP 415 Received"
|
67
|
+
rescue AbiquoAPIClient::Error => e
|
68
|
+
puts "Error - "+ e.message
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
############################################################################
|
2
|
+
#
|
3
|
+
# VCLI::CLI::Delete
|
4
|
+
#
|
5
|
+
############################################################################
|
6
|
+
# Jay Fearn
|
7
|
+
############################################################################
|
8
|
+
# Initial Delete
|
9
|
+
############################################################################
|
10
|
+
# DATE # Ver # Description
|
11
|
+
############################################################################
|
12
|
+
# 28072015 # 0.1 # Initial Creation
|
13
|
+
############################################################################
|
14
|
+
|
15
|
+
module Vcli
|
16
|
+
module CLI
|
17
|
+
class Delete < Thor
|
18
|
+
desc "virtualappliance", "Delete Virtual Appliance"
|
19
|
+
def virtualappliance(id,vdc)
|
20
|
+
begin
|
21
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
22
|
+
:abiquo_username => Vcli::user,
|
23
|
+
:abiquo_password => Vcli::password)
|
24
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + id ,
|
25
|
+
:type => 'application/vnd.abiquo.virtualappliance+json')
|
26
|
+
response=abq.delete(link)
|
27
|
+
rescue AbiquoAPIClient::Forbidden
|
28
|
+
puts "Forbidden HTTP 403 Received"
|
29
|
+
rescue AbiquoAPIClient::InvalidCredentials
|
30
|
+
puts "Invalid Credentials - HTTP 401 Received"
|
31
|
+
rescue AbiquoAPIClient::BadRequest
|
32
|
+
puts "Bad Request - HTTP 400 or 406 Received"
|
33
|
+
rescue AbiquoAPIClient::NotFound
|
34
|
+
puts "Note Found - HTTP 400 Received"
|
35
|
+
rescue AbiquoAPIClient::UnsupportedMediaType
|
36
|
+
puts "Unsupported Media Type Specified - HTTP 415 Received"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "vlan", "Create VLAN Appliance"
|
41
|
+
def vlan(id,vdc)
|
42
|
+
begin
|
43
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
44
|
+
:abiquo_username => Vcli::user,
|
45
|
+
:abiquo_password => Vcli::password)
|
46
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/privatenetworks/' + id ,
|
47
|
+
:type => 'application/vnd.abiquo.vlan+json')
|
48
|
+
response=abq.delete(link)
|
49
|
+
puts "VLAN Deleted"
|
50
|
+
rescue AbiquoAPIClient::Forbidden
|
51
|
+
puts "Forbidden HTTP 403 Received"
|
52
|
+
rescue AbiquoAPIClient::InvalidCredentials
|
53
|
+
puts "Invalid Credentials - HTTP 401 Received"
|
54
|
+
rescue AbiquoAPIClient::BadRequest
|
55
|
+
puts "Bad Request - HTTP 400 or 406 Received"
|
56
|
+
rescue AbiquoAPIClient::NotFound
|
57
|
+
puts "Not Found - HTTP 400 Received"
|
58
|
+
rescue AbiquoAPIClient::UnsupportedMediaType
|
59
|
+
puts "Unsupported Media Type Specified - HTTP 415 Received"
|
60
|
+
rescue AbiquoAPIClient::Error => e
|
61
|
+
puts "Error - "+ e.message
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/vcli/cli/show.rb
CHANGED
@@ -22,7 +22,6 @@ module Vcli
|
|
22
22
|
class Show < Thor
|
23
23
|
# Data Centers
|
24
24
|
desc "datacenters", "Show all datacenters"
|
25
|
-
method_option :limits, :type => :boolean
|
26
25
|
def datacenters( )
|
27
26
|
begin
|
28
27
|
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
@@ -33,12 +32,6 @@ module Vcli
|
|
33
32
|
dc=abq.list(link)
|
34
33
|
dc.each { |l|
|
35
34
|
puts "#{l.name} \t - #{l.id} \t - #{l.location}"
|
36
|
-
if options.limits?
|
37
|
-
link2=AbiquoAPI::Link.new(:href => 'api/admin/datacenters/' + l.id.to_s + "/action/getlimits",
|
38
|
-
:type => 'application/vnd.abiquo.limits+json')
|
39
|
-
limits=abq.list(link2)
|
40
|
-
puts "#{limits}.inspect"
|
41
|
-
end
|
42
35
|
}
|
43
36
|
rescue AbiquoAPIClient::Forbidden
|
44
37
|
puts "Forbidden HTTP 403 Received"
|
data/lib/vcli/version.rb
CHANGED
@@ -10,7 +10,9 @@ module Vcli
|
|
10
10
|
# 0.2.0 #20072015# Added virtual machine functionality
|
11
11
|
#################################################################
|
12
12
|
# 0.2.1 #27072015# Added template functionality
|
13
|
+
#################################################################
|
14
|
+
# 0.2.2 #28072015# Added VLAN functionality
|
13
15
|
#################################################################
|
14
16
|
|
15
|
-
VERSION = "0.2.
|
17
|
+
VERSION = "0.2.2"
|
16
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay Fearn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -141,7 +141,8 @@ files:
|
|
141
141
|
- bin/vcli
|
142
142
|
- lib/vcli.rb
|
143
143
|
- lib/vcli/cli.rb
|
144
|
-
- lib/vcli/cli/
|
144
|
+
- lib/vcli/cli/create.rb
|
145
|
+
- lib/vcli/cli/delete.rb
|
145
146
|
- lib/vcli/cli/resource.rb
|
146
147
|
- lib/vcli/cli/show.rb
|
147
148
|
- lib/vcli/version.rb
|
data/lib/vcli/cli/abiquo.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
abiquo = lambda {AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)}
|