Beispiel #1
0
    def __init__(
        self, attributes
    ):  # todo handle the c=initialization of the object from the attributes
        self.cloud_provider = ''
        self.aws_ami_id = ''
        self.storage_size = ''
        self.storage_iops = ''
        # the storage type can be one of these: 'standard'|'io1'|'gp2'|'sc1'|'st1'
        self.storage_type = ''  # type: str
        self.min_count = 0  # type: int
        self.max_count = 0  # type: int
        self.instance_type = ''  # type: str
        self.iam_role = ''  # type: str
        self.security_group_ids = None  # type: str
        self.private_ip_address = ''  # type: str
        self.root_volume_name = ''  # type: str
        self.delete_on_termination = True  # type: bool
        self.auto_power_off = False  # type: bool
        self.wait_for_ip = False  # type: bool
        self.wait_for_status_check = False  # type: bool
        self.auto_delete = False  # type: bool
        self.autoload = False  # type: bool
        self.outbound_ports = ''  # type: str
        self.inbound_ports = ''  # type: str
        self.wait_for_credentials = ''  # type: str
        self.add_public_ip = False  # type: bool
        self.allocate_elastic_ip = False  # type: bool
        self.network_configurations = None  # type: list[NetworkAction]
        self.allow_all_sandbox_traffic = True  # type: bool

        self.aws_ami_id = attributes["AWS AMI Id"]
        self.allow_all_sandbox_traffic = convert_to_bool(
            attributes['Allow all Sandbox Traffic'])
        self.storage_size = attributes['Storage Size']
        self.storage_iops = attributes['Storage IOPS']
        self.storage_type = attributes['Storage Type']
        self.instance_type = attributes['Instance Type']
        self.iam_role = attributes['IAM Role Name']
        self.root_volume_name = attributes['Root Volume Name']
        self.wait_for_ip = convert_to_bool(attributes['Wait for IP'])
        self.wait_for_status_check = convert_to_bool(
            attributes['Wait for Status Check'])
        self.autoload = convert_to_bool(attributes['Autoload'])
        self.inbound_ports = attributes['Inbound Ports']
        self.wait_for_credentials = convert_to_bool(
            attributes['Wait for Credentials'])
        (self.add_public_ip, self.allocate_elastic_ip) = \
            AWSModelsParser.parse_public_ip_options_attribute(attributes['Public IP Options'])
    def parse(action):
        """
        :param dict params_data:
        :rtype: ConnectionParamsBase
        """
        params_data = action.get("connectionParams")
        params = None
        if not params_data:
            return params

        params_type = params_data["type"]

        if params_type == "connectToSubnetParams":
            params = SubnetConnectionParams()
            params.subnet_id = params_data['subnetId']

        elif params_type == "prepareSubnetParams":
            params = PrepareSubnetParams()
            params.is_public = convert_to_bool(params_data['isPublic'])
            params.alias = params_data.get('alias', '')

        elif params_type == "prepareNetworkParams":
            params = PrepareNetworkParams()

        else:
            raise ValueError("Unsupported connection params type {0}".format(type))

        ConnectionParamsParser.parse_base_data(params, params_data, action)

        return params
Beispiel #3
0
    def convert_to_deployment_resource_model(deployment_request, resource):
        """
        :param str deployment_request: JSON string representing the deployment request
        :param ResourceContextDetails resource: The details of the resource using the driver
        """
        data = jsonpickle.decode(deployment_request)
        deployment_resource_model = DeployAWSEc2AMIInstanceResourceModel()

        deployment_resource_model.cloud_provider = resource.name
        deployment_resource_model.app_name = data["AppName"]

        deployment_resource_model.aws_ami_id = data["Attributes"]['AWS AMI Id']
        deployment_resource_model.allow_all_sandbox_traffic = convert_to_bool(
            data["Attributes"]['Allow all Sandbox Traffic'])
        deployment_resource_model.storage_size = data["Attributes"][
            'Storage Size']
        deployment_resource_model.storage_iops = data["Attributes"][
            'Storage IOPS']
        deployment_resource_model.storage_type = data["Attributes"][
            'Storage Type']
        deployment_resource_model.instance_type = data["Attributes"][
            'Instance Type']
        deployment_resource_model.root_volume_name = data["Attributes"][
            'Root Volume Name']
        deployment_resource_model.wait_for_ip = convert_to_bool(
            data["Attributes"]['Wait for IP'])
        deployment_resource_model.wait_for_status_check = convert_to_bool(
            data["Attributes"]['Wait for Status Check'])
        deployment_resource_model.autoload = convert_to_bool(
            data["Attributes"]['Autoload'])
        deployment_resource_model.inbound_ports = data["Attributes"][
            'Inbound Ports']
        deployment_resource_model.wait_for_credentials = \
            convert_to_bool(data["Attributes"]['Wait for Credentials'])

        (deployment_resource_model.add_public_ip, deployment_resource_model.allocate_elastic_ip) = \
            AWSModelsParser.parse_public_ip_options_attribute(data["Attributes"]['Public IP Options'])

        deployment_resource_model.user = \
            AWSModelsParser.get_attribute_value_by_name_ignoring_namespace(
                data["LogicalResourceRequestAttributes"], "User")

        deployment_resource_model.network_configurations = \
            AWSModelsParser.parse_deploy_networking_configurations(data)

        return deployment_resource_model
    def __init__(self, attributes):  # todo handle the c=initialization of the object from the attributes
        self.cloud_provider = ''
        self.aws_ami_id = ''
        self.storage_size = ''
        self.storage_iops = ''
        # the storage type can be one of these: 'standard'|'io1'|'gp2'|'sc1'|'st1'
        self.storage_type = ''  # type: str
        self.min_count = 0  # type: int
        self.max_count = 0  # type: int
        self.instance_type = ''  # type: str
        self.iam_role = ''  # type: str
        self.security_group_ids = None  # type: str
        self.private_ip_address = ''  # type: str
        self.root_volume_name = ''  # type: str
        self.delete_on_termination = True  # type: bool
        self.auto_power_off = False  # type: bool
        self.wait_for_ip = False  # type: bool
        self.wait_for_status_check = False  # type: bool
        self.auto_delete = False  # type: bool
        self.autoload = False  # type: bool
        self.outbound_ports = ''  # type: str
        self.inbound_ports = ''  # type: str
        self.wait_for_credentials = ''  # type: str
        self.add_public_ip = False  # type: bool
        self.allocate_elastic_ip = False  # type: bool
        self.network_configurations = None  # type: list[NetworkAction]
        self.allow_all_sandbox_traffic = True  # type: bool

        self.aws_ami_id = attributes["AWS AMI Id"]
        self.allow_all_sandbox_traffic = convert_to_bool(attributes['Allow all Sandbox Traffic'])
        self.storage_size = attributes['Storage Size']
        self.storage_iops = attributes['Storage IOPS']
        self.storage_type = attributes['Storage Type']
        self.instance_type = attributes['Instance Type']
        self.iam_role = attributes['IAM Role Name']
        self.root_volume_name = attributes['Root Volume Name']
        self.wait_for_ip = convert_to_bool(attributes['Wait for IP'])
        self.wait_for_status_check = convert_to_bool(attributes['Wait for Status Check'])
        self.autoload = convert_to_bool(attributes['Autoload'])
        self.inbound_ports = attributes['Inbound Ports']
        self.wait_for_credentials = convert_to_bool(attributes['Wait for Credentials'])
        (self.add_public_ip, self.allocate_elastic_ip) = \
            AWSModelsParser.parse_public_ip_options_attribute(attributes['Public IP Options'])
 def test_parse_bool_value_as_string_and_as_boolean(self):
     self.assertTrue(convert_to_bool("True"))
     self.assertTrue(convert_to_bool(True))
     self.assertFalse(convert_to_bool("False"))
     self.assertFalse(convert_to_bool(False))
 def test_parse_bool_value_as_string_and_as_boolean(self):
     self.assertTrue(convert_to_bool("True"))
     self.assertTrue(convert_to_bool(True))
     self.assertFalse(convert_to_bool("False"))
     self.assertFalse(convert_to_bool(False))
    def __init__(
        self, attributes
    ):  # todo handle the c=initialization of the object from the attributes
        self.user_data_url = ""
        self.user_data_run_parameters = ""

        self.custom_tags = ""
        self.cloud_provider = ""
        self.aws_ami_id = ""
        self.storage_size = ""
        self.storage_iops = ""
        # the storage type can be one of these: 'standard'|'io1'|'gp2'|'sc1'|'st1'
        self.storage_type = ""  # type: str
        self.min_count = 0  # type: int
        self.max_count = 0  # type: int
        self.instance_type = ""  # type: str
        self.iam_role = ""  # type: str
        self.security_group_ids = None  # type: str
        self.private_ip_address = ""  # type: str
        self.private_ip_addresses_dict = None  # type: Dict
        self.root_volume_name = ""  # type: str
        self.delete_on_termination = True  # type: bool
        self.auto_power_off = False  # type: bool
        self.wait_for_ip = False  # type: bool
        self.wait_for_status_check = False  # type: bool
        self.auto_delete = False  # type: bool
        self.autoload = False  # type: bool
        self.outbound_ports = ""  # type: str
        self.inbound_ports = ""  # type: str
        self.wait_for_credentials = ""  # type: str
        self.add_public_ip = False  # type: bool
        self.allocate_elastic_ip = False  # type: bool
        self.network_configurations = None  # type: list["NetworkAction"]  # noqa
        self.allow_all_sandbox_traffic = True  # type: bool

        self.aws_ami_id = attributes[f"{self.__deploymentModel__}.AWS AMI Id"]
        self.allow_all_sandbox_traffic = convert_to_bool(
            attributes[f"{self.__deploymentModel__}.Allow all Sandbox Traffic"]
        )
        self.storage_size = attributes[
            f"{self.__deploymentModel__}.Storage Size"]
        self.storage_iops = attributes[
            f"{self.__deploymentModel__}.Storage IOPS"]
        self.storage_type = attributes[
            f"{self.__deploymentModel__}.Storage Type"]
        self.instance_type = attributes[
            f"{self.__deploymentModel__}.Instance Type"]
        self.iam_role = attributes[f"{self.__deploymentModel__}.IAM Role Name"]
        self.root_volume_name = attributes[
            f"{self.__deploymentModel__}.Root Volume Name"]
        self.wait_for_ip = convert_to_bool(
            attributes[f"{self.__deploymentModel__}.Wait for IP"])
        self.wait_for_status_check = convert_to_bool(
            attributes[f"{self.__deploymentModel__}.Wait for Status Check"])
        self.autoload = convert_to_bool(
            attributes[f"{self.__deploymentModel__}.Autoload"])
        self.inbound_ports = attributes[
            f"{self.__deploymentModel__}.Inbound Ports"]
        self.wait_for_credentials = convert_to_bool(
            attributes[f"{self.__deploymentModel__}.Wait for Credentials"])
        (
            self.add_public_ip,
            self.allocate_elastic_ip,
        ) = AWSModelsParser.parse_public_ip_options_attribute(
            attributes[f"{self.__deploymentModel__}.Public IP Options"])
        self.custom_tags = attributes[
            f"{self.__deploymentModel__}.Custom Tags"]
        self.user_data_url = attributes[
            f"{self.__deploymentModel__}.User Data URL"]
        self.user_data_run_parameters = attributes[
            f"{self.__deploymentModel__}.User Data Parameters"]

        private_ip_att_value = attributes[
            f"{self.__deploymentModel__}.Private IP"]
        self.private_ip_address = self._get_primary_private_ip_address(
            private_ip_att_value)
        self.private_ip_addresses_dict = self._get_private_ip_addresses_dict(
            private_ip_att_value)