hpcloud 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +127 -0
- data/LICENSE +1 -0
- data/README.rdoc +59 -0
- data/bin/hpcloud +11 -0
- data/completion/hpcloud +372 -0
- data/lib/hpcloud/accounts.rb +288 -0
- data/lib/hpcloud/acl.rb +112 -0
- data/lib/hpcloud/acl_cmd.rb +81 -0
- data/lib/hpcloud/address_helper.rb +63 -0
- data/lib/hpcloud/addresses.rb +42 -0
- data/lib/hpcloud/auth_cache.rb +128 -0
- data/lib/hpcloud/base_helper.rb +56 -0
- data/lib/hpcloud/checker.rb +104 -0
- data/lib/hpcloud/cli.rb +170 -0
- data/lib/hpcloud/cli_status.rb +80 -0
- data/lib/hpcloud/columns.rb +46 -0
- data/lib/hpcloud/commands/account/catalog.rb +57 -0
- data/lib/hpcloud/commands/account/copy.rb +44 -0
- data/lib/hpcloud/commands/account/edit.rb +204 -0
- data/lib/hpcloud/commands/account/remove.rb +53 -0
- data/lib/hpcloud/commands/account/setup.rb +40 -0
- data/lib/hpcloud/commands/account/tenants.rb +43 -0
- data/lib/hpcloud/commands/account/use.rb +46 -0
- data/lib/hpcloud/commands/account/verify.rb +55 -0
- data/lib/hpcloud/commands/account.rb +67 -0
- data/lib/hpcloud/commands/acl/grant.rb +59 -0
- data/lib/hpcloud/commands/acl/revoke.rb +52 -0
- data/lib/hpcloud/commands/acl.rb +63 -0
- data/lib/hpcloud/commands/addresses/add.rb +67 -0
- data/lib/hpcloud/commands/addresses/associate.rb +63 -0
- data/lib/hpcloud/commands/addresses/disassociate.rb +58 -0
- data/lib/hpcloud/commands/addresses/remove.rb +57 -0
- data/lib/hpcloud/commands/addresses.rb +63 -0
- data/lib/hpcloud/commands/cdn_containers/add.rb +56 -0
- data/lib/hpcloud/commands/cdn_containers/get.rb +70 -0
- data/lib/hpcloud/commands/cdn_containers/location.rb +61 -0
- data/lib/hpcloud/commands/cdn_containers/remove.rb +55 -0
- data/lib/hpcloud/commands/cdn_containers/set.rb +63 -0
- data/lib/hpcloud/commands/cdn_containers.rb +72 -0
- data/lib/hpcloud/commands/complete.rb +60 -0
- data/lib/hpcloud/commands/config/set.rb +63 -0
- data/lib/hpcloud/commands/config.rb +46 -0
- data/lib/hpcloud/commands/containers/add.rb +67 -0
- data/lib/hpcloud/commands/containers/remove.rb +63 -0
- data/lib/hpcloud/commands/containers/sync.rb +59 -0
- data/lib/hpcloud/commands/containers.rb +24 -0
- data/lib/hpcloud/commands/copy.rb +78 -0
- data/lib/hpcloud/commands/dns/add.rb +56 -0
- data/lib/hpcloud/commands/dns/records/add.rb +50 -0
- data/lib/hpcloud/commands/dns/records/remove.rb +53 -0
- data/lib/hpcloud/commands/dns/records/update.rb +50 -0
- data/lib/hpcloud/commands/dns/records.rb +57 -0
- data/lib/hpcloud/commands/dns/remove.rb +57 -0
- data/lib/hpcloud/commands/dns/servers.rb +57 -0
- data/lib/hpcloud/commands/dns/update.rb +58 -0
- data/lib/hpcloud/commands/dns.rb +65 -0
- data/lib/hpcloud/commands/flavors.rb +59 -0
- data/lib/hpcloud/commands/get.rb +58 -0
- data/lib/hpcloud/commands/images/add.rb +54 -0
- data/lib/hpcloud/commands/images/metadata/add.rb +54 -0
- data/lib/hpcloud/commands/images/metadata/remove.rb +56 -0
- data/lib/hpcloud/commands/images/metadata.rb +54 -0
- data/lib/hpcloud/commands/images/remove.rb +58 -0
- data/lib/hpcloud/commands/images.rb +67 -0
- data/lib/hpcloud/commands/info.rb +41 -0
- data/lib/hpcloud/commands/keypairs/add.rb +73 -0
- data/lib/hpcloud/commands/keypairs/import.rb +62 -0
- data/lib/hpcloud/commands/keypairs/private/add.rb +44 -0
- data/lib/hpcloud/commands/keypairs/private/location.rb +50 -0
- data/lib/hpcloud/commands/keypairs/private/remove.rb +52 -0
- data/lib/hpcloud/commands/keypairs/private.rb +47 -0
- data/lib/hpcloud/commands/keypairs/public_key.rb +51 -0
- data/lib/hpcloud/commands/keypairs/remove.rb +58 -0
- data/lib/hpcloud/commands/keypairs.rb +64 -0
- data/lib/hpcloud/commands/lb/add.rb +92 -0
- data/lib/hpcloud/commands/lb/algorithms.rb +55 -0
- data/lib/hpcloud/commands/lb/limits.rb +55 -0
- data/lib/hpcloud/commands/lb/nodes/add.rb +47 -0
- data/lib/hpcloud/commands/lb/nodes/remove.rb +54 -0
- data/lib/hpcloud/commands/lb/nodes/update.rb +47 -0
- data/lib/hpcloud/commands/lb/nodes.rb +55 -0
- data/lib/hpcloud/commands/lb/protocols.rb +55 -0
- data/lib/hpcloud/commands/lb/remove.rb +54 -0
- data/lib/hpcloud/commands/lb/update.rb +46 -0
- data/lib/hpcloud/commands/lb/versions.rb +55 -0
- data/lib/hpcloud/commands/lb/virtualips.rb +51 -0
- data/lib/hpcloud/commands/lb.rb +73 -0
- data/lib/hpcloud/commands/list.rb +114 -0
- data/lib/hpcloud/commands/location.rb +56 -0
- data/lib/hpcloud/commands/metadata/set.rb +61 -0
- data/lib/hpcloud/commands/metadata.rb +60 -0
- data/lib/hpcloud/commands/migrate.rb +61 -0
- data/lib/hpcloud/commands/move.rb +73 -0
- data/lib/hpcloud/commands/networks/add.rb +55 -0
- data/lib/hpcloud/commands/networks/remove.rb +57 -0
- data/lib/hpcloud/commands/networks/update.rb +54 -0
- data/lib/hpcloud/commands/networks.rb +63 -0
- data/lib/hpcloud/commands/ports/add.rb +81 -0
- data/lib/hpcloud/commands/ports/remove.rb +57 -0
- data/lib/hpcloud/commands/ports/update.rb +67 -0
- data/lib/hpcloud/commands/ports.rb +63 -0
- data/lib/hpcloud/commands/remove.rb +75 -0
- data/lib/hpcloud/commands/routers/add.rb +67 -0
- data/lib/hpcloud/commands/routers/interface/add.rb +59 -0
- data/lib/hpcloud/commands/routers/interface/remove.rb +66 -0
- data/lib/hpcloud/commands/routers/remove.rb +54 -0
- data/lib/hpcloud/commands/routers/update.rb +66 -0
- data/lib/hpcloud/commands/routers.rb +66 -0
- data/lib/hpcloud/commands/securitygroups/add.rb +52 -0
- data/lib/hpcloud/commands/securitygroups/remove.rb +57 -0
- data/lib/hpcloud/commands/securitygroups/rules/add.rb +126 -0
- data/lib/hpcloud/commands/securitygroups/rules/remove.rb +51 -0
- data/lib/hpcloud/commands/securitygroups/rules.rb +56 -0
- data/lib/hpcloud/commands/securitygroups.rb +62 -0
- data/lib/hpcloud/commands/servers/add.rb +100 -0
- data/lib/hpcloud/commands/servers/console.rb +81 -0
- data/lib/hpcloud/commands/servers/limits.rb +46 -0
- data/lib/hpcloud/commands/servers/metadata/add.rb +56 -0
- data/lib/hpcloud/commands/servers/metadata/remove.rb +57 -0
- data/lib/hpcloud/commands/servers/metadata.rb +56 -0
- data/lib/hpcloud/commands/servers/password.rb +47 -0
- data/lib/hpcloud/commands/servers/ratelimits.rb +46 -0
- data/lib/hpcloud/commands/servers/reboot.rb +61 -0
- data/lib/hpcloud/commands/servers/rebuild.rb +59 -0
- data/lib/hpcloud/commands/servers/remove.rb +58 -0
- data/lib/hpcloud/commands/servers/securitygroups/add.rb +47 -0
- data/lib/hpcloud/commands/servers/securitygroups/remove.rb +47 -0
- data/lib/hpcloud/commands/servers/ssh.rb +92 -0
- data/lib/hpcloud/commands/servers.rb +92 -0
- data/lib/hpcloud/commands/snapshots/add.rb +62 -0
- data/lib/hpcloud/commands/snapshots/remove.rb +58 -0
- data/lib/hpcloud/commands/snapshots.rb +62 -0
- data/lib/hpcloud/commands/subnets/add.rb +78 -0
- data/lib/hpcloud/commands/subnets/remove.rb +57 -0
- data/lib/hpcloud/commands/subnets/update.rb +70 -0
- data/lib/hpcloud/commands/subnets.rb +63 -0
- data/lib/hpcloud/commands/tempurl.rb +62 -0
- data/lib/hpcloud/commands/volumes/add.rb +88 -0
- data/lib/hpcloud/commands/volumes/attach.rb +59 -0
- data/lib/hpcloud/commands/volumes/detach.rb +57 -0
- data/lib/hpcloud/commands/volumes/metadata/add.rb +54 -0
- data/lib/hpcloud/commands/volumes/metadata.rb +55 -0
- data/lib/hpcloud/commands/volumes/remove.rb +57 -0
- data/lib/hpcloud/commands/volumes/server.rb +64 -0
- data/lib/hpcloud/commands/volumes.rb +65 -0
- data/lib/hpcloud/config.rb +205 -0
- data/lib/hpcloud/connection.rb +290 -0
- data/lib/hpcloud/container_resource.rb +175 -0
- data/lib/hpcloud/database_helper.rb +70 -0
- data/lib/hpcloud/databases.rb +38 -0
- data/lib/hpcloud/dns_helper.rb +125 -0
- data/lib/hpcloud/dnss.rb +38 -0
- data/lib/hpcloud/error_response.rb +89 -0
- data/lib/hpcloud/exceptions/base.rb +35 -0
- data/lib/hpcloud/exceptions/general.rb +34 -0
- data/lib/hpcloud/exceptions/not_found.rb +34 -0
- data/lib/hpcloud/flavors.rb +40 -0
- data/lib/hpcloud/floating_ip_helper.rb +114 -0
- data/lib/hpcloud/floating_ips.rb +42 -0
- data/lib/hpcloud/fog_collection.rb +124 -0
- data/lib/hpcloud/image_helper.rb +111 -0
- data/lib/hpcloud/images.rb +43 -0
- data/lib/hpcloud/keypair_helper.rb +109 -0
- data/lib/hpcloud/keypairs.rb +41 -0
- data/lib/hpcloud/lb_algorithms.rb +37 -0
- data/lib/hpcloud/lb_limits.rb +37 -0
- data/lib/hpcloud/lb_nodes.rb +42 -0
- data/lib/hpcloud/lb_protocols.rb +37 -0
- data/lib/hpcloud/lb_versions.rb +37 -0
- data/lib/hpcloud/lb_virtualips.rb +42 -0
- data/lib/hpcloud/lbs.rb +38 -0
- data/lib/hpcloud/local_resource.rb +183 -0
- data/lib/hpcloud/log.rb +55 -0
- data/lib/hpcloud/metadata.rb +118 -0
- data/lib/hpcloud/monkey.rb +22 -0
- data/lib/hpcloud/network_helper.rb +88 -0
- data/lib/hpcloud/networks.rb +47 -0
- data/lib/hpcloud/object_store.rb +66 -0
- data/lib/hpcloud/port_helper.rb +150 -0
- data/lib/hpcloud/ports.rb +38 -0
- data/lib/hpcloud/progress.rb +53 -0
- data/lib/hpcloud/remote_resource.rb +512 -0
- data/lib/hpcloud/resource.rb +264 -0
- data/lib/hpcloud/resource_factory.rb +110 -0
- data/lib/hpcloud/routers.rb +56 -0
- data/lib/hpcloud/rule_helper.rb +70 -0
- data/lib/hpcloud/rules.rb +41 -0
- data/lib/hpcloud/security_group_helper.rb +59 -0
- data/lib/hpcloud/security_groups.rb +37 -0
- data/lib/hpcloud/server_helper.rb +318 -0
- data/lib/hpcloud/servers.rb +47 -0
- data/lib/hpcloud/shared_resource.rb +172 -0
- data/lib/hpcloud/snapshot_helper.rb +78 -0
- data/lib/hpcloud/snapshots.rb +38 -0
- data/lib/hpcloud/subnet_helper.rb +170 -0
- data/lib/hpcloud/subnets.rb +38 -0
- data/lib/hpcloud/tableizer.rb +77 -0
- data/lib/hpcloud/thor_ext/thor.rb +54 -0
- data/lib/hpcloud/time_parser.rb +47 -0
- data/lib/hpcloud/version.rb +27 -0
- data/lib/hpcloud/volume_attachment.rb +58 -0
- data/lib/hpcloud/volume_attachments.rb +58 -0
- data/lib/hpcloud/volume_helper.rb +119 -0
- data/lib/hpcloud/volumes.rb +38 -0
- data/lib/hpcloud.rb +112 -0
- data/lib/monkey/hp/lb.rb +188 -0
- data/lib/monkey/hp/models/lb/algorithm.rb +32 -0
- data/lib/monkey/hp/models/lb/algorithms.rb +46 -0
- data/lib/monkey/hp/models/lb/limit.rb +38 -0
- data/lib/monkey/hp/models/lb/limits.rb +50 -0
- data/lib/monkey/hp/models/lb/load_balancer.rb +70 -0
- data/lib/monkey/hp/models/lb/load_balancers.rb +46 -0
- data/lib/monkey/hp/models/lb/node.rb +69 -0
- data/lib/monkey/hp/models/lb/nodes.rb +47 -0
- data/lib/monkey/hp/models/lb/protocol.rb +33 -0
- data/lib/monkey/hp/models/lb/protocols.rb +46 -0
- data/lib/monkey/hp/models/lb/version.rb +34 -0
- data/lib/monkey/hp/models/lb/versions.rb +47 -0
- data/lib/monkey/hp/models/lb/virtual_ip.rb +37 -0
- data/lib/monkey/hp/models/lb/virtual_ips.rb +47 -0
- data/lib/monkey/hp/requests/lb/create_load_balancer.rb +64 -0
- data/lib/monkey/hp/requests/lb/create_load_balancer_node.rb +58 -0
- data/lib/monkey/hp/requests/lb/delete_load_balancer.rb +54 -0
- data/lib/monkey/hp/requests/lb/delete_load_balancer_node.rb +60 -0
- data/lib/monkey/hp/requests/lb/get_load_balancer.rb +88 -0
- data/lib/monkey/hp/requests/lb/get_load_balancer_node.rb +60 -0
- data/lib/monkey/hp/requests/lb/get_version.rb +68 -0
- data/lib/monkey/hp/requests/lb/get_virtual_ips.rb +48 -0
- data/lib/monkey/hp/requests/lb/list_algorithms.rb +51 -0
- data/lib/monkey/hp/requests/lb/list_limits.rb +60 -0
- data/lib/monkey/hp/requests/lb/list_load_balancer_nodes.rb +79 -0
- data/lib/monkey/hp/requests/lb/list_load_balancer_virtual_ips.rb +76 -0
- data/lib/monkey/hp/requests/lb/list_load_balancers.rb +69 -0
- data/lib/monkey/hp/requests/lb/list_protocols.rb +51 -0
- data/lib/monkey/hp/requests/lb/list_versions.rb +51 -0
- data/lib/monkey/hp/requests/lb/update_load_balancer.rb +46 -0
- data/lib/monkey/hp/requests/lb/update_load_balancer_node.rb +50 -0
- metadata +368 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
require 'hpcloud/fog_collection'
|
23
|
+
|
24
|
+
module HP
|
25
|
+
module Cloud
|
26
|
+
class LbNodes < FogCollection
|
27
|
+
def initialize(load_balancer_id)
|
28
|
+
super("load balancer node")
|
29
|
+
@items = @connection.lb.nodes({:load_balancer_id => load_balancer_id})
|
30
|
+
end
|
31
|
+
|
32
|
+
def unique(name)
|
33
|
+
super(name)
|
34
|
+
Fog::HP::LB::Node.new({:service => Connection.instance.lb})
|
35
|
+
end
|
36
|
+
|
37
|
+
def matches(arg, item)
|
38
|
+
return ((arg == item.id.to_s) || (arg == "#{item.address}:#{item.port}"))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
require 'hpcloud/fog_collection'
|
23
|
+
|
24
|
+
module HP
|
25
|
+
module Cloud
|
26
|
+
class LbProtocols < FogCollection
|
27
|
+
def initialize
|
28
|
+
super("load balancer protocol")
|
29
|
+
@items = @connection.lb.protocols
|
30
|
+
end
|
31
|
+
|
32
|
+
def matches(arg, item)
|
33
|
+
return (arg == item.name.to_s)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
require 'hpcloud/fog_collection'
|
23
|
+
|
24
|
+
module HP
|
25
|
+
module Cloud
|
26
|
+
class LbVersions < FogCollection
|
27
|
+
def initialize
|
28
|
+
super("load balancer version")
|
29
|
+
@items = @connection.lb.versions
|
30
|
+
end
|
31
|
+
|
32
|
+
def matches(arg, item)
|
33
|
+
return true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
require 'hpcloud/fog_collection'
|
23
|
+
|
24
|
+
module HP
|
25
|
+
module Cloud
|
26
|
+
class LbVirtualIps < FogCollection
|
27
|
+
def initialize(load_balancer_id)
|
28
|
+
super("load balancer virtual IPs")
|
29
|
+
@items = @connection.lb.virtual_ips({:load_balancer_id => load_balancer_id})
|
30
|
+
end
|
31
|
+
|
32
|
+
def unique(name)
|
33
|
+
super(name)
|
34
|
+
Fog::HP::LB::VirtualIps.new({:service => Connection.instance.lb})
|
35
|
+
end
|
36
|
+
|
37
|
+
def matches(arg, item)
|
38
|
+
return ((arg == item.id.to_s) || (arg == item.address.to_s))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/hpcloud/lbs.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
require 'hpcloud/fog_collection'
|
23
|
+
|
24
|
+
module HP
|
25
|
+
module Cloud
|
26
|
+
class Lbs < FogCollection
|
27
|
+
def initialize
|
28
|
+
super("load balancer")
|
29
|
+
@items = @connection.lb.load_balancers
|
30
|
+
end
|
31
|
+
|
32
|
+
def unique(name)
|
33
|
+
super(name)
|
34
|
+
Fog::HP::LB::LoadBalancer.new({:service => Connection.instance.lb})
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,183 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
module HP
|
23
|
+
module Cloud
|
24
|
+
class LocalResource < Resource
|
25
|
+
|
26
|
+
def get_size()
|
27
|
+
begin
|
28
|
+
return File.size(@fname)
|
29
|
+
rescue
|
30
|
+
return 0
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def valid_source()
|
35
|
+
if !File.exists?(@fname)
|
36
|
+
@cstatus = CliStatus.new("File not found at '#{@fname}'.", :not_found)
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
return true
|
40
|
+
end
|
41
|
+
|
42
|
+
def valid_destination(source)
|
43
|
+
if isDirectory()
|
44
|
+
dir_path = File.expand_path(@path)
|
45
|
+
else
|
46
|
+
if source.isMulti() == true
|
47
|
+
@cstatus = CliStatus.new("Invalid target for directory/multi-file copy '#{@fname}'.", :incorrect_usage)
|
48
|
+
return false
|
49
|
+
end
|
50
|
+
dir_path = File.expand_path(File.dirname(@path))
|
51
|
+
end
|
52
|
+
if !File.directory?(dir_path)
|
53
|
+
@cstatus = CliStatus.new("No directory exists at '#{dir_path}'.", :not_found)
|
54
|
+
return false
|
55
|
+
end
|
56
|
+
return true
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_destination(name)
|
60
|
+
if (@path.nil?)
|
61
|
+
@destination = name
|
62
|
+
else
|
63
|
+
@destination = File.expand_path(@path)
|
64
|
+
if isDirectory()
|
65
|
+
@destination = "#{@destination}/#{name}"
|
66
|
+
dir_path = File.dirname(File.expand_path(@destination))
|
67
|
+
else
|
68
|
+
dir_path = File.dirname(@destination)
|
69
|
+
end
|
70
|
+
if !File.directory?(dir_path)
|
71
|
+
begin
|
72
|
+
FileUtils.mkpath(dir_path)
|
73
|
+
rescue Exception => e
|
74
|
+
@cstatus = CliStatus.new("Error creating target directory '#{dir_path}'.", :general_error)
|
75
|
+
return false
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
return true
|
80
|
+
end
|
81
|
+
|
82
|
+
def open(output=false, siz=0)
|
83
|
+
close()
|
84
|
+
@lastread = 0
|
85
|
+
begin
|
86
|
+
if (output == true)
|
87
|
+
@pbar = Progress.new(@destination, siz)
|
88
|
+
@file = File.open(@destination, 'w')
|
89
|
+
else
|
90
|
+
if (@disable_pbar == false)
|
91
|
+
@pbar = Progress.new(@fname, get_size())
|
92
|
+
end
|
93
|
+
@file = File.open(@fname, 'r')
|
94
|
+
end
|
95
|
+
rescue Exception => e
|
96
|
+
@cstatus = CliStatus.new(e.to_s, :permission_denied)
|
97
|
+
return false
|
98
|
+
end
|
99
|
+
return true
|
100
|
+
end
|
101
|
+
|
102
|
+
def read(siz = Excon::CHUNK_SIZE)
|
103
|
+
@pbar.increment(@lastread) unless @pbar.nil?
|
104
|
+
if siz == 0
|
105
|
+
@lastread = 0
|
106
|
+
return ''
|
107
|
+
end
|
108
|
+
val = @file.read(siz).to_s
|
109
|
+
@lastread = val.length
|
110
|
+
return val
|
111
|
+
end
|
112
|
+
|
113
|
+
def write(data)
|
114
|
+
@pbar.increment(data.length) unless @pbar.nil?
|
115
|
+
@file.write(data)
|
116
|
+
return true
|
117
|
+
end
|
118
|
+
|
119
|
+
def close()
|
120
|
+
@pbar.increment(@lastread) unless @pbar.nil?
|
121
|
+
@pbar.finish unless @pbar.nil?
|
122
|
+
@lastread = 0
|
123
|
+
@pbar = nil
|
124
|
+
@file.close unless @file.nil?
|
125
|
+
@file = nil
|
126
|
+
return true
|
127
|
+
end
|
128
|
+
|
129
|
+
def copy_file(from)
|
130
|
+
if from.isLocal()
|
131
|
+
@disable_pbar = true
|
132
|
+
end
|
133
|
+
|
134
|
+
return false unless open(true, from.get_size())
|
135
|
+
|
136
|
+
result = true
|
137
|
+
if from.isLocal()
|
138
|
+
if (from.open() == true)
|
139
|
+
while ((chunk = from.read()) != nil) do
|
140
|
+
if chunk.empty?
|
141
|
+
break
|
142
|
+
end
|
143
|
+
if ! write(chunk.to_s) then result = false end
|
144
|
+
end
|
145
|
+
result = false if ! from.close()
|
146
|
+
else
|
147
|
+
result = false
|
148
|
+
end
|
149
|
+
else
|
150
|
+
from.read() { |chunk|
|
151
|
+
if ! write(chunk)
|
152
|
+
result = false
|
153
|
+
break
|
154
|
+
end
|
155
|
+
}
|
156
|
+
result = false unless from.close()
|
157
|
+
unless from.is_valid?
|
158
|
+
set_error(from)
|
159
|
+
result = false
|
160
|
+
end
|
161
|
+
end
|
162
|
+
return false unless close()
|
163
|
+
return result
|
164
|
+
end
|
165
|
+
|
166
|
+
def foreach(&block)
|
167
|
+
if (isDirectory() == false)
|
168
|
+
yield self
|
169
|
+
return
|
170
|
+
end
|
171
|
+
begin
|
172
|
+
Dir.foreach(path) { |x|
|
173
|
+
if ((x != '.') && (x != '..')) then
|
174
|
+
ResourceFactory.create_any(@storage, path + '/' + x).foreach(&block)
|
175
|
+
end
|
176
|
+
}
|
177
|
+
rescue Errno::EACCES
|
178
|
+
@cstatus = CliStatus.new("You don't have permission to access '#{path}'.", :permission_denied)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
data/lib/hpcloud/log.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
module HP
|
23
|
+
module Cloud
|
24
|
+
class Log
|
25
|
+
def initialize(shell)
|
26
|
+
@silence_display = nil
|
27
|
+
@shell = shell
|
28
|
+
end
|
29
|
+
|
30
|
+
def fatal(err, exit_status = :general_error)
|
31
|
+
error(err, exit_status)
|
32
|
+
exit @shell.exit_status.get
|
33
|
+
end
|
34
|
+
|
35
|
+
def error(err, exit_status = :general_error)
|
36
|
+
if err.kind_of?(String)
|
37
|
+
message = err
|
38
|
+
else
|
39
|
+
if err.kind_of?(CliStatus)
|
40
|
+
exit_status = err.error_code
|
41
|
+
message = err.to_s
|
42
|
+
else
|
43
|
+
message = ErrorResponse.new(err).to_s
|
44
|
+
end
|
45
|
+
end
|
46
|
+
$stderr.puts message
|
47
|
+
@shell.exit_status.set(exit_status)
|
48
|
+
end
|
49
|
+
|
50
|
+
def display(message)
|
51
|
+
@shell.say message unless @silence_display
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
require 'csv'
|
23
|
+
|
24
|
+
module HP
|
25
|
+
module Cloud
|
26
|
+
class Metadata
|
27
|
+
attr_reader :cstatus, :hsh
|
28
|
+
|
29
|
+
def self.get_keys()
|
30
|
+
return [ "key", "value" ]
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(mta = nil)
|
34
|
+
@cstatus = CliStatus.new
|
35
|
+
@fog_metadata = mta
|
36
|
+
@hsh = {}
|
37
|
+
if mta.nil?
|
38
|
+
return
|
39
|
+
end
|
40
|
+
mta.map { |m| @hsh["#{m.key}"] = "#{m.value}" }
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_array()
|
44
|
+
ray = []
|
45
|
+
@hsh.each { |k,v| ray << {"key"=>k,"value"=>v} }
|
46
|
+
ray.sort!{|a, b| a["key"] <=> b["key"]}
|
47
|
+
return ray
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_metadata(value)
|
51
|
+
if value.nil?
|
52
|
+
return true
|
53
|
+
end
|
54
|
+
if value.empty?
|
55
|
+
@hsh = {}
|
56
|
+
return true
|
57
|
+
end
|
58
|
+
begin
|
59
|
+
hshstr = '{"' + value.gsub('=', '"=>"').gsub(',', '","') + '"}'
|
60
|
+
hsh = eval(hshstr)
|
61
|
+
if (hsh.kind_of? Hash)
|
62
|
+
@hsh = hsh
|
63
|
+
unless @fog_metadata.nil?
|
64
|
+
@hsh.each { |k,v|
|
65
|
+
pair = @fog_metadata.get(k)
|
66
|
+
if pair.nil?
|
67
|
+
pair = @fog_metadata.new
|
68
|
+
pair.key = k
|
69
|
+
pair.value = v
|
70
|
+
else
|
71
|
+
pair.value = v
|
72
|
+
end
|
73
|
+
pair.save
|
74
|
+
}
|
75
|
+
end
|
76
|
+
return true
|
77
|
+
end
|
78
|
+
rescue SyntaxError => se
|
79
|
+
rescue NameError => ne
|
80
|
+
end
|
81
|
+
@cstatus = CliStatus.new("Invalid metadata '#{value}' should be in the form 'k1=v1,k2=v2,...'", :incorrect_usage)
|
82
|
+
return false
|
83
|
+
end
|
84
|
+
|
85
|
+
def remove_metadata(key)
|
86
|
+
pair = nil
|
87
|
+
if ! @fog_metadata.nil?
|
88
|
+
pair = @fog_metadata.get(key)
|
89
|
+
end
|
90
|
+
if pair.nil?
|
91
|
+
@cstatus = CliStatus.new("Metadata key '#{key}' not found", :not_found)
|
92
|
+
else
|
93
|
+
begin
|
94
|
+
pair.destroy
|
95
|
+
rescue Exception => e
|
96
|
+
@cstatus = CliStatus.new("Error deleting metadata '#{key}': " + e.message)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
if @cstatus.is_success?
|
100
|
+
return true
|
101
|
+
end
|
102
|
+
return false
|
103
|
+
end
|
104
|
+
|
105
|
+
def to_s
|
106
|
+
found=false
|
107
|
+
metadata=""
|
108
|
+
ray = to_array()
|
109
|
+
ray.each { |val|
|
110
|
+
metadata << "," unless found == false
|
111
|
+
metadata << val["key"].to_s + "=" + val["value"].to_s
|
112
|
+
found = true
|
113
|
+
}
|
114
|
+
return metadata
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
require 'monkey/hp/lb'
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
module HP
|
23
|
+
module Cloud
|
24
|
+
class NetworkHelper < BaseHelper
|
25
|
+
attr_accessor :id, :name, :tenant_id, :status, :subnets, :subnets_array
|
26
|
+
attr_accessor :shared, :admin_state_up, :router_external
|
27
|
+
attr_accessor :admin_state
|
28
|
+
|
29
|
+
def self.get_keys()
|
30
|
+
return [ "id", "name", "status", "shared", "admin_state", "subnets" ]
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(connection, foggy = nil)
|
34
|
+
super(connection, foggy)
|
35
|
+
@shared = false
|
36
|
+
@admin_state_up = true
|
37
|
+
if foggy.nil?
|
38
|
+
return
|
39
|
+
end
|
40
|
+
@id = foggy.id
|
41
|
+
@name = foggy.name
|
42
|
+
@tenant_id = foggy.tenant_id
|
43
|
+
@status = foggy.status
|
44
|
+
@shared = foggy.shared
|
45
|
+
@admin_state_up = foggy.admin_state_up
|
46
|
+
@admin_state = foggy.admin_state_up ? "up" : "down"
|
47
|
+
@subnets_array = foggy.subnets
|
48
|
+
@subnets = ''
|
49
|
+
unless foggy.subnets.nil?
|
50
|
+
foggy.subnets.each{ |x|
|
51
|
+
@subnets = ',' unless @subnets.empty?
|
52
|
+
@subnets = x.id.to_s
|
53
|
+
}
|
54
|
+
end
|
55
|
+
@router_external = foggy.router_external
|
56
|
+
end
|
57
|
+
|
58
|
+
def save
|
59
|
+
return false if is_valid? == false
|
60
|
+
hsh = {:name => @name,
|
61
|
+
:tenant_id => @tenant_id,
|
62
|
+
:shared => @shared.to_s,
|
63
|
+
:admin_state_up => @admin_state_up.to_s}
|
64
|
+
if @fog.nil?
|
65
|
+
response = @connection.network.create_network(hsh)
|
66
|
+
if response.nil?
|
67
|
+
set_error("Error creating network '#{@name}'")
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
@id = response.body["network"]["id"]
|
71
|
+
@status = response.body["network"]["status"]
|
72
|
+
@foggy = response.body["network"]
|
73
|
+
else
|
74
|
+
response = @connection.network.update_network(@id, hsh)
|
75
|
+
if response.nil?
|
76
|
+
set_error("Error updating network '#{@name}'")
|
77
|
+
return false
|
78
|
+
end
|
79
|
+
end
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
|
83
|
+
def destroy
|
84
|
+
@connection.network.delete_network(@id)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|