knife-cloudstack-fog 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,53 +1,53 @@
1
- # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
- # Copyright:: Copyright (c) 2013 Datapipe
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackNetworkDelete < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack network delete ID"
28
-
29
-
30
- def run
31
- if @name_args.nil?
32
- puts #{ui.color("Please provide a network ID.", :red)}
33
- end
34
-
35
- @name_args.each do |network_id|
36
- response = connection.list_networks('id' => network_id)
37
-
38
- apiresponse = response['listnetworksresponse']
39
- network = apiresponse['network']
40
- Chef::Log.debug("Network: #{network}")
41
- network_name = network[0]['name'].to_s
42
- network_display = network[0]['displaytext'].to_s
43
- puts "#{ui.color("Name", :red)}: #{network_name}"
44
- puts "#{ui.color("Display Text", :red)}: #{network_display}"
45
- puts "\n"
46
- confirm("#{ui.color("Do you really want to delete this network?", :red)}")
47
- connection.delete_network(network_id)
48
- ui.warn("Deleted network #{network_name}")
49
- end
50
- end
51
- end
52
- end
53
- end
1
+ # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
+ # Copyright:: Copyright (c) 2013 Datapipe
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackNetworkDelete < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack network delete ID"
28
+
29
+
30
+ def run
31
+ if @name_args.nil? || @name_args.empty?
32
+ puts "#{ui.color("Please provide a network ID.", :red)}"
33
+ end
34
+
35
+ @name_args.each do |network_id|
36
+ response = connection.list_networks('id' => network_id)
37
+
38
+ apiresponse = response['listnetworksresponse']
39
+ network = apiresponse['network']
40
+ Chef::Log.debug("Network: #{network}")
41
+ network_name = network[0]['name'].to_s
42
+ network_display = network[0]['displaytext'].to_s
43
+ puts "#{ui.color("Name", :red)}: #{network_name}"
44
+ puts "#{ui.color("Display Text", :red)}: #{network_display}"
45
+ puts "\n"
46
+ confirm("#{ui.color("Do you really want to delete this network?", :red)}")
47
+ connection.delete_network(network_id)
48
+ ui.warn("Deleted network #{network_name}")
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,67 +1,67 @@
1
- # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
- # Copyright:: Copyright (c) 2012 Datapipe
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackNetworkList < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack network list"
28
-
29
- def run
30
- $stdout.sync = true
31
-
32
- validate!
33
-
34
- network_list = [
35
- ui.color('ID', :bold),
36
- ui.color('Name', :bold),
37
- ui.color('Zone ID', :bold),
38
- ui.color('VLAN', :bold),
39
- ui.color('State', :bold)
40
- ]
41
- response = connection.list_networks['listnetworksresponse']
42
- if networks = response['network']
43
- networks.each do |network|
44
- network_list << network['id'].to_s
45
- network_list << network['name'].to_s
46
- network_list << network['zoneid'].to_s
47
- network_list << network['vlan'].to_s
48
- network_list << begin
49
- state = network['state'].to_s.downcase
50
- case state
51
- when 'allocated'
52
- ui.color(state, :red)
53
- when 'pending'
54
- ui.color(state, :yellow)
55
- else
56
- ui.color(state, :green)
57
- end
58
- end
59
- end
60
- end
61
- puts ui.list(network_list, :columns_across, 5)
62
-
63
- end
64
-
65
- end
66
- end
67
- end
1
+ # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
+ # Copyright:: Copyright (c) 2012 Datapipe
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackNetworkList < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack network list"
28
+
29
+ def run
30
+ $stdout.sync = true
31
+
32
+ validate!
33
+
34
+ network_list = [
35
+ ui.color('ID', :bold),
36
+ ui.color('Name', :bold),
37
+ ui.color('Zone ID', :bold),
38
+ ui.color('VLAN', :bold),
39
+ ui.color('State', :bold)
40
+ ]
41
+ response = connection.list_networks['listnetworksresponse']
42
+ if networks = response['network']
43
+ networks.each do |network|
44
+ network_list << network['id'].to_s
45
+ network_list << network['name'].to_s
46
+ network_list << network['zoneid'].to_s
47
+ network_list << network['vlan'].to_s
48
+ network_list << begin
49
+ state = network['state'].to_s.downcase
50
+ case state
51
+ when 'allocated'
52
+ ui.color(state, :red)
53
+ when 'pending'
54
+ ui.color(state, :yellow)
55
+ else
56
+ ui.color(state, :green)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ puts ui.list(network_list, :columns_across, 5)
62
+
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -1,74 +1,74 @@
1
- # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
- # Copyright:: Copyright (c) 2012 Datapipe
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackNetworkofferingList < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack networkoffering list"
28
-
29
- def run
30
- $stdout.sync = true
31
-
32
- validate!
33
-
34
- network_list = [
35
- ui.color('ID', :bold),
36
- ui.color('Name', :bold),
37
- ui.color('Display Name', :bold),
38
- ui.color('Traffic Type', :bold),
39
- ui.color('State', :bold),
40
- ui.color('Service Offering ID', :bold)
41
- ]
42
-
43
- response = connection.list_network_offerings['listnetworkofferingsresponse']
44
-
45
- if networks = response['networkoffering']
46
-
47
- networks.each do |networkoffering|
48
- # puts networkoffering
49
- network_list << networkoffering['id'].to_s
50
- network_list << networkoffering['name'].to_s
51
- network_list << networkoffering['displaytext'].to_s
52
- network_list << networkoffering['traffictype'].to_s
53
- network_list << begin
54
- state = networkoffering['state'].to_s.downcase
55
- case state
56
- when 'allocated'
57
- ui.color(state, :red)
58
- when 'pending'
59
- ui.color(state, :yellow)
60
- else
61
- ui.color(state, :green)
62
- end
63
- end
64
- network_list << networkoffering['serviceofferingid'].to_s
65
- end
66
- end
67
-
68
- puts ui.list(network_list, :uneven_columns_across, 6)
69
-
70
- end
71
-
72
- end
73
- end
74
- end
1
+ # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
+ # Copyright:: Copyright (c) 2012 Datapipe
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackNetworkofferingList < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack networkoffering list"
28
+
29
+ def run
30
+ $stdout.sync = true
31
+
32
+ validate!
33
+
34
+ network_list = [
35
+ ui.color('ID', :bold),
36
+ ui.color('Name', :bold),
37
+ ui.color('Display Name', :bold),
38
+ ui.color('Traffic Type', :bold),
39
+ ui.color('State', :bold),
40
+ ui.color('Service Offering ID', :bold)
41
+ ]
42
+
43
+ response = connection.list_network_offerings['listnetworkofferingsresponse']
44
+
45
+ if networks = response['networkoffering']
46
+
47
+ networks.each do |networkoffering|
48
+ # puts networkoffering
49
+ network_list << networkoffering['id'].to_s
50
+ network_list << networkoffering['name'].to_s
51
+ network_list << networkoffering['displaytext'].to_s
52
+ network_list << networkoffering['traffictype'].to_s
53
+ network_list << begin
54
+ state = networkoffering['state'].to_s.downcase
55
+ case state
56
+ when 'allocated'
57
+ ui.color(state, :red)
58
+ when 'pending'
59
+ ui.color(state, :yellow)
60
+ else
61
+ ui.color(state, :green)
62
+ end
63
+ end
64
+ network_list << networkoffering['serviceofferingid'].to_s
65
+ end
66
+ end
67
+
68
+ puts ui.list(network_list, :uneven_columns_across, 6)
69
+
70
+ end
71
+
72
+ end
73
+ end
74
+ end
@@ -1,90 +1,90 @@
1
- # Author:: Takashi Kanai (<anikundesu@gmail.com>)
2
- # Copyright:: Copyright (c) 2012 IDC Frontier Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackPublicipCreate < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack publicip create (options)"
28
-
29
- option :zoneid,
30
- :short => "-z ZONEID",
31
- :long => "--zoneid ZONEID",
32
- :description => "[REQUIRED]The CloudStack zone ID to create new public IP."
33
-
34
- option :networkid,
35
- :long => "--network-id NETWORKID",
36
- :description => "[OPTIONAL]The CloudStack network ID to crate new public IP."
37
-
38
- def run
39
- $stdout.sync = true
40
-
41
- validate!
42
-
43
- options = {}
44
-
45
- if locate_config_value(:networkid) != nil
46
- options['networkid']=locate_config_value(:networkid)
47
- end
48
-
49
- if locate_config_value(:zoneid) != nil
50
- options['zoneid']=locate_config_value(:zoneid)
51
-
52
- publicip_list = [
53
- ui.color('ID', :bold),
54
- ui.color('ipaddress', :bold),
55
- ui.color('isSourceNAT', :bold),
56
- ui.color('isStaticNAT', :bold)
57
- ]
58
-
59
- response = connection.acquire_ip_address(options)
60
- publicipid = response['associateipaddressresponse']['id']
61
- jobid = response['associateipaddressresponse'].fetch('jobid')
62
-
63
- publicip_assign = connection.query_async_job_result('jobid'=>jobid)
64
- print "#{ui.color("Waiting for assigning Public IP", :magenta)}"
65
- while publicip_assign['queryasyncjobresultresponse'].fetch('jobstatus') != 1
66
- print "#{ui.color(".", :magenta)}"
67
- sleep(5)
68
- publicip_assign = connection.query_async_job_result('jobid'=>jobid)
69
- end
70
- puts "\n\n"
71
-
72
- publicip_assign = connection.query_async_job_result('jobid'=>jobid)
73
- publicip = publicip_assign['queryasyncjobresultresponse']['jobresult']['ipaddress']
74
-
75
- publicip_list << publicip['id'].to_s
76
- publicip_list << publicip['ipaddress'].to_s
77
- publicip_list << publicip['issourcenat'].to_s
78
- publicip_list << publicip['isstaticnat'].to_s
79
-
80
- puts ui.list(publicip_list, :columns_across, 4)
81
-
82
- else
83
- puts 'Error. Missing Zone ID (-z).'
84
- end
85
-
86
- end
87
-
88
- end
89
- end
90
- end
1
+ # Author:: Takashi Kanai (<anikundesu@gmail.com>)
2
+ # Copyright:: Copyright (c) 2012 IDC Frontier Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackPublicipCreate < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack publicip create (options)"
28
+
29
+ option :zoneid,
30
+ :short => "-z ZONEID",
31
+ :long => "--zoneid ZONEID",
32
+ :description => "[REQUIRED]The CloudStack zone ID to create new public IP."
33
+
34
+ option :networkid,
35
+ :long => "--network-id NETWORKID",
36
+ :description => "[OPTIONAL]The CloudStack network ID to crate new public IP."
37
+
38
+ def run
39
+ $stdout.sync = true
40
+
41
+ validate!
42
+
43
+ options = {}
44
+
45
+ if locate_config_value(:networkid) != nil
46
+ options['networkid']=locate_config_value(:networkid)
47
+ end
48
+
49
+ if locate_config_value(:zoneid) != nil
50
+ options['zoneid']=locate_config_value(:zoneid)
51
+
52
+ publicip_list = [
53
+ ui.color('ID', :bold),
54
+ ui.color('ipaddress', :bold),
55
+ ui.color('isSourceNAT', :bold),
56
+ ui.color('isStaticNAT', :bold)
57
+ ]
58
+
59
+ response = connection.acquire_ip_address(options)
60
+ publicipid = response['associateipaddressresponse']['id']
61
+ jobid = response['associateipaddressresponse'].fetch('jobid')
62
+
63
+ publicip_assign = connection.query_async_job_result('jobid'=>jobid)
64
+ print "#{ui.color("Waiting for assigning Public IP", :magenta)}"
65
+ while publicip_assign['queryasyncjobresultresponse'].fetch('jobstatus') != 1
66
+ print "#{ui.color(".", :magenta)}"
67
+ sleep(5)
68
+ publicip_assign = connection.query_async_job_result('jobid'=>jobid)
69
+ end
70
+ puts "\n\n"
71
+
72
+ publicip_assign = connection.query_async_job_result('jobid'=>jobid)
73
+ publicip = publicip_assign['queryasyncjobresultresponse']['jobresult']['ipaddress']
74
+
75
+ publicip_list << publicip['id'].to_s
76
+ publicip_list << publicip['ipaddress'].to_s
77
+ publicip_list << publicip['issourcenat'].to_s
78
+ publicip_list << publicip['isstaticnat'].to_s
79
+
80
+ puts ui.list(publicip_list, :columns_across, 4)
81
+
82
+ else
83
+ puts 'Error. Missing Zone ID (-z).'
84
+ end
85
+
86
+ end
87
+
88
+ end
89
+ end
90
+ end