Class: Azure::Deploys
Instance Method Summary
collapse
#error_from_response_xml, #xml_content
Constructor Details
#initialize(connection) ⇒ Deploys
22
23
24
|
# File 'lib/azure/deploy.rb', line 22
def initialize(connection)
@connection=connection
end
|
Instance Method Details
#all ⇒ Object
46
47
48
|
# File 'lib/azure/deploy.rb', line 46
def all
self.load
end
|
#create(params) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/azure/deploy.rb', line 61
def create(params)
if params[:azure_connect_to_existing_dns]
unless @connection.hosts.exists?(params[:azure_dns_name])
Chef::Log.fatal 'The specified Azure DNS Name does not exist.'
exit 1
end
else
ret_val = @connection.hosts.create(params)
error_code, error_message = error_from_response_xml(ret_val)
if error_code.length > 0
Chef::Log.fatal 'Unable to create DNS:' + error_code + ' : ' + error_message
exit 1
end
end
unless @connection.storageaccounts.exists?(params[:azure_storage_account])
@connection.storageaccounts.create(params)
end
if params[:identity_file]
params[:fingerprint] = @connection.certificates.create(params)
end
params['deploy_name'] = get_deploy_name_for_hostedservice(params[:azure_dns_name])
if params['deploy_name'] != nil
role = Role.new(@connection)
roleXML = role.setup(params)
ret_val = role.create(params, roleXML)
else
params['deploy_name'] = params[:azure_dns_name]
deploy = Deploy.new(@connection)
deployXML = deploy.setup(params)
ret_val = deploy.create(params, deployXML)
end
error_code, error_message = error_from_response_xml(ret_val)
if error_code.length > 0
Chef::Log.debug(ret_val.to_s)
raise Chef::Log.fatal 'Unable to create role:' + error_code + ' : ' + error_message
end
@connection.roles.find_in_hosted_service(params[:azure_vm_name], params[:azure_dns_name])
end
|
#delete(rolename) ⇒ Object
100
101
|
# File 'lib/azure/deploy.rb', line 100
def delete(rolename)
end
|
#get_deploy_name_for_hostedservice(hostedservicename) ⇒ Object
TODO - Current knife-azure plug-in seems to have assumption that single hostedservice will always have one deployment (production). see Deploy#retrieve below
52
53
54
55
56
57
58
59
|
# File 'lib/azure/deploy.rb', line 52
def get_deploy_name_for_hostedservice(hostedservicename)
host = @connection.hosts.find(hostedservicename)
if host && host.deploys.length > 0
host.deploys[0].name
else
nil
end
end
|
#load(force_load = false) ⇒ Object
force_load should be true when there is something in local cache and we want to reload first call is always load.
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/azure/deploy.rb', line 27
def load(force_load = false)
if not @deploys || force_load
@deploys = begin
deploys = Array.new
hosts = @connection.hosts.all
hosts.each do |host|
deploy = Deploy.new(@connection)
deploy.retrieve(host.name)
if deploy.name
host.add_deploy(deploy)
deploys << deploy
end
end
deploys
end
end
@deploys
end
|
#queryDeploy(hostedservicename) ⇒ Object
103
104
105
106
107
|
# File 'lib/azure/deploy.rb', line 103
def queryDeploy(hostedservicename)
deploy = Deploy.new(@connection)
deploy.retrieve(hostedservicename)
deploy
end
|