예제 #1
0
    def __run_nat_instance (self):
        
        #image_id:  ID of the image we are creating, here it's AMAZON LINUX VPC NAT instance id
        #instance_type:  This is the flavour we're using 
       	#		m3.xlarge provides 4 vCPUs,15GiB and 2*40 GB SSD Storage  		
        
        reservation = self.ec2_conn.run_instances (
                        image_id = 'ami-1a9dac48', min_count = 1, 
			max_count = 1, key_name ='openstack-workshop',
                        instance_type = 'm3.xlarge',
                        subnet_id = self.public_subnet.id,
                        private_ip_address='172.16.0.5',
                    	security_group_ids = [self.sg_nat.id]);
        nat_instance = reservation.instances[0];
        nat_instance.add_tag("Name", self.conf["name"] + "_NAT");
        
        # Each EC2 instance performs source/destination checks by default. 
        # This means that the instance must be the source or destination 
        # of any traffic it sends or receives. 
        # However, a NAT instance must be able to send and receive traffic
        # whem the source or destination is not itself. Therefore, we must 
        # disable source/destination checks on the NAT instance
        
        self.ec2_conn.modify_instance_attribute(
                                            instance_id = nat_instance.id,
                                            attribute = 'sourceDestCheck', 
                                            value=False);
                                            
        # Wait for the NAT instance to get into running state 
        # We cannot assing an EIP to it until it is in the running
        
        awsUtils.wait_for_instances([nat_instance.id], 'running', 
                                    self.ec2_conn);
        return nat_instance;
예제 #2
0
    def __run_nat_instance(self):

        #image_id:  ID of the image we are creating, here it's AMAZON LINUX VPC NAT instance id
        #instance_type:  This is the flavour we're using
        #		m3.xlarge provides 4 vCPUs,15GiB and 2*40 GB SSD Storage

        reservation = self.ec2_conn.run_instances(
            image_id='ami-1a9dac48',
            min_count=1,
            max_count=1,
            key_name='openstack-workshop',
            instance_type='m3.xlarge',
            subnet_id=self.public_subnet.id,
            private_ip_address='172.16.0.5',
            security_group_ids=[self.sg_nat.id])
        nat_instance = reservation.instances[0]
        nat_instance.add_tag("Name", self.conf["name"] + "_NAT")

        # Each EC2 instance performs source/destination checks by default.
        # This means that the instance must be the source or destination
        # of any traffic it sends or receives.
        # However, a NAT instance must be able to send and receive traffic
        # whem the source or destination is not itself. Therefore, we must
        # disable source/destination checks on the NAT instance

        self.ec2_conn.modify_instance_attribute(instance_id=nat_instance.id,
                                                attribute='sourceDestCheck',
                                                value=False)

        # Wait for the NAT instance to get into running state
        # We cannot assing an EIP to it until it is in the running

        awsUtils.wait_for_instances([nat_instance.id], 'running',
                                    self.ec2_conn)
        return nat_instance
예제 #3
0
    def __run_cloud_instances(self, private_ip=None):

        cloud_instances = []
        #create IP for the controller instance, [.91]
        controller_ip = self.__create_private_ip('91')
        #create IP for the compute instance, [.92]
        compute_ip = self.__create_private_ip('92')
        #It'll run the instance, ID here is the id of the instance with pre installed devstack in them
        controller = self.__run_cloud_instance(controller_ip,
                                               image_id='ami-0f7aba6c')
        compute = self.__run_cloud_instance(compute_ip,
                                            image_id='ami-9c7abaff')
        controller.add_tag("Name", "Controller_" + self.participant_id)
        compute.add_tag("Name", "Compute_" + self.participant_id)
        cloud_instances.append(controller)
        cloud_instances.append(compute)
        #Wait for instances to be in running state
        ids = []
        for instance in cloud_instances:
            ids.append(instance.id)
        awsUtils.wait_for_instances(ids, 'running')
        return controller_ip, compute_ip, cloud_instances
예제 #4
0
 def __run_cloud_instances (self, private_ip = None):
     
     cloud_instances = [];
     #create IP for the controller instance, [.91]
     controller_ip = self.__create_private_ip('91');
     #create IP for the compute instance, [.92]
     compute_ip = self.__create_private_ip('92');
     #It'll run the instance, ID here is the id of the instance with pre installed devstack in them
     controller = self.__run_cloud_instance(
                             controller_ip,
                             image_id='ami-0f7aba6c');
     compute = self.__run_cloud_instance(
                             compute_ip,
                             image_id='ami-9c7abaff');
     controller.add_tag("Name", "Controller_" + self.participant_id );
     compute.add_tag("Name", "Compute_" + self.participant_id);
     cloud_instances.append(controller);
     cloud_instances.append(compute);
     #Wait for instances to be in running state
     ids = [];
     for instance in cloud_instances:
         ids.append(instance.id);
     awsUtils.wait_for_instances(ids, 'running');
     return controller_ip, compute_ip, cloud_instances;
예제 #5
0
    def __terminate_cloud_instances(self):

        self.ec2_conn.terminate_instances(instance_ids=self.instance_ids)
        awsUtils.wait_for_instances(self.instance_ids, 'terminated',
                                    self.ec2_conn)
 def __terminate_cloud_instances (self):
     
     self.ec2_conn.terminate_instances (instance_ids=self.instance_ids);
     awsUtils.wait_for_instances(self.instance_ids, 'terminated', 
                                 self.ec2_conn);