def create_datacenter(kwargs=None, call=None):
 if (call != 'function'):
  raise SaltCloudSystemExit('The create_datacenter function must be called with -f or --function.')
 datacenter_name = (kwargs.get('name') if (kwargs and ('name' in kwargs)) else None)
 if (not datacenter_name):
  raise SaltCloudSystemExit('You must specify name of the new datacenter to be created.')
 if ((len(datacenter_name) >= 80) or (len(datacenter_name) <= 0)):
  raise SaltCloudSystemExit('The datacenter name must be a non empty string of less than 80 characters.')
 si = _get_si()
 datacenter_ref = salt.utils.vmware.get_mor_by_property(si, vim.Datacenter, datacenter_name)
 if datacenter_ref:
  return {datacenter_name: 'datacenter already exists'}
 folder = si.content.rootFolder
 if isinstance(folder, vim.Folder):
  try:
   folder.CreateDatacenter(name=datacenter_name)
  except Exception as exc:
   log.error('Error creating datacenter {0}: {1}'.format(datacenter_name, exc), exc_info_on_loglevel=logging.DEBUG)
   return False
  log.debug('Created datacenter {0}'.format(datacenter_name))
  return {datacenter_name: 'created'}
 return False

def create_datacenter ( kwargs = None , call = None ) : if ( call != 'function' ) : raise SaltCloudSystemExit ( 'The create_datacenter function must be called with -f or --function.' ) datacenter_name = ( kwargs . get ( 'name' ) if ( kwargs and ( 'name' in kwargs ) ) else None ) if ( not datacenter_name ) : raise SaltCloudSystemExit ( 'You must specify name of the new datacenter to be created.' ) if ( ( len ( datacenter_name ) >= 80 ) or ( len ( datacenter_name ) <= 0 ) ) : raise SaltCloudSystemExit ( 'The datacenter name must be a non empty string of less than 80 characters.' ) si = _get_si ( ) datacenter_ref = salt . utils . vmware . get_mor_by_property ( si , vim . Datacenter , datacenter_name ) if datacenter_ref : return { datacenter_name : 'datacenter already exists' } folder = si . content . rootFolder if isinstance ( folder , vim . Folder ) : try : folder . CreateDatacenter ( name = datacenter_name ) except Exception as exc : log . error ( 'Error creating datacenter {0}: {1}' . format ( datacenter_name , exc ) , exc_info_on_loglevel = logging . DEBUG ) return False log . debug ( 'Created datacenter {0}' . format ( datacenter_name ) ) return { datacenter_name : 'created' } return False
create a new data center in this vmware environment cli example: .