Search in sources :

Example 1 with ServiceTemplateType

use of net.juniper.contrail.api.types.ServiceTemplateType in project cloudstack by apache.

the class ServiceInstanceModel method locateServiceTemplate.

private ServiceTemplate locateServiceTemplate(ModelController controller) {
    ServiceTemplate tmpl;
    try {
        ApiConnector api = controller.getApiAccessor();
        tmpl = (ServiceTemplate) api.findById(ServiceTemplate.class, _templateId);
    } catch (IOException ex) {
        s_logger.warn("service-template read", ex);
        throw new CloudRuntimeException("Unable to create service-template object", ex);
    }
    if (tmpl == null) {
        tmpl = new ServiceTemplate();
        tmpl.setName(_templateName);
        tmpl.setUuid(_templateId);
        ServiceTemplateType props = new ServiceTemplateType("in-network", null, _templateUrl, false, null);
        tmpl.setProperties(props);
        try {
            ApiConnector api = controller.getApiAccessor();
            api.create(tmpl);
        } catch (IOException ex) {
            throw new CloudRuntimeException("Unable to create service-template object", ex);
        }
    }
    return tmpl;
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ServiceTemplate(net.juniper.contrail.api.types.ServiceTemplate) ApiConnector(net.juniper.contrail.api.ApiConnector) ServiceTemplateType(net.juniper.contrail.api.types.ServiceTemplateType) IOException(java.io.IOException)

Aggregations

CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 IOException (java.io.IOException)1 ApiConnector (net.juniper.contrail.api.ApiConnector)1 ServiceTemplate (net.juniper.contrail.api.types.ServiceTemplate)1 ServiceTemplateType (net.juniper.contrail.api.types.ServiceTemplateType)1