Problems with waiters AWS PHP SDK3 - amazon-web-services

I'm trying to change instance type but since I have updated to SDK3 this script fails. I don't know what I'm doing wrong with waiters.
$client = new Ec2Client(self::getCredentials());
$client->stopInstances(array(
'InstanceIds' => $instanceIds,
));
$client->waitUntil('stopped', [
'InstanceId' => $instanceId,
]);
$client->ModifyInstanceAttribute(array(
'InstanceId' => $instanceId,
'Attribute' => 'instanceType',
'Value' => $instanceType
));
$client->startInstances(array(
'InstanceIds' => $instanceIds,
));
$client->waitUntil('running', [
'InstanceId' => $instanceId,
]);

I finally found the solution.
The problem was that InstanceId param was wrong... You have to use an array of instaces Ids.
$client->waitUntil('InstanceStopped', [
'InstanceIds' => array($instanceId),
]);
$client->waitUntil('InstanceRunning', [
'InstanceIds' => array($instanceId),
]);

Related

Failed to connect to importexport.amazonaws.com port 443

Any body knows how to solve this
Error message after trying to convert the image to ami
Note (I already try to import via command line and it's working good)
I'm trying to convert image from row to ami using laravel 8
Here is the information
1.) "aws/aws-sdk-php": "^3.231"
2.) php 8
3.) my code to process the conversion
public function startConversion(string $s3DiskImageName, string $description): void{
$client = ImportExportClient::factory(array(
'credentials' => array(
'key' => config('filesystems.disks.s3.key'),
'secret' => config('filesystems.disks.s3.secret'),
),
'region' => config('filesystems.disks.s3.region'),
'version' => 'latest'
));
$bucket = config('filesystems.disks.s3.bucket');
$client->createJob([
'JobType' => 'Import',
'ValidateOnly' => false,
'Manifest' => json_encode([
[
'Description' => "$s3DiskImageName - $description",
'Format' => 'raw',
'Url' => 's3:://'.$bucket .'/'.$s3DiskImageName
]
])
]);
}
Thanks in advance!

Make a Stub for nesting function in Yii2

I learn to use Unit test in Yii2 with Codeception, and try to check if a billing is a "daily" billing from a merchant's setting.
$this->biller->merchant->detail->rule_type == self::PERIODIC_MODE_DAILY
I don't know how to mock that rule_type value if I use a Stub::make() function.
What I tried so far is using the nested array like this (doesn't work) :
$billing = Stub::make(Billing::class, [
'status' => Billing::STATUS_ACTIVE,
'set_periodic_by' => Billing::SET_PERIODIC_BY_MERCHANT,
'biller' => [
'merchant' => [
'detail' => [
'rule_type' => Billing::PERIODIC_MODE_DAILY,
]
]
]
]);
And I also tried to mock each of the object model using another Stub::make()
$billing = Stub::make(Billing::class, [
'status' => Billing::STATUS_ACTIVE,
'set_periodic_by' => Billing::SET_PERIODIC_BY_MERCHANT,
'getBiller' => Stub::make(Biller::class, [
'getMerchant' => Stub::make(Merchant::class, [
'getDetail' => Stub::make(MerchantDetail::class, [
'rule_type' => Billing::PERIODIC_MODE_DAILY,
])
])
])
]);
How do I properly create a "nested" function return values using Stub? Any comment or answer is always welcome.
Casting the nested array to (object) will do
$billing = Stub::make(Billing::class, [
'status' => Billing::STATUS_ACTIVE,
'set_periodic_by' => Billing::SET_PERIODIC_BY_MERCHANT,
'getBiller' => (object) [
'merchant' => (object) [
'detail' => (object) [
'rule_type' => Billing::PERIODIC_MODE_DAILY,
]
]
]
]);

Creating Salesorder with Vtiger Webservice missing Tax

I have the Problem when creating an salesorder with Vtiger Webservice,
The sales order is created but somehow the tax is not added.
I thought it has something to do with the parameter : hdnTaxType
Cause even if I add this value 'group' it does not apply the Tax to the Salesorder.
I have to manually add The Taxtype 'group' then the system adds the tax.
thats why i tried to add values like:
'tax1' => '7.00',
and
'group_tax' =>[
'group_tax_percentage1' => '7.0'
],
nothing so far did help...
has anybody an Idea what the problem is?
Thank you
Tobi
$salesOrder =[
'lastname' => $customer['lastname'],
'subject' => 'Order from 01.01.1018',
'sostatus' => '1',
'assigned_user_id' => '',
'bill_street' => 'Rechunngsstrasse 123',
'ship_street' =>'Lieferungsstrasse 123',
'productid' => '14x4325',
'currency_id' => '21x1',
'carrier' => 'DHL',
'txtAdjustment' => '13',
'salescommission' => '12',
'exciseduty' => '15',
'hdnTaxType' => 'group',
'tax1' => '7.00',
'hdnS_H_Amount' => '22.22',
'group_tax' =>[
'group_tax_percentage1' => '7.0'
],
'LineItems' => [
0 => [
"taxid" => "33x1",
'productid'=>'14x6',
'listprice'=>'20.53',
'quantity'=>'3',
'comment' => "Product123"
]
]
Webservices in Vtiger are not complete.
In this case you can register your own webservice that makes your queries, or check the SalesOrder in the after-save event

Route_Regex in zend framework

My aim was to create common route for that cases:
http://test.com/pages/cat_name/about
http://test.com/pages/?????/about
http://test.com/pages/about
....
I've wrote in bootstrap:
$router->addRoute("pages",new Zend_Controller_Router_Route_Regex(
'pages/(\w+)/:stitle',
array( 'controller' => 'pages',
'action' => 'index',
'module' => 'pages')));
but it still doesnt work. whats wrong?
your code shoud be like this:
$router = Zend_Controller_Front::getInstance()->getRouter();
$route = new Zend_Controller_Router_Route(':interface/:module/:controller/:action/*',
array('interface' => 'en',
'module' => 'pages',
'controller' => 'pages',
'action' => 'index'));
$router->addRoute('route_name', $route);

ZF2 + Doctrine 2 : Cli Tool has Access Denied

I have a ZF2 2.1.3 app with Doctrine 2.
I installed using composer:
"zendframework/zendframework": "2.*"
,"doctrine/doctrine-orm-module": "dev-master"
A create a file config/autoload/database.local.php with the following:
return array(
'doctrine' => array(
'connection' => array(
// Default connection name
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'dbname' => 'zf2-experimental',
'user' => 'root',
'password' => '',
),
),
),
),
);
I create my entity Bar under Foo module (src/Business/Entity/Bar.php) and configure it on module.config.php like this:
'doctrine' => array(
'driver' => array(
__NAMESPACE__ . '_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Business/Entity'),
),
'orm_default' => array(
'drivers' => array(
__NAMESPACE__ . '\Business\Entity' => __NAMESPACE__ . '_driver',
),
),
),
),
Ok! It's exactly at Sam says here!
Then I create a simple Foo entity and run the doctrine cli tool:
c:\wamp\www\zf2-Experimental>.\vendor\bin\doctrine-module.bat orm:validate-schema
[Mapping] OK - The mapping files are correct.
[PDOException]
SQLSTATE[28000] [1045] Access denied for user 'username'#'localhost' (using password: YES)
orm:validate-schema
c:\wamp\www\zf2-Experimental>
Looks like the cli tool can get my connection parameters in my config/autoload/database.local.php!
On Application index I tested my config:
$config = $this->getServiceLocator()->get('config');
\Zend\Debug\Debug::dump($config['doctrine']['connection']['orm_default']);
And this returned:
array (size=4)
'configuration' => string 'orm_default' (length=11)
'eventmanager' => string 'orm_default' (length=11)
'params' =>
array (size=5)
'host' => string 'localhost' (length=9)
'port' => string '3306' (length=4)
'user' => string 'root' (length=4)
'password' => string '' (length=0)
'dbname' => string 'zf2-experimental' (length=16)
'driverClass' => string 'Doctrine\DBAL\Driver\PDOMySql\Driver' (length=36)
Someone can, please, help me?! :)
Thanks you all!
Well, I waste a lot of time trying to solve this and finally did.
I forgot to mention that I using ZF1 environment-specific configurations style!
You can see here!
I create my database config file in the following structure (I didn't mention this before, because I thought It wouldn't interfere on the question):
'module_listener_options' => array(
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
// Here! My config path is config/autoload/app_env/development/
'config/autoload/app_env/' . (getenv('APPLICATION_ENV') ?: 'production') . '{,*.}.local.php',
),
So, my database configs actually are in config/autoload/app_env/development/database.local.php!
When I copy-paste the file to config/autoload/database.local.php my CLI Tool works!
But WHY? Why the Cli Tool can't look for the config file inside another directory?
There is a way to work with sub-folders?
Thanks for the help!