[CORD-2683] Adding convenience method to populate ServiceInstance with provider/subscriber ids
Change-Id: I973e1a910584015405080621bd0c17b83d27f711
diff --git a/xos/coreapi/.gitignore b/xos/coreapi/.gitignore
new file mode 100644
index 0000000..5a270ef
--- /dev/null
+++ b/xos/coreapi/.gitignore
@@ -0,0 +1,4 @@
+core.models.xosbase_header
+coreapi_output.txt
+grpc_server
+xos_grpc_api.py
\ No newline at end of file
diff --git a/xos/coreapi/apihelper.py b/xos/coreapi/apihelper.py
index cd9d4da..b353722 100644
--- a/xos/coreapi/apihelper.py
+++ b/xos/coreapi/apihelper.py
@@ -67,6 +67,7 @@
try:
return function(*args, **kwargs)
except Exception as e:
+
if "context" in kwargs:
context = kwargs["context"]
else:
diff --git a/xos/coreapi/protos/.gitignore b/xos/coreapi/protos/.gitignore
index f84f48e..ab08d52 100644
--- a/xos/coreapi/protos/.gitignore
+++ b/xos/coreapi/protos/.gitignore
@@ -1,3 +1,5 @@
*_pb2_grpc.py
*_pb2.py
-*.desc
\ No newline at end of file
+*.desc
+modeldefs.yaml
+xos.proto
\ No newline at end of file
diff --git a/xos/coreapi/protos/modeldefs.proto b/xos/coreapi/protos/modeldefs.proto
index b95a31c..999f4f9 100644
--- a/xos/coreapi/protos/modeldefs.proto
+++ b/xos/coreapi/protos/modeldefs.proto
@@ -4,7 +4,6 @@
import "google/protobuf/empty.proto";
import "google/api/annotations.proto";
-import "common.proto";
// This API is used by the UI to validate fields.
diff --git a/xos/coreapi/protos/utility.proto b/xos/coreapi/protos/utility.proto
index 1169b9d..073eb81 100644
--- a/xos/coreapi/protos/utility.proto
+++ b/xos/coreapi/protos/utility.proto
@@ -5,6 +5,7 @@
import "google/protobuf/empty.proto";
import "google/api/annotations.proto";
import "common.proto";
+import "xosoptions.proto";
message LoginRequest {
string username = 1;
@@ -15,19 +16,6 @@
string sessionid = 1;
};
-message ToscaRequest {
- string recipe = 1;
-};
-
-message ToscaResponse {
- enum ToscaStatus {
- SUCCESS = 0;
- ERROR = 1;
- }
- ToscaStatus status = 1;
- string messages = 2;
-};
-
message ModelFilter {
string class_name = 1;
};
@@ -46,6 +34,26 @@
string xproto = 1;
};
+message PopulatedServiceInstance {
+ option (contentTypeId) = "core.serviceinstance";
+ oneof id_present {
+ int32 id = 1;
+ }
+ oneof leaf_model_name_present {
+ string leaf_model_name = 2[(val).maxLength = 1024, (val).nonNull = true];
+ }
+ oneof name_present {
+ string name = 3[(val).maxLength = 200];
+ }
+ oneof owner_present {
+ int32 owner_id = 4[(val).nonNull = true, (foreignKey).modelName = "Service", (foreignKey).reverseFieldName = "service_instances"];
+ }
+ repeated int32 provided_service_instances = 5;
+ repeated int32 subscribed_service_instances = 6;
+ repeated int32 subscribed_service = 7;
+ repeated int32 subscribed_network = 8;
+};
+
service utility {
rpc Login(LoginRequest) returns (LoginResponse) {
@@ -62,20 +70,6 @@
};
}
- rpc RunTosca(ToscaRequest) returns (ToscaResponse) {
- option (google.api.http) = {
- post: "/xosapi/v1/utility/tosca"
- body: "*"
- };
- }
-
- rpc DestroyTosca(ToscaRequest) returns (ToscaResponse) {
- option (google.api.http) = {
- post: "/xosapi/v1/utility/destroy_tosca"
- body: "*"
- };
- }
-
rpc NoOp(google.protobuf.Empty) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/xosapi/v1/utility/noop"
@@ -108,4 +102,10 @@
get: "/xosapi/v1/xproto"
};
}
+
+ rpc GetPopulatedServiceInstances(ID) returns (PopulatedServiceInstance) {
+ option (google.api.http) = {
+ get: "/xosapi/v1/core/populatedserviceinstance/{id}"
+ };
+ }
};
\ No newline at end of file
diff --git a/xos/coreapi/tests/.gitignore b/xos/coreapi/tests/.gitignore
new file mode 100644
index 0000000..f9e9702
--- /dev/null
+++ b/xos/coreapi/tests/.gitignore
@@ -0,0 +1,2 @@
+chameleon_list_test.sh
+list_test.py
\ No newline at end of file
diff --git a/xos/coreapi/xos_utility_api.py b/xos/coreapi/xos_utility_api.py
index 6f6ad11..4179212 100644
--- a/xos/coreapi/xos_utility_api.py
+++ b/xos/coreapi/xos_utility_api.py
@@ -231,3 +231,42 @@
res.xproto = xproto
return res
+ @translate_exceptions
+ def GetPopulatedServiceInstances(self, request, context):
+ """
+ Return a service instance with provider and subsciber service instance ids
+ """
+ response = utility_pb2.PopulatedServiceInstance()
+
+ si = ServiceInstance.objects.get(id=request.id)
+
+
+ # populate the response object
+ response.id = si.id
+ response.leaf_model_name = si.leaf_model_name
+ response.owner_id = si.owner_id
+
+ if si.name:
+ response.name = si.name
+
+ # find links
+ provided_links = si.provided_links.all()
+ subscribed_links = si.subscribed_links.all()
+
+ # import pdb; pdb.set_trace()
+
+ for l in provided_links:
+ response.provided_service_instances.append(l.subscriber_service_instance.id)
+
+ for l in subscribed_links:
+ if l.subscriber_service_instance:
+ response.subscribed_service_instances.append(l.provider_service_instance_id)
+ elif l.subscriber_service:
+ response.subscribed_service.append(l.subscriber_service.id)
+ elif l.subscriber_network:
+ response.subscribed_network.append(l.subscriber_network.id)
+
+ return response
+
+
+
diff --git a/xos/synchronizers/.gitignore b/xos/synchronizers/.gitignore
new file mode 100644
index 0000000..6aed14b
--- /dev/null
+++ b/xos/synchronizers/.gitignore
@@ -0,0 +1,5 @@
+new_base/event_loop
+new_base/mock_modelaccessor.py
+new_base/mock_modelaccessor.py.context
+new_base/synchronizers.new_base.ansible_helper
+new_base/xos.synchronizers.new_base.tests.test_payload
\ No newline at end of file