Changed to use XOS client to get service and port information

XOS client still gets these information from OpenStack temporarily
until XOS provides these APIs

Change-Id: I1ef9302f719a18a7377221f63b84431c2cdface8
diff --git a/src/main/java/org/onosproject/cordvtn/api/CordService.java b/src/main/java/org/onosproject/cordvtn/api/CordService.java
deleted file mode 100644
index 604e707..0000000
--- a/src/main/java/org/onosproject/cordvtn/api/CordService.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.cordvtn.api;
-
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.net.Host;
-import org.openstack4j.model.network.Network;
-import org.openstack4j.model.network.Subnet;
-
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-public final class CordService {
-
-    public enum ServiceType {
-        PRIVATE,
-        PUBLIC,
-        MANAGEMENT
-    }
-
-    private final CordServiceId id;
-    private final long segmentationId;
-    private final ServiceType serviceType;
-    private final IpPrefix serviceIpRange;
-    private final IpAddress serviceIp;
-    private final Map<Host, IpAddress> hosts;
-    private final Set<CordServiceId> tenantServices;
-    private final Set<CordServiceId> providerServices;
-
-    /**
-     * Default constructor.
-     *
-     * @param osNet OpenStack network
-     * @param osSubnet OpenStack subnet
-     * @param hosts host and tunnel ip map
-     * @param tenantServices list of tenant service ids
-     * @param providerServices list of provider service ids
-     */
-    public CordService(Network osNet, Subnet osSubnet,
-                       Map<Host, IpAddress> hosts, Set<CordServiceId> tenantServices,
-                       Set<CordServiceId> providerServices) {
-        this.id = CordServiceId.of(osNet.getId());
-        this.segmentationId = Long.parseLong(osNet.getProviderSegID());
-        this.serviceType = getServiceType(osNet.getName());
-        this.serviceIpRange = IpPrefix.valueOf(osSubnet.getCidr());
-        this.serviceIp = IpAddress.valueOf(osSubnet.getGateway());
-        this.hosts = hosts;
-        this.tenantServices = tenantServices;
-        this.providerServices = providerServices;
-    }
-
-    /**
-     * Returns service ID.
-     *
-     * @return service id
-     */
-    public CordServiceId id() {
-        return id;
-    }
-
-    /**
-     * Returns segmentation ID of this service.
-     *
-     * @return segmentation id
-     */
-    public long segmentationId() {
-        return segmentationId;
-    }
-
-    /**
-     * Returns service type.
-     *
-     * @return service type
-     */
-    public ServiceType serviceType() {
-        return serviceType;
-    }
-
-    /**
-     * Returns service IP range.
-     *
-     * @return CIDR
-     */
-    public IpPrefix serviceIpRange() {
-        return serviceIpRange;
-    }
-
-    /**
-     * Returns service IP address.
-     *
-     * @return ip address
-     */
-    public IpAddress serviceIp() {
-        return serviceIp;
-    }
-
-    /**
-     * Returns hosts associated with this service.
-     *
-     * @return list of hosts
-     */
-    public Map<Host, IpAddress> hosts() {
-        return hosts;
-    }
-
-    /**
-     * Returns tenant service IDs.
-     *
-     * @return list of tenant service id
-     */
-    public Set<CordServiceId> tenantServices() {
-        return tenantServices;
-    }
-
-    /**
-     * Returns provider service IDs.
-     *
-     * @return list of provider service id
-     */
-    public Set<CordServiceId> providerServices() {
-        return providerServices;
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(id);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof CordService)) {
-            return false;
-        }
-        final CordService other = (CordService) obj;
-        return Objects.equals(this.id, other.id);
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(this)
-                .add("id", id)
-                .add("segmentationId", segmentationId)
-                .add("serviceType", serviceType)
-                .add("serviceIpRange", serviceIpRange)
-                .add("serviceIp", serviceIp)
-                .add("tenantServices", tenantServices)
-                .add("providerServices", providerServices)
-                .toString();
-    }
-
-    /**
-     * Returns network type from network name.
-     * It assumes that network name contains network type.
-     *
-     * @param netName network name
-     * @return network type, or PRIVATE if it doesn't match any type
-     */
-    private ServiceType getServiceType(String netName) {
-        checkNotNull(netName);
-
-        String name = netName.toUpperCase();
-        if (name.contains(ServiceType.PUBLIC.toString())) {
-            return ServiceType.PUBLIC;
-        } else if (name.contains(ServiceType.MANAGEMENT.toString())) {
-            return ServiceType.MANAGEMENT;
-        } else {
-            return ServiceType.PRIVATE;
-        }
-    }
-}
diff --git a/src/main/java/org/onosproject/cordvtn/api/CordServiceId.java b/src/main/java/org/onosproject/cordvtn/api/CordServiceId.java
deleted file mode 100644
index b8a22a2..0000000
--- a/src/main/java/org/onosproject/cordvtn/api/CordServiceId.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.cordvtn.api;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Representation of service identifier.
- */
-public final class CordServiceId extends Identifier<String> {
-    /**
-     * Default constructor.
-     *
-     * @param id service identifier
-     */
-    private CordServiceId(String id) {
-        super(id);
-    }
-
-    /**
-     * Returns the CordServiceId with value.
-     *
-     * @param id service id
-     * @return CordServiceId
-     */
-    public static CordServiceId of(String id) {
-        checkNotNull(id);
-        return new CordServiceId(id);
-    }
-}
diff --git a/src/main/java/org/onosproject/cordvtn/api/CordVtnConfig.java b/src/main/java/org/onosproject/cordvtn/api/CordVtnConfig.java
index 2055e34..b50d6fc 100644
--- a/src/main/java/org/onosproject/cordvtn/api/CordVtnConfig.java
+++ b/src/main/java/org/onosproject/cordvtn/api/CordVtnConfig.java
@@ -25,6 +25,7 @@
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.config.Config;
+import org.onosproject.xosclient.api.OpenStackAccess;
 import org.onosproject.xosclient.api.XosAccess;
 import org.slf4j.Logger;
 
@@ -209,9 +210,9 @@
     /**
      * Returns OpenStack API access information.
      *
-     * @return openstack config
+     * @return openstack access
      */
-    public OpenStackConfig openstackConfig() {
+    public OpenStackAccess openstackAccess() {
         JsonNode jsonNode = object.get(OPENSTACK);
         if (jsonNode == null) {
             log.error("Failed to get OpenStack configurations");
@@ -219,7 +220,7 @@
         }
 
         try {
-            return new OpenStackConfig(
+            return new OpenStackAccess(
                     jsonNode.path(ENDPOINT).asText(),
                     jsonNode.path(TENANT).asText(),
                     jsonNode.path(USER).asText(),
@@ -229,66 +230,4 @@
             return null;
         }
     }
-
-    /**
-     * Configuration for OpenStack API access.
-     */
-    public static class OpenStackConfig {
-
-        private final String endpoint;
-        private final String tenant;
-        private final String user;
-        private final String password;
-
-        /**
-         * Default constructor.
-         *
-         * @param endpoint Keystone endpoint
-         * @param tenant tenant name
-         * @param user user name
-         * @param password passwowrd
-         */
-        public OpenStackConfig(String endpoint, String tenant, String user, String password) {
-            this.endpoint = endpoint;
-            this.tenant = tenant;
-            this.user = user;
-            this.password = password;
-        }
-
-        /**
-         * Returns OpenStack API endpoint.
-         *
-         * @return endpoint
-         */
-        public String endpoint() {
-            return this.endpoint;
-        }
-
-        /**
-         * Returns OpenStack tenant name.
-         *
-         * @return tenant name
-         */
-        public String tenant() {
-            return this.tenant;
-        }
-
-        /**
-         * Returns OpenStack user.
-         *
-         * @return user name
-         */
-        public String user() {
-            return this.user;
-        }
-
-        /**
-         * Returns OpenStack password for the user.
-         *
-         * @return password
-         */
-        public String password() {
-            return this.password;
-        }
-    }
 }
diff --git a/src/main/java/org/onosproject/cordvtn/api/CordVtnService.java b/src/main/java/org/onosproject/cordvtn/api/CordVtnService.java
index 5950670..bd25b0f 100644
--- a/src/main/java/org/onosproject/cordvtn/api/CordVtnService.java
+++ b/src/main/java/org/onosproject/cordvtn/api/CordVtnService.java
@@ -19,6 +19,7 @@
 import org.onlab.packet.MacAddress;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.HostId;
+import org.onosproject.xosclient.api.VtnServiceId;
 
 import java.util.Map;
 
@@ -51,8 +52,7 @@
      * @param pServiceId id of the service which provide dependency
      * @param isBidirectional true to enable bidirectional connectivity between two services
      */
-    void createServiceDependency(CordServiceId tServiceId,
-                                 CordServiceId pServiceId,
+    void createServiceDependency(VtnServiceId tServiceId, VtnServiceId pServiceId,
                                  boolean isBidirectional);
 
     /**
@@ -61,7 +61,7 @@
      * @param tServiceId id of the service which has a dependency
      * @param pServiceId id of the service which provide dependency
      */
-    void removeServiceDependency(CordServiceId tServiceId, CordServiceId pServiceId);
+    void removeServiceDependency(VtnServiceId tServiceId, VtnServiceId pServiceId);
 
     /**
      * Updates virtual service gateways.