Skip to content

Commit 2a8389d

Browse files
authored
Merge pull request #472 from QualiSystems/develop
Merging dev to master
2 parents 3d21e67 + b866c1f commit 2a8389d

45 files changed

Lines changed: 1065 additions & 1079 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ install:
99
- pip install "cloudshell-core>=2.2.0,<2.3.0"
1010
- pip install "cloudshell-shell-core>=3.1.0,<3.2.0"
1111
- pip install "cloudshell-automation-api>=8.3.0.0,<8.3.1.0" --extra-index-url https://testpypi.python.org/simple
12-
12+
- pip install "cloudshell-cp-core>=1.0.0,<1.1.0" --extra-index-url https://test.pypi.org/simple
1313
script:
1414
- pushd package
1515
- python setup.py develop

cloudformation/2_EC2_EX_No_VPN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@
455455
"InstanceId": {
456456
"Ref": "CloudShellServerInstance"
457457
},
458-
"Domain": ""
458+
"Domain": "vpc"
459459
},
460460
"DependsOn": "CloudShellServerInstance"
461461
}

drivers/aws_shell/src/driver.py

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
import jsonpickle
21
from cloudshell.shell.core.driver_context import AutoLoadDetails
32
from cloudshell.shell.core.resource_driver_interface import ResourceDriverInterface
43
from cloudshell.cp.aws.aws_shell import AWSShell
4+
from cloudshell.cp.core import DriverRequestParser
5+
from cloudshell.cp.core.models import DeployApp, DriverResponse
6+
from cloudshell.cp.core.utils import single
7+
from cloudshell.cp.aws.models.deploy_aws_ec2_ami_instance_resource_model import DeployAWSEc2AMIInstanceResourceModel
8+
from cloudshell.cp.core.models import ConnectSubnet
9+
510

611

712
class AWSShellDriver(ResourceDriverInterface):
@@ -13,23 +18,38 @@ def __init__(self):
1318
ctor must be without arguments, it is created with reflection at run time
1419
"""
1520
self.aws_shell = AWSShell()
21+
self.request_parser = DriverRequestParser()
22+
self.request_parser.add_deployment_model(deployment_model_cls=DeployAWSEc2AMIInstanceResourceModel)
1623
self.deployments = dict()
1724
self.deployments['AWS EC2 Instance'] = self.deploy_ami
1825

1926
def initialize(self, context):
2027
pass
2128

2229
def Deploy(self, context, request=None, cancellation_context=None):
23-
app_request = jsonpickle.decode(request)
24-
deployment_name = app_request['DeploymentServiceName']
30+
actions = self.request_parser.convert_driver_request_to_actions(request)
31+
deploy_action = single(actions, lambda x: isinstance(x, DeployApp))
32+
deployment_name = deploy_action.actionParams.deployment.deploymentPath
33+
self.parse_vnicename(actions)
34+
35+
2536
if deployment_name in self.deployments.keys():
2637
deploy_method = self.deployments[deployment_name]
27-
return deploy_method(context, request, cancellation_context)
38+
deploy_result = deploy_method(context, actions, cancellation_context)
39+
return DriverResponse(deploy_result).to_driver_response_json()
2840
else:
2941
raise Exception('Could not find the deployment')
3042

31-
def deploy_ami(self, context, request, cancellation_context):
32-
return self.aws_shell.deploy_ami(context, request, cancellation_context)
43+
def parse_vnicename(self, actions):
44+
network_actions = [a for a in actions if isinstance(a, ConnectSubnet)]
45+
for network_action in network_actions:
46+
try:
47+
network_action.actionParams.vnicName = int(network_action.actionParams.vnicName)
48+
except:
49+
network_action.actionParams.vnicName = None
50+
51+
def deploy_ami(self, context, actions, cancellation_context):
52+
return self.aws_shell.deploy_ami(context, actions, cancellation_context)
3353

3454
def PowerOn(self, context, ports):
3555
return self.aws_shell.power_on_ami(context)
@@ -43,14 +63,17 @@ def PowerCycle(self, context, ports, delay):
4363
def remote_refresh_ip(self, context, ports, cancellation_context):
4464
return self.aws_shell.refresh_ip(context)
4565

46-
def destroy_vm_only(self, context, ports):
66+
def DeleteInstance(self, context, ports):
4767
return self.aws_shell.delete_instance(context)
4868

49-
def PrepareConnectivity(self, context, request, cancellation_context):
50-
return self.aws_shell.prepare_connectivity(context, request, cancellation_context)
69+
def PrepareSandboxInfra(self, context, request, cancellation_context):
70+
actions = self.request_parser.convert_driver_request_to_actions(request)
71+
action_results = self.aws_shell.prepare_connectivity(context, actions, cancellation_context)
72+
return DriverResponse(action_results).to_driver_response_json()
5173

52-
def CleanupConnectivity(self, context, request):
53-
return self.aws_shell.cleanup_connectivity(context, request)
74+
def CleanupSandboxInfra(self, context, request):
75+
actions = self.request_parser.convert_driver_request_to_actions(request)
76+
return self.aws_shell.cleanup_connectivity(context, actions)
5477

5578
def GetApplicationPorts(self, context, ports):
5679
return self.aws_shell.get_application_ports(context)

drivers/aws_shell/src/drivermetadata.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<Driver Description="This driver orchestrate all the command that will be executed on AWS" MainClass="driver.AWSShellDriver" Name="AWS Shell Driver" Version="2.2.1">
1+
<Driver Description="This driver orchestrate all the command that will be executed on AWS" MainClass="driver.AWSShellDriver" Name="AWS Shell Driver" Version="2.3.9999">
22
<Layout>
33
<Category Name="Deployment">
44
<Command Description="" DisplayName="Deploy From AMI" EnableCancellation="true" Name="deploy_ami" Tags="allow_unreserved" />
55
</Category>
66
<Category Name="Connectivity">
77
<Command Description="" DisplayName="Refresh IP" EnableCancellation="true" Name="remote_refresh_ip" Tags="remote_connectivity,allow_shared" />
88
<Command Description="" DisplayName="Get Application Ports" Name="GetApplicationPorts" Tags="remote_connectivity,allow_shared" />
9-
<Command Description="" DisplayName="Prepare Connectivity" EnableCancellation="true" Name="PrepareConnectivity" Tags="allow_unreserved" />
10-
<Command Description="" DisplayName="Cleanup Connectivity" EnableCancellation="true" Name="CleanupConnectivity" Tags="allow_unreserved" />
9+
<Command Description="" DisplayName="Prepare Connectivity" EnableCancellation="true" Name="PrepareSandboxInfra" Tags="allow_unreserved" />
10+
<Command Description="" DisplayName="Cleanup Connectivity" EnableCancellation="true" Name="CleanupSandboxInfra" Tags="allow_unreserved" />
1111
</Category>
1212
<Category Name="Hidden Commands">
1313
<Command Description="" DisplayName="Power Cycle" Name="PowerCycle" Tags="power" />
14-
<Command Description="" DisplayName="Delete VM Only" Name="destroy_vm_only" Tags="remote_app_management,allow_shared" />
14+
<Command Description="" DisplayName="Delete VM Only" Name="DeleteInstance" Tags="remote_app_management,allow_shared" />
1515
<Command Description="" DisplayName="GetAccessKey" Name="GetAccessKey" Tags="remote_app_management" />
1616
<Command Description="" DisplayName="Deploy" Name="Deploy" Tags="allow_unreserved" />
1717
<Command Description="" DisplayName="Set App Security Groups" Name="SetAppSecurityGroups" Tags="allow_unreserved" />
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cloudshell-automation-api>=8.3.0.0,<8.3.1.0
22
cloudshell-shell-core>=3.1.0,<3.2.0
3-
cloudshell-cp-aws>=2.2.0,<2.3.0
3+
cloudshell-cp-aws>=2.3.0,<2.4.0
44
jsonpickle==0.9.3
5+
cloudshell-cp-core>=1.0.0,<1.1.0

drivers/aws_shellPackage/DataModel/datamodel.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@
114114
<Rule Name="Setting" />
115115
</Rules>
116116
</AttributeInfo>
117+
<AttributeInfo Name="IAM Role Name" Type="String" DefaultValue="" Description="Provide the IAM role name to be used in this instance." IsReadOnly="false" >
118+
<Rules>
119+
<Rule Name="Configuration" />
120+
<Rule Name="Setting" />
121+
</Rules>
122+
</AttributeInfo>
117123
<AttributeInfo DefaultValue="0" Description="The max number of I/O operations per second that the volume can support. For Provisioned IOPS (SSD) volumes, you can provision up to 30 IOPS per GiB. If left empty the default in the AMI will be used. For example 240." IsReadOnly="false" Name="Max Storage IOPS" Type="Numeric">
118124
<Rules>
119125
<Rule Name="Configuration" />
@@ -226,6 +232,7 @@
226232
<DriverName>AWS Shell Driver</DriverName>
227233
</Drivers>
228234
<Scripts>
235+
229236
</Scripts>
230237
</ResourceModel>
231238
</Models>
@@ -260,7 +267,7 @@
260267
<Models>
261268
<ResourceModel Description="" Name="AWS EC2 Instance" ImagePath="DeploymentTypes-AWS-EC2.png" SupportsConcurrentCommands="false">
262269
<AttachedAttributes>
263-
<AttachedAttribute IsLocal="true" IsOverridable="true" Name="AWS AMI Id" UserInput="true">
270+
<AttachedAttribute IsLocal="true" IsOverridable="true" Name="AWS AMI Id" UserInput="true" EditableOnlyInAppTemplate="true">
264271
<AllowedValues />
265272
</AttachedAttribute>
266273
<AttachedAttribute IsLocal="true" IsOverridable="true" Name="Allow all Sandbox Traffic" UserInput="true">
@@ -269,6 +276,9 @@
269276
<AttachedAttribute IsLocal="true" IsOverridable="true" Name="Instance Type" UserInput="true">
270277
<AllowedValues />
271278
</AttachedAttribute>
279+
<AttachedAttribute IsLocal="true" IsOverridable="true" Name="IAM Role Name" UserInput="true">
280+
<AllowedValues />
281+
</AttachedAttribute>
272282
<AttachedAttribute IsLocal="true" IsOverridable="true" Name="Storage Size" UserInput="false">
273283
<AllowedValues />
274284
</AttachedAttribute>

drivers/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.1
1+
2.3.0

external_requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
python-dateutil==2.6.1
21
boto3==1.4.5
32
jsonpickle==0.9.3
43
enum==0.4.6

0 commit comments

Comments
 (0)