コード例 #1
0
 def setUp(self):
     #Initialize core DB
     self.euca_admin_id = create_euca_provider()
     self.euca_provider = self.euca_admin_id.provider
     self.os_admin_id = create_os_provider()
     self.os_provider = self.os_admin_id.provider
     #Ensure there is an account created/ready to go
     euca_accounts = EucaAccounts(self.euca_provider)
     euca_user = euca_accounts.get_user(settings.TEST_RUNNER_USER)
     self.euca_id = euca_accounts.create_account(euca_user)
     os_accounts = OSAccounts(self.os_provider)
     self.os_id = os_accounts.create_account(
         settings.TEST_RUNNER_USER,
         os_accounts.hashpass(settings.TEST_RUNNER_USER))
     #Initialize API
     self.api_client = TokenAPIClient()
     self.api_client.login(username=settings.TEST_RUNNER_USER,
                           password=settings.TEST_RUNNER_PASS)
     reverse_link = reverse('api:public_apis:machine-list',
                            args=[self.os_id.provider.id, self.os_id.id])
     self.os_machine_url = urljoin(settings.SERVER_URL, reverse_link)
     reverse_link = reverse(
         'api:public_apis:machine-list',
         args=[self.euca_id.provider.id, self.euca_id.id])
     self.euca_machine_url = urljoin(settings.SERVER_URL, reverse_link)
コード例 #2
0
def main():
    for prov in Provider.objects.filter(type__name__icontains='openstack'):
        if not prov.is_active():
            continue
        print "Importing machine membership for %s" % prov
        accounts = OSAccounts(prov)
        if not accounts:
            print "Aborting import: Could not retrieve OSAccounts driver "\
                    "for Provider %s" % prov
            continue
        admin_driver = get_admin_driver(prov)
        if not admin_driver:
            print "Aborting import: Could not retrieve admin_driver "\
                    "for Provider %s" % prov
            continue

        private_images = admin_driver.filter_machines(
            accounts.list_all_images(is_public=False),
            black_list=["eki-", "eri-", "ChromoSnapShot"])

        public_images = admin_driver.filter_machines(
            accounts.list_all_images(is_public=True),
            black_list=["eki-", "eri-", "ChromoSnapShot"])

        fix_public_images(public_images, prov, accounts)
        fix_private_images(private_images, prov, accounts)
        fix_private_images_without_repr(private_images, prov, accounts)
コード例 #3
0
    def setUp(self):
        #Initialize core DB
        #Ensure there is an account created/ready to go

        #self.euca_admin_id = create_euca_provider()
        #self.euca_provider = self.euca_admin_id.provider
        #euca_accounts = EucaAccounts(self.euca_provider)
        #euca_user = euca_accounts.get_user(settings.TEST_RUNNER_USER)
        #self.euca_id = euca_accounts.create_account(euca_user, max_quota=True)

        self.os_admin_id = create_os_provider()
        self.os_provider = self.os_admin_id.provider
        os_accounts = OSAccounts(self.os_provider)
        self.os_id = os_accounts.create_account(settings.TEST_RUNNER_USER,
                                                os_accounts.hashpass(
                                                    settings.TEST_RUNNER_USER),
                                                max_quota=True)
        user = AtmosphereUser.objects.get(username=settings.TEST_RUNNER_USER)
        user.is_staff = True
        user.is_superuser = True
        user.save()
        #Initialize API
        self.api_client = TokenAPIClient()
        self.api_client.login(username=settings.TEST_RUNNER_USER,
                              password=settings.TEST_RUNNER_PASS)
        reverse_link = reverse('api:public_apis:instance-list',
                               args=[self.os_id.provider.id, self.os_id.id])
        self.os_instance_url = urljoin(settings.SERVER_URL, reverse_link)
        reverse_link = reverse('api:public_apis:machine-request-list',
                               args=[self.os_id.provider.id, self.os_id.id])
        self.os_request_url = urljoin(settings.SERVER_URL, reverse_link)
コード例 #4
0
    def setUp(self):
        #Initialize core DB
        self.euca_admin_id = create_euca_provider()
        self.euca_provider = self.euca_admin_id.provider
        self.os_admin_id = create_os_provider()
        self.os_provider = self.os_admin_id.provider
        #Ensure there is an account created/ready to go
        euca_accounts = EucaAccounts(self.euca_provider)
        euca_user = euca_accounts.get_user(settings.TEST_RUNNER_USER)
        self.euca_id = euca_accounts.create_account(euca_user, max_quota=True)
        os_accounts = OSAccounts(self.os_provider)
        self.os_id = os_accounts.create_account(settings.TEST_RUNNER_USER,
                                                os_accounts.hashpass(
                                                    settings.TEST_RUNNER_USER),
                                                max_quota=True)
        #user = AtmosphereUser.objects.get(username=settings.TEST_RUNNER_USER)
        #user.is_staff = True
        #user.is_superuser = True
        #user.save()
        #Initialize API
        self.api_client = TokenAPIClient()
        self.api_client.login(username=settings.TEST_RUNNER_USER,
                              password=settings.TEST_RUNNER_PASS)
        reverse_link = reverse('api:public_apis:instance-list',
                               args=[self.os_id.provider.id, self.os_id.id])
        self.os_instance_url = urljoin(settings.SERVER_URL, reverse_link)
        reverse_link = reverse('api:public_apis:volume-list',
                               args=[self.os_id.provider.id, self.os_id.id])
        #Prepare Openstack
        self.os_volume_url = urljoin(settings.SERVER_URL, reverse_link)
        instance_data = {
            "size_alias": "2",
            "machine_alias": "0f539197-3718-40bc-8a29-c22e0841684f",
            "name": "test volume attachment",
            "delete_before": False
        }
        (self.os_instance_id,
         self.os_instance_ip) = standup_instance(self, self.os_instance_url,
                                                 **instance_data)

        #Prepare Eucalyptus
        reverse_link = reverse(
            'api:public_apis:volume-list',
            args=[self.euca_id.provider.id, self.euca_id.id])
        self.euca_volume_url = urljoin(settings.SERVER_URL, reverse_link)
        reverse_link = reverse(
            'api:public_apis:instance-list',
            args=[self.euca_id.provider.id, self.euca_id.id])
        self.euca_instance_url = urljoin(settings.SERVER_URL, reverse_link)
        instance_data = {
            "size_alias": "m1.small",
            "machine_alias": "emi-E7F8300F",
            "name": "test volume attachment",
            "delete_before": False
        }
        (self.euca_instance_id,
         self.euca_instance_ip) = standup_instance(self,
                                                   self.euca_instance_url,
                                                   **instance_data)
コード例 #5
0
def setUp_openstack():
    #Initialize core DB
    global os_base_instance_url
    os_admin_id = create_os_provider()
    os_provider = os_admin_id.provider
    os_accounts = OSAccounts(os_provider)
    os_id = os_accounts.create_account(settings.TEST_RUNNER_USER,
                                       os_accounts.hashpass(
                                           settings.TEST_RUNNER_USER),
                                       max_quota=True)
    reverse_link = reverse('api:public_apis:instance-list',
                           args=[os_id.provider.id, os_id.id])
    os_base_instance_url = urljoin(settings.SERVER_URL, reverse_link)
コード例 #6
0
 def update_images():
     from service.accounts.openstack import AccountDriver as OSAccounts
     for pm in self.providermachine_set.all():
         if pm.provider.get_type_name().lower() != 'openstack':
             continue
         image_id = pm.identifier
         provider = pm.provider
         try:
             accounts = OSAccounts(pm.provider)
             image = accounts.image_manager.get_image(image_id)
             self.diff_updates(pm, image)
             accounts.image_manager.update_image(image, **updates)
         except Exception as ex:
             logger.warn("Image Update Failed for %s on Provider %s"
                         % (image_id, provider))
コード例 #7
0
def upload_privacy_data(machine_request, new_machine):
    from service.accounts.openstack import AccountDriver as OSAccounts
    from service.driver import get_admin_driver
    prov = new_machine.provider
    accounts = OSAccounts(prov)
    if not accounts:
        print "Aborting import: Could not retrieve OSAccounts driver "\
                "for Provider %s" % prov
        return
    admin_driver = get_admin_driver(prov)
    if not admin_driver:
        print "Aborting import: Could not retrieve admin_driver "\
                "for Provider %s" % prov
        return
    img = accounts.image_manager.get_image(new_machine.identifier)
    tenant_list = machine_request.get_access_list()
    #All in the list will be added as 'sharing' the OStack img
    #All tenants already sharing the OStack img will be added to this list
    tenant_list = sync_image_access_list(accounts, img, names=tenant_list)
    #Make private on the DB level
    make_private(accounts.image_manager, img, new_machine, tenant_list)