2 * Copyright 2016 [ZTE] and others.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
16 package org.openo.commontosca.catalog.model.externalservice.lifecycle;
\r
18 import java.lang.reflect.Type;
\r
19 import java.util.ArrayList;
\r
21 import org.openo.commontosca.catalog.common.MSBUtil;
\r
22 import org.openo.commontosca.catalog.common.ToolUtil;
\r
23 import org.openo.commontosca.catalog.model.externalservice.entity.lifecycleEnity.InstanceEntity;
\r
24 import org.slf4j.Logger;
\r
25 import org.slf4j.LoggerFactory;
\r
27 import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
\r
28 import com.google.gson.Gson;
\r
29 import com.google.gson.reflect.TypeToken;
\r
32 * The lifecycle service.
\r
36 public class LifeCycleServiceConsumer {
\r
37 private static final Logger LOG = LoggerFactory.getLogger(LifeCycleServiceConsumer.class);
\r
40 * get lifecycle application instances.
\r
41 * @return instance entity
\r
43 public static ArrayList<InstanceEntity> getInstances() {
\r
44 ILifeCycleServiceRest resourceserviceproxy = ConsumerFactory
\r
45 .createConsumer(MSBUtil.getNsocLifecycleBaseUrl(), ILifeCycleServiceRest.class);
\r
48 result = resourceserviceproxy.getVNFInstances();
\r
49 } catch (Exception e) {
\r
50 LOG.error("query vim info faild.", e);
\r
53 if (ToolUtil.isEmptyString(result)) {
\r
57 Gson gson = new Gson();
\r
58 Type listType = new TypeToken<ArrayList<InstanceEntity>>() {}.getType();
\r
59 return gson.fromJson(result, listType);
\r