public boolean createNetwork(
      Network network,
      NetworkOffering offering,
      DeployDestination dest,
      ReservationContext context) {
    if (_sspUuidDao.findUuidByNetwork(network) != null) {
      s_logger.info("Network already has ssp TenantNetwork uuid :" + network.toString());
      return true;
    }
    if (!canHandle(network)) {
      return false;
    }

    String tenantUuid = _sspTenantDao.findUuidByZone(network.getDataCenterId());
    if (tenantUuid == null) {
      tenantUuid = _configDao.getValueAndInitIfNotExist("ssp.tenant", "Network", null);
    }

    boolean processed = false;
    for (SspClient client :
        fetchSspClients(network.getPhysicalNetworkId(), network.getDataCenterId(), true)) {
      SspClient.TenantNetwork sspNet = client.createTenantNetwork(tenantUuid, network.getName());
      if (sspNet != null) {
        SspUuidVO uuid = new SspUuidVO();
        uuid.setUuid(sspNet.uuid);
        uuid.setObjClass(SspUuidVO.objClassNetwork);
        uuid.setObjId(network.getId());
        _sspUuidDao.persist(uuid);
        return true;
      }
      processed = true;
    }
    if (processed) {
      s_logger.error("Could not allocate an uuid for network " + network.toString());
      return false;
    } else {
      s_logger.error("Skipping #createNetwork() for " + network.toString());
      return true;
    }
  }
  @Override
  public Host addSspHost(AddSspCmd cmd) {
    SspClient client = new SspClient(cmd.getUrl(), cmd.getUsername(), cmd.getPassword());
    if (!client.login()) {
      throw new CloudRuntimeException("Ssp login failed.");
    }

    long zoneId = cmd.getZoneId();
    SspCredentialVO credential = _sspCredentialDao.findByZone(zoneId);
    if (credential == null) {
      if (cmd.getUsername() == null || cmd.getPassword() == null) {
        throw new InvalidParameterValueException("Initial credential required for zone: " + zoneId);
      }
      credential = new SspCredentialVO();
      credential.setZoneId(zoneId);
      credential.setUsername(cmd.getUsername());
      credential.setPassword(cmd.getPassword());
      _sspCredentialDao.persist(credential);
    } else {
      if (cmd.getUsername() != null || cmd.getPassword() != null) {
        s_logger.warn("Tenant credential already configured for zone:" + zoneId);
      }
    }

    String tenantUuid = _sspTenantDao.findUuidByZone(zoneId);
    if (tenantUuid == null) {
      if (cmd.getTenantUuid() == null) {
        throw new InvalidParameterValueException(
            "Initial tenant uuid required for zone: " + zoneId);
      }
      SspTenantVO tenant = new SspTenantVO();
      tenant.setZoneId(zoneId);
      tenant.setUuid(cmd.getTenantUuid());
      _sspTenantDao.persist(tenant);
    } else {
      if (cmd.getTenantUuid() != null) {
        s_logger.warn("Tenant uuid already configured for zone:" + zoneId);
      }
    }

    String normalizedUrl = null;
    String hostname = null;
    try {
      URL url = new URL(cmd.getUrl());
      normalizedUrl = url.toString();
      hostname = url.getHost();
    } catch (MalformedURLException e1) {
      throw new CloudRuntimeException("Invalid url " + cmd.getUrl());
    }

    List<HostVO> hosts = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.L2Networking, zoneId);
    for (HostVO host : hosts) {
      assert (credential != null);
      _hostDao.loadDetails(host);
      if ("v1Api".equals(host.getDetail("sspHost"))) {
        if (normalizedUrl.equals(host.getDetail("url"))) {
          s_logger.warn("Ssp host already registered " + normalizedUrl);
          return host;
        }
      }
    }
    // SspHost HostVO will be created per zone and url.
    HostVO host = new HostVO(UUID.randomUUID().toString());
    host.setDataCenterId(zoneId);
    host.setType(Host.Type.L2Networking);
    host.setPrivateIpAddress(hostname); // db schema not null. It may be a name, not IP address.
    //        host.setPrivateMacAddress(""); // db schema nullable
    //        host.setPrivateNetmask(""); // db schema nullable
    host.setVersion("1"); // strange db schema not null
    host.setName(cmd.getName());

    host.setDetails(new HashMap<String, String>());
    host.setDetail("sspHost", "v1Api");
    host.setDetail("url", normalizedUrl);
    return _hostDao.persist(host);
  }