Class: Azure::Deploys
- Inherits:
-
Object
- Object
- Azure::Deploys
- Includes:
- AzureUtility
- Defined in:
- lib/azure/service_management/deploy.rb
Instance Method Summary collapse
- #all ⇒ Object
- #create(params) ⇒ Object
- #delete(rolename) ⇒ Object
-
#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).
-
#initialize(connection) ⇒ Deploys
constructor
A new instance of Deploys.
-
#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.
- #queryDeploy(hostedservicename) ⇒ Object
Methods included from AzureUtility
#error_from_response_xml, #xml_content
Constructor Details
#initialize(connection) ⇒ Deploys
Returns a new instance of Deploys.
22 23 24 |
# File 'lib/azure/service_management/deploy.rb', line 22 def initialize(connection) @connection = connection end |
Instance Method Details
#all ⇒ Object
47 48 49 |
# File 'lib/azure/service_management/deploy.rb', line 47 def all load end |
#create(params) ⇒ Object
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 100 101 102 103 104 105 106 107 |
# File 'lib/azure/service_management/deploy.rb', line 62 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_from_response_xml(ret_val) if error_code.length > 0 Chef::Log.fatal "Unable to create DNS:" + error_code + " : " + exit 1 end end unless @connection.storageaccounts.exists?(params[:azure_storage_account]) @connection.storageaccounts.create(params) end if params[:ssh_identity_file] params[:fingerprint] = @connection.certificates.create(params) end if params[:cert_path] cert_data = File.read (params[:cert_path]) @connection.certificates.add cert_data, params[:cert_password], "pfx", params[:azure_dns_name] elsif params[:winrm_ssl] # TODO: generate certificates for ssl listener 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_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 + " : " + end @connection.roles.find_in_hosted_service(params[:azure_vm_name], params[:azure_dns_name]) end |
#delete(rolename) ⇒ Object
109 |
# File 'lib/azure/service_management/deploy.rb', line 109 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
53 54 55 56 57 58 59 60 |
# File 'lib/azure/service_management/deploy.rb', line 53 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.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/azure/service_management/deploy.rb', line 28 def load(force_load = false) unless @deploys || force_load @deploys = begin deploys = [] 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 |