Commit 500b0688 authored by Spiros Koulouzis's avatar Spiros Koulouzis

test upload file

parent 96924a93
...@@ -10,6 +10,8 @@ import yaml ...@@ -10,6 +10,8 @@ import yaml
import unittest import unittest
import sure_tosca_client import sure_tosca_client
from sure_tosca_client import Configuration, ApiClient
from sure_tosca_client.api import default_api
class TestDeployer(unittest.TestCase): class TestDeployer(unittest.TestCase):
...@@ -46,9 +48,10 @@ class TestDeployer(unittest.TestCase): ...@@ -46,9 +48,10 @@ class TestDeployer(unittest.TestCase):
with open(tosca_template_path, 'w') as outfile: with open(tosca_template_path, 'w') as outfile:
yaml.dump(tosca_template_dict, outfile, default_flow_style=False) yaml.dump(tosca_template_dict, outfile, default_flow_style=False)
tosca_client = init_sure_tosca_client('http://localhost:8081/tosca-sure/1.0.0/')
doc_id = tosca_client.upload_tosca_template(tosca_template_path)
print(doc_id) tosca_client = self.init_sure_tosca_client('http://localhost:8081/tosca-sure/1.0.0/')
self.upload_tosca_template('application_example_provisioned.yaml',tosca_client)
# tosca_interfaces = tosca.get_interfaces(tosca_template_dict) # tosca_interfaces = tosca.get_interfaces(tosca_template_dict)
# tmp_path = tempfile.mkdtemp() # tmp_path = tempfile.mkdtemp()
...@@ -85,12 +88,30 @@ class TestDeployer(unittest.TestCase): ...@@ -85,12 +88,30 @@ class TestDeployer(unittest.TestCase):
# print(json.dumps(response)) # print(json.dumps(response))
def init_sure_tosca_client(sure_tosca_base_path): def upload_tosca_template(self, file_name,api):
configuration = sure_tosca_client.Configuration() file = self.get_tosca_file(file_name)
sure_tosca_client.configuration.host = sure_tosca_base_path file_id = api.upload_tosca_template(file)
api_client = sure_tosca_client.ApiClient(configuration=configuration) return file_id
sure_tosca_client_api = sure_tosca_client.api.default_api.DefaultApi(api_client=api_client) # noqa: E501
return sure_tosca_client_api
def get_tosca_file(self, file_name):
tosca_path = "../../TOSCA/"
input_tosca_file_path = tosca_path + '/' + file_name
if not os.path.exists(input_tosca_file_path):
tosca_path = "../TOSCA/"
input_tosca_file_path = tosca_path + '/' + file_name
dir_path = os.path.dirname(os.path.realpath(__file__))
self.assertEqual(True, os.path.exists(input_tosca_file_path),
'Starting from: ' + dir_path + ' Input TOSCA file: ' + input_tosca_file_path + ' not found')
return input_tosca_file_path
def init_sure_tosca_client(self,sure_tosca_base_path):
configuration = Configuration()
configuration.host = "http://localhost:8081/tosca-sure/1.0.0/"
api_client = ApiClient(configuration=configuration)
api = default_api.DefaultApi(api_client=api_client) # noqa: E501
return api
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -59,18 +59,18 @@ services: ...@@ -59,18 +59,18 @@ services:
- "27017:27017" - "27017:27017"
manager: #manager:
depends_on: #depends_on:
- rabbit #- rabbit
- mongo #- mongo
- sure-tosca #- sure-tosca
image: manager:3.0.0 #image: manager:3.0.0
environment: #environment:
RABBITMQ_HOST: rabbit #RABBITMQ_HOST: rabbit
MONGO_HOST: mongo #MONGO_HOST: mongo
SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0 #SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
ports: #ports:
- "30000:8080" #- "30000:8080"
sure-tosca: sure-tosca:
image: sure-tosca:3.0.0 image: sure-tosca:3.0.0
...@@ -85,14 +85,14 @@ services: ...@@ -85,14 +85,14 @@ services:
environment: environment:
RABBITMQ_HOST: rabbit RABBITMQ_HOST: rabbit
provisioner: #provisioner:
depends_on: #depends_on:
- rabbit #- rabbit
- sure-tosca #- sure-tosca
image: provisioner:3.0.0 #image: provisioner:3.0.0
environment: #environment:
RABBITMQ_HOST: rabbit #RABBITMQ_HOST: rabbit
SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0 #SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
#deployer: #deployer:
#depends_on: #depends_on:
......
...@@ -2,11 +2,9 @@ ...@@ -2,11 +2,9 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3f84153d-6ed1-4691-94d6-53105266f15e" name="Default Changelist" comment=""> <list default="true" id="3f84153d-6ed1-4691-94d6-53105266f15e" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../deployer/__main__.py" beforeDir="false" afterPath="$PROJECT_DIR$/../deployer/__main__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../deployer/test/test_deployer.py" beforeDir="false" afterPath="$PROJECT_DIR$/../deployer/test/test_deployer.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../deployer/test/test_deployer.py" beforeDir="false" afterPath="$PROJECT_DIR$/../deployer/test/test_deployer.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../docker-compose.yml" beforeDir="false" afterPath="$PROJECT_DIR$/../docker-compose.yml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../docker-compose.yml" beforeDir="false" afterPath="$PROJECT_DIR$/../docker-compose.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/setup.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -67,38 +65,38 @@ ...@@ -67,38 +65,38 @@
<screen x="67" y="34" width="1853" height="1046" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state x="723" y="257" width="530" height="598" key="FileChooserDialogImpl/67.34.1853.1046@67.34.1853.1046" timestamp="1584814061190" /> <state x="723" y="257" width="530" height="598" key="FileChooserDialogImpl/67.34.1853.1046@67.34.1853.1046" timestamp="1584814061190" />
<state width="1825" height="342" key="GridCell.Tab.0.bottom" timestamp="1584902089025"> <state width="1825" height="336" key="GridCell.Tab.0.bottom" timestamp="1585226920216">
<screen x="67" y="34" width="1853" height="1046" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="342" key="GridCell.Tab.0.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1584902089025" /> <state width="1825" height="336" key="GridCell.Tab.0.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1585226920216" />
<state width="1825" height="342" key="GridCell.Tab.0.center" timestamp="1584902089024"> <state width="1825" height="336" key="GridCell.Tab.0.center" timestamp="1585226920216">
<screen x="67" y="34" width="1853" height="1046" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="342" key="GridCell.Tab.0.center/67.34.1853.1046@67.34.1853.1046" timestamp="1584902089024" /> <state width="1825" height="336" key="GridCell.Tab.0.center/67.34.1853.1046@67.34.1853.1046" timestamp="1585226920216" />
<state width="1825" height="342" key="GridCell.Tab.0.left" timestamp="1584902089023"> <state width="1825" height="336" key="GridCell.Tab.0.left" timestamp="1585226920215">
<screen x="67" y="34" width="1853" height="1046" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="342" key="GridCell.Tab.0.left/67.34.1853.1046@67.34.1853.1046" timestamp="1584902089023" /> <state width="1825" height="336" key="GridCell.Tab.0.left/67.34.1853.1046@67.34.1853.1046" timestamp="1585226920215" />
<state width="1825" height="342" key="GridCell.Tab.0.right" timestamp="1584902089024"> <state width="1825" height="336" key="GridCell.Tab.0.right" timestamp="1585226920216">
<screen x="67" y="34" width="1853" height="1046" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="342" key="GridCell.Tab.0.right/67.34.1853.1046@67.34.1853.1046" timestamp="1584902089024" /> <state width="1825" height="336" key="GridCell.Tab.0.right/67.34.1853.1046@67.34.1853.1046" timestamp="1585226920216" />
<state width="1825" height="263" key="GridCell.Tab.1.bottom" timestamp="1584902065994"> <state width="1825" height="336" key="GridCell.Tab.1.bottom" timestamp="1584952144349">
<screen x="67" y="34" width="1853" height="1046" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="263" key="GridCell.Tab.1.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1584902065994" /> <state width="1825" height="336" key="GridCell.Tab.1.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1584952144349" />
<state width="1825" height="263" key="GridCell.Tab.1.center" timestamp="1584902065993"> <state width="1825" height="336" key="GridCell.Tab.1.center" timestamp="1584952144349">
<screen x="67" y="34" width="1853" height="1046" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="263" key="GridCell.Tab.1.center/67.34.1853.1046@67.34.1853.1046" timestamp="1584902065993" /> <state width="1825" height="336" key="GridCell.Tab.1.center/67.34.1853.1046@67.34.1853.1046" timestamp="1584952144349" />
<state width="1825" height="263" key="GridCell.Tab.1.left" timestamp="1584902065993"> <state width="1825" height="336" key="GridCell.Tab.1.left" timestamp="1584952144348">
<screen x="67" y="34" width="1853" height="1046" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="263" key="GridCell.Tab.1.left/67.34.1853.1046@67.34.1853.1046" timestamp="1584902065993" /> <state width="1825" height="336" key="GridCell.Tab.1.left/67.34.1853.1046@67.34.1853.1046" timestamp="1584952144348" />
<state width="1825" height="263" key="GridCell.Tab.1.right" timestamp="1584902065994"> <state width="1825" height="336" key="GridCell.Tab.1.right" timestamp="1584952144349">
<screen x="67" y="34" width="1853" height="1046" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="263" key="GridCell.Tab.1.right/67.34.1853.1046@67.34.1853.1046" timestamp="1584902065994" /> <state width="1825" height="336" key="GridCell.Tab.1.right/67.34.1853.1046@67.34.1853.1046" timestamp="1584952144349" />
<state x="359" y="103" key="SettingsEditor" timestamp="1584813615342"> <state x="359" y="103" key="SettingsEditor" timestamp="1584813615342">
<screen x="67" y="34" width="1853" height="1046" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment