Пример #1
0
    def __init__(self, edw_service_spec):
        super(Redshift, self).__init__(edw_service_spec)
        # pkb setup attribute
        self.project = None
        self.cmd_prefix = list(util.AWS_PREFIX)
        if FLAGS.zones:
            self.zone = FLAGS.zones[0]
            self.region = util.GetRegionFromZone(self.zone)
        else:
            self.region = GetDefaultRegion()
        self.cmd_prefix += ['--region', self.region]

        # Redshift specific attribute (see if they can be set)
        self.cluster_subnet_group = None
        self.cluster_parameter_group = None
        self.arn = ''
        self.cluster_subnet_group = aws_cluster_subnet_group.RedshiftClusterSubnetGroup(
            self.cmd_prefix)
        self.cluster_parameter_group = aws_cluster_parameter_group.RedshiftClusterParameterGroup(
            self.cmd_prefix)

        if self.db is None:
            self.db = DEFAULT_DATABASE_NAME
        self.client_interface = GetRedshiftClientInterface(
            self.db, self.user, self.password)
 def testValidClusterParameterGroupDeletion(self):
   csg = aws_cluster_subnet_group.RedshiftClusterSubnetGroup(
       list(util.AWS_PREFIX))
   self.assertEqual(csg.name, 'pkb-%s' % TEST_RUN_URI)
   with mock.patch(
       vm_util.__name__ + '.IssueCommand',
       return_value=('out_', 'err_', 0)) as mock_issue:
     csg._Delete()
     mock_issue.assert_called_once()
     mock_issue.assert_called_with(
         ['aws', '--output', 'json', 'redshift', 'delete-cluster-subnet-group',
          '--cluster-subnet-group-name', 'pkb-%s' % TEST_RUN_URI],
         raise_on_failure=False)
 def testValidClusterParameterGroupCreation(self):
   csg = aws_cluster_subnet_group.RedshiftClusterSubnetGroup(
       list(util.AWS_PREFIX))
   csg.subnet_id = CLUSTER_SUBNET_ID
   self.assertEqual(csg.name, 'pkb-%s' % TEST_RUN_URI)
   with mock.patch(
       vm_util.__name__ + '.IssueCommand',
       return_value=('out_', 'err_', 0)) as mock_issue:
     csg._Create()
     mock_issue.assert_called_once()
     mock_issue.assert_called_with([
         'aws', '--output', 'json', 'redshift', 'create-cluster-subnet-group',
         '--cluster-subnet-group-name', 'pkb-%s' % TEST_RUN_URI,
         '--description', 'Cluster Subnet Group for run uri %s' % TEST_RUN_URI,
         '--subnet-ids', CLUSTER_SUBNET_ID])