Esempio n. 1
0
        private void UpdateCSDEF()
        {
            string normalizedRoleName = this.RoleName.ToUpperInvariant();

            ServiceDefinitionSchema.ServiceDefinition destCSDEF = SerializationUtils.DeserializeXmlFile <ServiceDefinitionSchema.ServiceDefinition>(ServiceCSDEFFile);

            if (destCSDEF.WebRole != null)
            {
                //Check if destination csdef already has a role.
                ServiceDefinitionSchema.WebRole roleToAddInDestCSDEF = destCSDEF.WebRole.Where(eachRole => eachRole.name.ToUpperInvariant() == normalizedRoleName).FirstOrDefault();
                //If found just update VMSize and exit.
                if (roleToAddInDestCSDEF != null)
                {
                    roleToAddInDestCSDEF.vmsize = this.VMSize == null ? roleToAddInDestCSDEF.vmsize : this.VMSize.Value;
                    SerializationUtils.SerializeXmlFile <ServiceDefinitionSchema.ServiceDefinition>(destCSDEF, ServiceCSDEFFile);
                    WriteObject(string.Format(CultureInfo.InvariantCulture, Resources.RoleAlreadyPresentInCSDEF, this.RoleName, roleToAddInDestCSDEF.vmsize.ToString()));
                    return;
                }
            }

            ServiceDefinitionSchema.ServiceDefinition sourceCSDEF = SerializationUtils.DeserializeXmlFile <ServiceDefinitionSchema.ServiceDefinition>(CsdefFile);
            if (sourceCSDEF.WebRole == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.RoleNotFoundInCSDEF, this.RoleName));
            }

            ServiceDefinitionSchema.WebRole roleToAdd = sourceCSDEF.WebRole.Where(eachRole => eachRole.name.ToUpperInvariant() == normalizedRoleName).FirstOrDefault();
            if (roleToAdd == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.RoleNotFoundInCSDEF, this.RoleName));
            }

            if (roleToAdd.Runtime == null || roleToAdd.Runtime.EntryPoint == null)
            {
                throw new ApplicationFailedException(string.Format(CultureInfo.InvariantCulture, Resources.EntryPointConfigMissing, this.RoleName));
            }

            List <ServiceDefinitionSchema.WebRole> webRoles = new List <ServiceDefinitionSchema.WebRole>();

            //Retain old roles if any.
            if (destCSDEF.WebRole != null)
            {
                webRoles.AddRange(destCSDEF.WebRole);
            }
            webRoles.Add(roleToAdd);
            destCSDEF.WebRole = webRoles.ToArray();

            SerializationUtils.SerializeXmlFile <ServiceDefinitionSchema.ServiceDefinition>(destCSDEF, ServiceCSDEFFile);
        }
Esempio n. 2
0
 public static void AreEqualServiceDefinition(ServiceDefinitionSchema.ServiceDefinition expected, ServiceDefinitionSchema.ServiceDefinition actual)
 {
     throw new NotImplementedException();
 }
Esempio n. 3
0
 /// <summary>
 /// Validates that given service definition is valid against list of web/worker roles. Validation steps:
 /// 1. Make sure that name element
 /// </summary>
 /// <param name="actual">Service definition to be checked</param>
 /// <param name="serviceName">New created service name</param>
 public static void IsValidServiceDefinition(ServiceDefinitionSchema.ServiceDefinition actual, string serviceName)
 {
     Assert.AreEqual <string>(serviceName, actual.name);
     Assert.IsNull(actual.WebRole);
     Assert.IsNull(actual.WorkerRole);
 }