'Creates test adding instances to GCE.
Create three instances.
* The first two are of different types and zones, which
we\'ll check. Future tests will also be using these
from different zones (but same region).
* The third is a duplicate in the same zone as another
so we can check duplicate deletes (which limit one zone per call).
We\'ll set the class properties use_instance_names and use_instance_zones
so that they can be communicated to future tests to reference.
Returns:
st.OperationContract'

def create_instances(self):

    self.use_instance_names = [('katotest%sa' % self.test_id), ('katotest%sb' % self.test_id), ('katotest%sc' % self.test_id)]
    test_zone = self.bindings['TEST_GCE_ZONE']
    other_zone = (self.bindings['TEST_GCE_REGION'] + ('-b' if (test_zone[(-1)] != 'b') else '-c'))
    self.use_instance_zones = [test_zone, other_zone, test_zone]
    image_name = [self.bindings['TEST_GCE_IMAGE_NAME'], 'debian-7-wheezy-v20150818', self.bindings['TEST_GCE_IMAGE_NAME']]
    if (image_name[0] == image_name[1]):
        image_name[1] = 'ubuntu-1404-trusty-v20150805'
    machine_type = ['f1-micro', 'g1-small', 'f1-micro']
    instance_spec = []
    builder = gcp.GcpContractBuilder(self.gcp_observer)
    for i in range(3):
        instance_spec.append({'createGoogleInstanceDescription': {'instanceName': self.use_instance_names[i], 'image': image_name[i], 'instanceType': machine_type[i], 'zone': self.use_instance_zones[i], 'credentials': self.bindings['SPINNAKER_GOOGLE_ACCOUNT']}})
        builder.new_clause_builder(('Instance    %d    Created' % i), retryable_for_secs=90).aggregated_list_resource('instances').EXPECT(ov_factory.value_list_path_contains('name', jp.STR_SUBSTR(self.use_instance_names[i])))
        if (i < 2):
            builder.new_clause_builder(('Instance    %d    Details' % i)).inspect_resource('instances', self.use_instance_names[i], zone=self.use_instance_zones[i]).contains_path_value('machineType', machine_type[i])
            builder.new_clause_builder(('Instance    %d    Is    Running' % i), retryable_for_secs=120).inspect_resource('instances', self.use_instance_names[i], zone=self.use_instance_zones[i]).EXPECT(ov_factory.value_list_path_contains('status', jp.STR_EQ('RUNNING')))
    payload = self.agent.make_json_payload_from_object(instance_spec)
    return st.OperationContract(self.new_post_operation(title='create_instances', data=payload, path='ops'), contract=builder.build())
