/**
  * @param IDataCenterLocation $data_center_location
  * @throws EntityValidationException
  */
 public function addDataCenterLocation(IDataCenterLocation $data_center_location)
 {
     $data_centers = AssociationFactory::getInstance()->getOne2ManyAssociation($this, 'DataCenters');
     foreach ($data_centers->toArray() as $location) {
         if ($data_center_location->getCountry() == $location->getCountry() && $data_center_location->getCity() == $location->getCity()) {
             throw new EntityValidationException(array(array('message' => sprintf('DataCenter Location ( %s - %s) already exists!.', $location->getCity(), $location->getCountry()))));
         }
     }
     $data_centers->add($data_center_location);
 }
 public static function convertDataCenterLocationToArray(IDataCenterLocation $location)
 {
     $res = array();
     $res['city'] = $location->getCity();
     $res['state'] = $location->getState();
     $res['country'] = $location->getCountry();
     $res['region'] = strtolower(preg_replace('/[^A-Za-z0-9-]+/', '-', $location->getDataCenterRegion()->getName()));
     $res['availability_zones'] = array();
     foreach ($location->getAvailabilityZones() as $az) {
         array_push($res['availability_zones'], CloudAssembler::convertAZtoArray($az));
     }
     return $res;
 }