ovirt_provision_plugin 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e34e8751197c85879b4acac702f27280b47023c2
4
- data.tar.gz: 8ee48580f600641e1c93a61f09f8e88a6fed7c9d
3
+ metadata.gz: 349e41ad4b8e953c3c5c38f924b80cf21d37aef7
4
+ data.tar.gz: 44b74a82562056d07be2703ba5ebe466dfaa8981
5
5
  SHA512:
6
- metadata.gz: 6ef825d15128bdcb0d70e8e0ea1ad86f0f72cd18ad0a4ac303d62e26f7cbc10abfebb6e686d290f76063a1985d74d8e57c086878f0c48d5771241bbd73e987a9
7
- data.tar.gz: 50984c1d0ab8c1aff730d8b8e2481a41f7fc4c35a8a16237a2b36e24f0d385bfb333fc50ad5f20435f1eb5fb47ad5eebd2e0aaf4fad9576f30a4c85b621a7630
6
+ metadata.gz: d8093c48083014eeac5d0ea827b9dbc87d825e5647a621cc8ae7e169ae53a5d29bbaa10b2be6d36075f48ca5df3b8f2541513dda507f4f67b73591b1a681b201
7
+ data.tar.gz: 7fb9fe49575241a618cb070648a9e193ba39441313da9d26c1f42aa65afb3a8a684f358e43adbd11c2930c69f9c58ed5d381b44b7b05d6457b5fb05cf98f738c
@@ -3,25 +3,25 @@ module OvirtProvisionPlugin
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  def ovirt_host_callback
6
- logger.debug "OvirtProvisionPlugin:: Running provision callback.."
6
+ logger.info "OvirtProvisionPlugin:: Running provision callback.."
7
7
  max_tries = 10;
8
8
  if self.is_ovirt_node?
9
- logger.debug "OvirtProvisionPlugin:: Node provisioning is done."
9
+ logger.info "OvirtProvisionPlugin:: Node provisioning is done."
10
10
  else
11
11
  while max_tries > 0 && self.ovirt_host? && self.status_installing?
12
12
  if (self.error?)
13
- logger.debug "OvirtProvisionPlugin:: Failed to run classes. Trying again (#{max_tries})"
13
+ logger.warn "OvirtProvisionPlugin:: Failed to run classes. Trying again (#{max_tries})"
14
14
  puppetrun!
15
15
  max_tries = max_tries - 1
16
16
  else
17
17
  begin
18
- logger.debug "OvirtProvisionPlugin:: Running ovirt_host_callback on \"#{self.get_ovirt_host_name}\""
18
+ logger.info "OvirtProvisionPlugin:: Running ovirt_host_callback on \"#{self.get_ovirt_host_name}\""
19
19
  host_id = self.get_ovirt_host_id
20
20
  client = self.get_ovirt_client
21
21
  client.reinstall_host("#{host_id}")
22
- logger.debug "OvirtProvisionPlugin:: Sent reinstall command successfully"
22
+ logger.info "OvirtProvisionPlugin:: Sent reinstall command successfully"
23
23
  rescue OVIRT::OvirtException
24
- logger.debug "OvirtProvisionPlugin:: Failed to reinstall host. Trying again (#{max_tries})"
24
+ logger.warn "OvirtProvisionPlugin:: Failed to reinstall host. Trying again (#{max_tries})"
25
25
  puppetrun!
26
26
  max_tries = max_tries - 1
27
27
  end
@@ -33,7 +33,7 @@ module OvirtProvisionPlugin
33
33
  def is_ovirt_node?
34
34
  is_ovirt_node = self.operatingsystem.name == "oVirt-Node" or self.operatingsystem.name == "RHEV-H"
35
35
  if is_ovirt_node
36
- logger.debug "OvirtProvisionPlugin:: Provisioned ovirt node host"
36
+ logger.info "OvirtProvisionPlugin:: Provisioned ovirt node host"
37
37
  return true
38
38
  end
39
39
  return false
@@ -41,7 +41,7 @@ module OvirtProvisionPlugin
41
41
 
42
42
  def ovirt_host?
43
43
  if self.get_ovirt_host_id
44
- logger.debug "OvirtProvisionPlugin:: host related to oVirt"
44
+ logger.info "OvirtProvisionPlugin:: host related to oVirt"
45
45
  return true
46
46
  end
47
47
  return false
@@ -50,61 +50,66 @@ module OvirtProvisionPlugin
50
50
  def status_installing?
51
51
  h = self.get_ovirt_host
52
52
  if h != "" && h.status.strip == "installing_os"
53
- logger.debug "OvirtProvisionPlugin:: host in status installing"
53
+ logger.info "OvirtProvisionPlugin:: host in status installing"
54
54
  return true
55
55
  end
56
56
  return false
57
57
  end
58
58
 
59
59
  def get_ovirt_client
60
- begin
61
- cr_id = parameters.find_by_name("compute_resource_id").value
62
- cr = ComputeResource.find_by_id(cr_id)
63
- return OVIRT::Client.new("#{cr.user}", "#{cr.password}", "#{cr.url}")
64
- rescue OVIRT::OvirtException
65
- logger.debug "OvirtProvisionPlugin:: compute resource id was not found"
66
- return false
67
- rescue NoMethodError
68
- logger.debug "OvirtProvisionPlugin:: fail to read compute_rescource_id on host #{self.name}, id #{cr_id}"
69
- return false
70
- else
71
- logger.debug "OvirtProvisionPlugin:: error occured during get_ovirt_client"
72
- return false
60
+ begin
61
+ cr_id = parameters.find_by_name("compute_resource_id").value
62
+ cr = ComputeResource.find_by_id(cr_id)
63
+ connection_opts = {}
64
+ if not cr.public_key.blank?
65
+ connection_opts[:datacenter_id] = cr.uuid
66
+ connection_opts[:ca_cert_store] = OpenSSL::X509::Store.new.add_cert(OpenSSL::X509::Certificate.new(cr.public_key))
73
67
  end
68
+ return OVIRT::Client.new("#{cr.user}", "#{cr.password}", "#{cr.url}", connection_opts)
69
+ rescue OVIRT::OvirtException
70
+ logger.error "OvirtProvisionPlugin:: compute resource id was not found"
71
+ return false
72
+ rescue NoMethodError
73
+ logger.error "OvirtProvisionPlugin:: fail to read compute_rescource_id on host #{self.name}, id #{cr_id}"
74
+ return false
75
+ else
76
+ logger.error "OvirtProvisionPlugin:: error occured during get_ovirt_client"
77
+ return false
78
+ end
74
79
  end
75
80
 
76
81
  def get_ovirt_host
77
- client = self.get_ovirt_client
78
- if not client
79
- logger.debug "OvirtProvisionPlugin:: couldn't get ovirt_host"
80
- return ""
81
- else
82
- return client.host(get_ovirt_host_id)
83
- end
82
+ client = self.get_ovirt_client
83
+ if not client
84
+ logger.error "OvirtProvisionPlugin:: couldn't get ovirt_host"
85
+ return ""
86
+ else
87
+ return client.host(get_ovirt_host_id)
88
+ end
84
89
  end
85
90
 
86
91
  def get_ovirt_host_name
87
- h = self.get_ovirt_host
88
- if not h
89
- return ""
90
- else
91
- return h.name
92
- end
92
+ h = self.get_ovirt_host
93
+ if not h
94
+ return ""
95
+ else
96
+ return h.name
97
+ end
93
98
  end
94
99
 
95
100
  def get_ovirt_host_id
96
- begin
97
- return self.parameters.find_by_name("host_ovirt_id").value
98
- rescue OVIRT::OvirtException
99
- logger.debug "OvirtProvisionPlugin:: host ovirt id was not found"
100
- return false
101
- rescue NoMethodError
102
- logger.debug "OvirtProvisionPlugin:: fail to read host_ovirt_id on host #{self.name}"
103
- return false
104
- else
105
- logger.debug "OvirtProvisionPlugin:: error occured during get_ovirt_host_id"
106
- return false
107
- end
101
+ begin
102
+ return self.parameters.find_by_name("host_ovirt_id").value
103
+ rescue OVIRT::OvirtException
104
+ logger.error "OvirtProvisionPlugin:: host ovirt id was not found"
105
+ return false
106
+ rescue NoMethodError
107
+ logger.error "OvirtProvisionPlugin:: fail to read host_ovirt_id on host #{self.name}"
108
+ return false
109
+ else
110
+ logger.error "OvirtProvisionPlugin:: error occured during get_ovirt_host_id"
111
+ return false
112
+ end
108
113
  end
109
114
  end
110
115
  end
@@ -1,3 +1,3 @@
1
1
  module OvirtProvisionPlugin
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ovirt_provision_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaniv Bronhaim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-04 00:00:00.000000000 Z
11
+ date: 2014-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface